UNPKG

armisa-models

Version:
119 lines (111 loc) 4.68 kB
import { ChildOfSubMenuItemFactory } from "./4-MenuChilOfSubMenuItemFactory"; import { ITypeOfFormForRoute } from "./1-MenuFactory"; import { MenuItemFactory } from "./2-MenuItemFactory"; import { IParentFormManager } from "../../Page/ElementsOfFormFactory"; import { INaming } from "../../NamingCaption"; export class MenuSubItemFactory { public visible: boolean = true; public keyOfSubItem: string; constructor( public menuItemFactory: MenuItemFactory, public caption: string, public accounting: boolean, public purchase: boolean, public sale: boolean, public treasury: boolean, public warehouse: boolean, public produce: boolean, public pms: boolean, public costOfGoods: boolean, public payment: boolean, public asset: boolean, public warranty: boolean, public automation: boolean, public dailyDistribution: boolean, public preventindMaintainance: boolean, public workflow: boolean, public path?: string, public Page?: React.ComponentType<{ parentFormManager: IParentFormManager }>, public exact?: boolean, public onClick?: () => void, public typeOfForm?: ITypeOfFormForRoute, ) { this.keyOfSubItem = this.menuItemFactory.subMenuItems.length + 'subMenu'; } public childOfSubMenuItems: ChildOfSubMenuItemFactory[] = []; public addNewSubMenuItem(caption: INaming | string): ChildOfSubMenuItemFactory { let captionFinal = ''; if (caption) { if (typeof caption === 'string') { captionFinal = caption; } else if (caption) { captionFinal = this.menuItemFactory.menuFactory.mainStateManager.getCaptionNaming(caption); } } const childOfSubMenuItems = new ChildOfSubMenuItemFactory(this, captionFinal); this.childOfSubMenuItems.push(childOfSubMenuItems); return childOfSubMenuItems; } public get isAllSystems() { return ( this.accounting && this.asset && this.automation && this.costOfGoods && this.dailyDistribution && this.payment && this.pms && this.preventindMaintainance && this.pms && this.produce && this.purchase && this.sale && this.treasury && this.warehouse && this.warranty && this.workflow ) || ( !this.accounting && !this.asset && !this.automation && !this.costOfGoods && !this.dailyDistribution && !this.payment && !this.pms && !this.preventindMaintainance && !this.pms && !this.produce && !this.purchase && !this.sale && !this.treasury && !this.warehouse && !this.warranty && !this.workflow ); } public get isSystemSelected(): boolean { // return this.visible && // ( // this.isAllSystems || // this.currentSelected.accounting && this.accounting || // this.currentSelected.asset && this.asset || // this.currentSelected.automation && this.automation || // this.currentSelected.costOfGoods && this.costOfGoods || // this.currentSelected.dailyDistribution && this.dailyDistribution || // this.currentSelected.payment && this.payment || // this.currentSelected.pms && this.pms || // this.currentSelected.preventindMaintainance && this.preventindMaintainance || // this.currentSelected.produce && this.produce || // this.currentSelected.purchase && this.purchase || // this.currentSelected.sale && this.sale || // this.currentSelected.treasury && this.treasury || // this.currentSelected.warehouse && this.warehouse || // this.currentSelected.warranty && this.warranty || // this.currentSelected.workflow && this.workflow || // this.childOfSubMenuItems.some(i => i.isSystemSelected()) // ); // } return true; } }