armisa-models
Version:
models of armisa!
135 lines (134 loc) • 5.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MenuItemFactory = void 0;
const _3_MenuSubItemFactory_1 = require("./3-MenuSubItemFactory");
class MenuItemFactory {
get currentSelected() {
// return this.menuFactory.authFactory.systems;
return true;
}
constructor(menuFactory, caption, accounting, purchase, sale, treasury, warehouse, produce, pms, costOfGoods, payment, asset, warranty, automation, dailyDistribution, preventindMaintainance, workflow, users, path, Page, exact, onClick) {
this.menuFactory = menuFactory;
this.caption = caption;
this.accounting = accounting;
this.purchase = purchase;
this.sale = sale;
this.treasury = treasury;
this.warehouse = warehouse;
this.produce = produce;
this.pms = pms;
this.costOfGoods = costOfGoods;
this.payment = payment;
this.asset = asset;
this.warranty = warranty;
this.automation = automation;
this.dailyDistribution = dailyDistribution;
this.preventindMaintainance = preventindMaintainance;
this.workflow = workflow;
this.users = users;
this.path = path;
this.Page = Page;
this.exact = exact;
this.onClick = onClick;
this.visible = true;
this.subMenuItems = [];
this.keyOfItem = this.menuFactory.menuItems.length + 'menu';
}
addNewSubMenuItem(caption, path, Page, exact, onClick, accounting, purchase, sale, treasury, warehouse, produce, pms, costOfGoods, payment, asset, warranty, automation, dailyDistribution, preventindMaintainance, workflow, typeOfForm) {
let captionFinal = '';
if (caption) {
if (typeof caption === 'string') {
captionFinal = caption;
}
else if (caption) {
captionFinal = this.menuFactory.mainStateManager.getCaptionNaming(caption);
}
}
const menuSubItemFactory = new _3_MenuSubItemFactory_1.MenuSubItemFactory(this, captionFinal, accounting || false, purchase || false, sale || false, treasury || false, warehouse || false, produce || false, pms || false, costOfGoods || false, payment || false, asset || false, warranty || false, automation || false, dailyDistribution || false, preventindMaintainance || false, workflow || false, path, Page, exact, onClick, typeOfForm);
this.subMenuItems.push(menuSubItemFactory);
if (typeof path === 'string' && path !== "" && Page && typeof Page === 'function') {
const route = { path, Page, exact, typeOfForm };
this.menuFactory.routes.push(route);
}
return menuSubItemFactory;
}
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);
}
get userInfo() {
return this.menuFactory.mainStateManager.userInfo;
}
get isNotAdminUser() {
return !this.userInfo.isAdmin;
}
get isInRole() {
if (!this.userInfo.isAuthenticated()) {
return false;
}
if (this.users instanceof Array && this.isNotAdminUser) {
if (this.userInfo) {
const userCode = this.userInfo.code;
return this.users.includes(userCode);
}
else {
return false;
}
}
return true;
}
get isSystemSelected() {
return this.visible;
// 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.subMenuItems && this.subMenuItems.length ? this.subMenuItems.some(i => i.isSystemSelected) : true)
}
}
exports.MenuItemFactory = MenuItemFactory;