/* Xeslint-disable */ function addNavItem(title, icon, route, navItems, key) { window.$gz.store.commit("addNavItem", { title, icon, route, navItems, key: key }); } ///////////////////////////////////// // Initialize the app // on change of authentication status export default function initialize() { var promise = new Promise(function(resolve) { if (window.$gz.store.state.authenticated) { //Fetch the core localized text keys that will always be required by user window.$gz.locale .fetch(window.$gz.locale.coreKeys) .then(function initializeNavPanel() { // console.log("INIT NAV PANEL"); var key = 0; var sub = []; //****************** HOME //Most users except ops and client logins if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryFull, window.$gz.role.AUTHORIZATION_ROLES.AccountingFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.SubContractorLimited, window.$gz.role.AUTHORIZATION_ROLES.SubContractorFull, window.$gz.role.AUTHORIZATION_ROLES.SalesFull, window.$gz.role.AUTHORIZATION_ROLES.SalesLimited ]) ) { //DASHBOARD sub.push({ title: window.$gz.locale.get("Dashboard"), icon: "tachometer-alt", route: "/home-dashboard", key: key++ }); //Set homePage in store to dashboard window.$gz.store.commit("setHomePage", "/home-dashboard"); //SEARCH if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryFull, window.$gz.role.AUTHORIZATION_ROLES.AccountingFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.SalesFull, window.$gz.role.AUTHORIZATION_ROLES.SalesLimited ]) ) { sub.push({ title: window.$gz.locale.get("Search"), icon: "search", route: "/home-search", key: key++ }); } //SCHEDULE (personal) sub.push({ title: window.$gz.locale.get("Schedule"), icon: "calendar-day", route: "/home-schedule", key: key++ }); //MEMOS sub.push({ title: window.$gz.locale.get("MemoList"), icon: "inbox", route: "/home-memos", key: key++ }); //REMINDERS (SCHEDULE MARKERS) sub.push({ title: window.$gz.locale.get("ReminderList"), icon: "sticky-note", route: "/home-reminders", key: key++ }); //USER SETTINGS sub.push({ title: window.$gz.locale.get("UserSettings"), icon: "user-cog", route: "/home-user-settings", key: key++ }); //Moved these two into user settings // //USER LOCALE // sub.push({ // title: window.$gz.locale.get("Locale"), // icon: "language", // route: "/home-locale", // key: key++ // }); // //SET LOGIN // sub.push({ // title: window.$gz.locale.get("SetLoginPassword"), // icon: "key", // route: "/home-password", // key: key++ // }); //USER NOTIFICATION SUBSCRIPTIONS if ( //all but subcontractors (arbitrary decision without any facts ;) window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryFull, window.$gz.role.AUTHORIZATION_ROLES.AccountingFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.SalesFull, window.$gz.role.AUTHORIZATION_ROLES.SalesLimited ]) ) { sub.push({ title: window.$gz.locale.get("NotifySubscriptionList"), icon: "bullhorn", route: "/home-notify-subscriptions", key: key++ }); } //HOME addNavItem( window.$gz.locale.get("Home"), "home", undefined, sub, key++ ); } //****************** CUSTOMERS if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited, window.$gz.role.AUTHORIZATION_ROLES.AccountingFull, window.$gz.role.AUTHORIZATION_ROLES.SalesFull, window.$gz.role.AUTHORIZATION_ROLES.SalesLimited ]) ) { //clear sublevel array sub = []; //CUSTOMERS subitem sub.push({ title: window.$gz.locale.get("ClientList"), icon: "address-card", route: "/cust-customers", key: key++ }); //HEAD OFFICES subitem sub.push({ title: window.$gz.locale.get("HeadOfficeList"), icon: "sitemap", route: "/cust-headoffices", key: key++ }); // ** CUSTOMER (TOP) addNavItem( window.$gz.locale.get("ClientList"), "address-book", undefined, sub, key++ ); } //****************** SERVICE if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited, window.$gz.role.AUTHORIZATION_ROLES.SalesFull, window.$gz.role.AUTHORIZATION_ROLES.SalesLimited ]) ) { //clear sublevel array sub = []; //SCHEDULE (combined) if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get("Schedule"), icon: "calendar-alt", route: "/svc-schedule", key: key++ }); } //WORKORDERS LIST (was service workorders) if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get("WorkorderServiceList"), icon: "tools", route: "/svc-workorders", key: key++ }); } // //WORKORDER TEMPLATES LIST //this will be an item inside the workorders NEW menu or grid or wherever but it's not top level worthy //there used to be an array for 3rd level shit but that's whack yo! ;) // subSub.push({ // title: window.$gz.locale.get("WorkorderServiceTemplate"), // icon: "stamp", // route: "/svc-workorder-templates", // key: key++ // }); //QUOTE LIST //NOTE: this is the only item in this service level area that is visible to Sales //so there is no separate role check here as the service group role check supersedes this sub.push({ title: window.$gz.locale.get("WorkorderQuoteList"), icon: "edit", route: "/svc-quotes", key: key++ }); //PM LIST if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get( "WorkorderPreventiveMaintenanceList" ), icon: "business-time", route: "/svc-pm-list", key: key++ }); } //UNITS subitem if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get("UnitList"), icon: "fan", route: "/svc-units", key: key++ }); //UNIT MODELS subitem sub.push({ title: window.$gz.locale.get("UnitModels"), icon: "dice-d20", route: "/svc-unit-models", key: key++ }); } //LOANERS subitem if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get("LoanItemList"), icon: "plug", route: "/svc-loaners", key: key++ }); } //CONTRACTS subitem if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get("ContractList"), icon: "file-contract", route: "/svc-contracts", key: key++ }); } //CUSTOMER SERVICE REQUESTS subitem if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { sub.push({ title: window.$gz.locale.get("ClientServiceRequestList"), icon: "child", route: "/svc-csr-list", key: key++ }); } //**** Service (TOP GROUP) addNavItem( window.$gz.locale.get("Service"), "toolbox", undefined, sub, key++ ); } //****************** INVENTORY if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryFull, window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited ]) ) { //clear sublevel array sub = []; //PARTS (part list) sub.push({ title: window.$gz.locale.get("PartList"), icon: "boxes", route: "/inv-parts", key: key++ }); //INVENTORY sub.push({ title: window.$gz.locale.get("PartByWarehouseInventoryList"), icon: "pallet", route: "/inv-part-inventory", key: key++ }); //PART REQUESTS sub.push({ title: window.$gz.locale.get("WorkorderItemPartRequestList"), icon: "paper-plane", route: "/inv-part-requests", key: key++ }); //PURCHASE ORDERS sub.push({ title: window.$gz.locale.get("InventoryPurchaseOrders"), icon: "shipping-fast", route: "/inv-purchase-orders", key: key++ }); //NOTE: V7 HAD POITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE //PURCHASE ORDER RECEIPTS sub.push({ title: window.$gz.locale.get("InventoryPurchaseOrderReceipts"), icon: "dolly-flatbed", route: "/inv-purchase-order-receipts", key: key++ }); //NOTE: V7 HAD PORECEIPTITEMS, THAT MAY BE AN ANACHRONISM NOW SO NOT PUTTING HERE //NOTE: Warehouses? Shouldn't they be here as well?? //ADJUSTMENTS sub.push({ title: window.$gz.locale.get("InventoryPartInventoryAdjustments"), icon: "dolly", route: "/inv-adjustments", key: key++ }); //**** INVENTORY (TOP GROUP) addNavItem( window.$gz.locale.get("Inventory"), "box", undefined, sub, key++ ); } //**** VENDORS (TOP GROUP) if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.AccountingFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.InventoryFull, window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited ]) ) { addNavItem( window.$gz.locale.get("VendorList"), "store", "/vendors", [], key++ ); } //****************** ACCOUNTING if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.AccountingFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited ]) ) { sub = []; //FAKE subitem as is still TBD sub.push({ title: window.$gz.locale.get("Accounting"), icon: "calculator", route: "/acc-accounting", key: key++ }); // ** ACCOUNTING (TOP) addNavItem( window.$gz.locale.get("Accounting"), "calculator", undefined, sub, key++ ); } //****************** ADMINISTRATION if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited ]) ) { //clear sublevel array sub = []; // GLOBAL SETTINGS sub.push({ title: window.$gz.locale.get("AdministrationGlobalSettings"), icon: "cogs", route: "/adm-global-settings", key: key++ }); // LICENSE sub.push({ title: window.$gz.locale.get("HelpLicense"), icon: "ticket-alt", route: "/adm-license", key: key++ }); // USERS sub.push({ title: window.$gz.locale.get("UserList"), icon: "users", route: "/adm-users", key: key++ }); // CUSTOM FIELD DESIGNER NOT REQUIRED, OPENS FROM INDIVIDUAL FORMS //LOCALIZED TEXT DESIGNER sub.push({ title: window.$gz.locale.get("LocalizedTextDesign"), icon: "language", route: "/adm-localized-text", key: key++ }); //REPORT TEMPLATES sub.push({ title: window.$gz.locale.get("ReportList"), icon: "th-list", route: "/adm-report-templates", key: key++ }); //FILES IN DATABASE sub.push({ title: window.$gz.locale.get("Attachments"), icon: "folder", route: "/adm-attachments", key: key++ }); //EVENT LOG / HISTORY sub.push({ title: window.$gz.locale.get("History"), icon: "history", route: "/adm-history", key: key++ }); //KPI / METRICS / CHARTS AND STUFF sub.push({ title: window.$gz.locale.get("Statistics"), icon: "chart-line", route: "/adm-statistics", key: key++ }); // ** ADMINISTRATION (TOP) addNavItem( window.$gz.locale.get("Administration"), "user-tie", undefined, sub, key++ ); } //****************** OPERATIONS if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.OpsAdminFull, window.$gz.role.AUTHORIZATION_ROLES.OpsAdminLimited ]) ) { //clear sublevel array sub = []; // ARCHIVE sub.push({ title: window.$gz.locale.get("Backup"), icon: "file-archive", route: "/ops-backup", key: key++ }); //Set home page if they don't already have the dashboard set above if (!window.$gz.store.state.homePage) { //Set homePage in store to Backup window.$gz.store.commit("setHomePage", "/ops-BACKUP"); } // JOBS sub.push({ title: window.$gz.locale.get("ServerJobs"), icon: "robot", route: "/ops-jobs", key: key++ }); // LOGS sub.push({ title: window.$gz.locale.get("ServerLog"), icon: "history", route: "/ops-log", key: key++ }); //METRICS sub.push({ title: window.$gz.locale.get("ServerMetrics"), icon: "file-medical-alt", route: "/ops-metrics", key: key++ }); //NOTIFICATION CONFIG AND HISTORY sub.push({ title: window.$gz.locale.get("NotificationSettings"), icon: "bullhorn", route: "/ops-notification-settings", key: key++ }); // ** OPERATIONS (TOP) addNavItem( window.$gz.locale.get("Operations"), "server", undefined, sub, key++ ); } //**** WIDGETS (TOP GROUP) if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited, window.$gz.role.AUTHORIZATION_ROLES.DispatchFull, window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited, window.$gz.role.AUTHORIZATION_ROLES.TechFull, window.$gz.role.AUTHORIZATION_ROLES.TechLimited ]) ) { addNavItem( window.$gz.locale.get("WidgetList"), "vial", "/test-widgets", [], key++ ); } //****************** CUSTOMER USER / HEAD OFFICE USER UI if ( window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.CustomerFull, window.$gz.role.AUTHORIZATION_ROLES.CustomerLimited ]) && (window.$gz.store.userType == 4 || window.$gz.store.userType == 5) ) { //clear sublevel array sub = []; //Set homePage in store to customer csr for this user type window.$gz.store.commit("setHomePage", "/customer-csr-list"); //CSR LIST subitem sub.push({ title: window.$gz.locale.get("ClientServiceRequestList"), icon: "child", route: "/customer-csr-list", key: key++ }); //WORKORDERS subitem sub.push({ title: window.$gz.locale.get("WorkorderServiceList"), icon: "tools", route: "/customer-workorders", key: key++ }); //** CUSTOMER LOGIN HOME (TOP) addNavItem( window.$gz.locale.get("Home"), "home", undefined, sub, key++ ); } }) .then(() => { //console.log("INIT FETCH USEROPTIONS AND CACHE"); //CACHE LOCALE SETTINGS window.$gz.api .get("UserOptions/" + window.$gz.store.state.userId) .then(res => { if (res.error != undefined) { //In a form this would trigger a bunch of validation or error display code but for here and now: //convert error to human readable string for display and popup a notification to user var msg = window.$gz.api.apiErrorToHumanString(res.error); window.$gz.store.commit( "logItem", "Initialize::() fetch useroptions -> error" + msg ); window.$gz.eventBus.$emit("notify-error", msg); } else { window.$gz.store.commit("setLocale", { languageOverride: "en-US", timeZoneOverride: "America/New_York", currencyName: "USD", hour12: true }); resolve(); } }) .catch(function handleFetchUserOptionsError(error) { window.$gz.store.commit( "logItem", "Initialize::() fetch useroptions -> error" + error ); throw error; }); }) .catch(function handleIntializeError(error) { window.$gz.store.commit( "logItem", "Initialize::() ltfetch -> error" + error ); throw error; }); } }); return promise; }