Introducción
Primeramente vamos a definir el modelado de los elementos de la interfaz de usuario
1. Modelo de datos
En principio crearemos varios ficheros:
- config.model.ts: donde guardaremos parámetros y enumeraciones
- menu.model.ts: que define la estructura de menú
Veamos el primero (config.model.ts):
/**
* Configuration and base enums
*/
/**
* Type of action in a menu
*/
export enum MenuAction {
Menu = 0, // Link to submenu
Component, // Link to a component
Procedure, // Link to a procedure
URL // link to an URL
}
Y ahora el segundo (menu.model.ts)
/**
* Menu structure
*/
import { MenuAction } from './config.model'; // <-- import this
export class Menu {
title: string; // title of the menu
actionType: MenuAction; // Type of action as MenuAction
action: string; // action
submenu: Menu; // submenu
info: string; // Additional info
constructor(title: string, actionType: MenuAction,
info: string, action: string, submenu: Menu) {
this.title = title;
this.actionType = actionType;
this.info = info;
this.action = action ;
this.submenu = submenu;
}
}
* Menu structure
*/
import { MenuAction } from './config.model'; // <-- import this
export class Menu {
title: string; // title of the menu
actionType: MenuAction; // Type of action as MenuAction
action: string; // action
submenu: Menu; // submenu
info: string; // Additional info
constructor(title: string, actionType: MenuAction,
info: string, action: string, submenu: Menu) {
this.title = title;
this.actionType = actionType;
this.info = info;
this.action = action ;
this.submenu = submenu;
}
}
No hay comentarios :
Publicar un comentario