/*-------------------------------------------------------------------------------------------------------------- * Copyright (c) insite-gmbh. All rights reserved. * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------------------------*/ import { IMenuItem } from '../interfaces/menuItem'; import { Router } from '@angular/router'; import { IMenuProvider } from '../interfaces/menuProvider'; /** * Baseclass for menu items * @class MenuItemBase * @classdesc The structure for the Items of a menu * @author insite-gmbh */ export class MenuItemBase implements IMenuItem{ constructor(public id:number,public text:string = "", public action:string = "", public childs: Array = [], public parent:IMenuItem = null){ if(this.childs != null){ try{ this.childs.forEach(c => c.parent = this); } catch(error){} } } public provider:IMenuProvider; public isDisabled:boolean = false; public isSelected:boolean = false; /** * call this action on select * @method selectAction */ public async selectAction():Promise{ if(this.parent != null) return await this.provider.applySelectAction(this); return true; } }