718 lines
21 KiB
JavaScript
718 lines
21 KiB
JavaScript
/* 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 putFetchedNavItemsInStore() {
|
|
//put nav items into store
|
|
var key = 0;
|
|
var sub = [];
|
|
var subSub = [];
|
|
|
|
//****************** HOME
|
|
|
|
//Everyone has a home
|
|
|
|
//create array of sub items under the home menu item
|
|
|
|
//DASHBOARD
|
|
sub.push({
|
|
title: window.$gz.locale.get("DashboardDashboard"),
|
|
icon: "tachometer-alt",
|
|
route: "/home-dashboard",
|
|
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("ScheduleMarkerList"),
|
|
icon: "sticky-note",
|
|
route: "/home-reminders",
|
|
key: key++
|
|
});
|
|
|
|
//3rd level items under preferences
|
|
|
|
//LOCALE
|
|
subSub.push({
|
|
title: window.$gz.locale.get("Locale"),
|
|
icon: "language",
|
|
route: "/home-locale",
|
|
key: key++
|
|
});
|
|
|
|
//SET LOGIN
|
|
subSub.push({
|
|
title: window.$gz.locale.get("SetLoginPassword"),
|
|
icon: "key",
|
|
route: "/home-password",
|
|
key: key++
|
|
});
|
|
|
|
//NOTIFICATION SUBSCRIPTIONS
|
|
subSub.push({
|
|
title: window.$gz.locale.get("NotifySubscriptionList"),
|
|
icon: "bullhorn",
|
|
route: "/home-notify-subscriptions",
|
|
key: key++
|
|
});
|
|
|
|
//USER PREFERENCES (personal)
|
|
sub.push({
|
|
title: window.$gz.locale.get("UserPreferences"),
|
|
icon: "user-cog",
|
|
route: undefined,
|
|
navItems: subSub,
|
|
key: key++
|
|
});
|
|
|
|
//HOME
|
|
addNavItem(
|
|
window.$gz.locale.get("Home"),
|
|
"home",
|
|
undefined,
|
|
sub,
|
|
key++
|
|
);
|
|
|
|
//****************** CUSTOMERS
|
|
//clear sublevel arrays
|
|
subSub = [];
|
|
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
|
|
//clear sublevel arrays
|
|
subSub = [];
|
|
sub = [];
|
|
|
|
//SCHEDULE (combined)
|
|
sub.push({
|
|
title: window.$gz.locale.get("Schedule"),
|
|
icon: "calendar-alt",
|
|
route: "/svc-schedule",
|
|
key: key++
|
|
});
|
|
|
|
|
|
//WORKORDERS LIST (was service workorders)
|
|
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
|
|
// subSub.push({
|
|
// title: window.$gz.locale.get("WorkorderServiceTemplate"),
|
|
// icon: "stamp",
|
|
// route: "/svc-workorder-templates",
|
|
// key: key++
|
|
// });
|
|
|
|
// //WORKORDERS GROUP
|
|
// sub.push({
|
|
// title: window.$gz.locale.get("WorkorderServiceList"),
|
|
// icon: "tools",
|
|
// route: undefined,
|
|
// navItems: subSub,
|
|
// key: key++
|
|
// });
|
|
|
|
|
|
//QUOTE LIST
|
|
sub.push({
|
|
title: window.$gz.locale.get("WorkorderQuoteList"),
|
|
icon: "edit",
|
|
route: "/svc-quotes",
|
|
key: key++
|
|
});
|
|
|
|
// //QUOTE TEMPLATES LIST
|
|
// subSub.push({
|
|
// title: window.$gz.locale.get("WorkorderQuoteTemplate"),
|
|
// icon: "stamp",
|
|
// route: "/svc-quote-templates",
|
|
// key: key++
|
|
// });
|
|
|
|
// //QUOTE GROUP
|
|
// sub.push({
|
|
// title: window.$gz.locale.get("WorkorderQuoteList"),
|
|
// icon: "edit",
|
|
// route: undefined,
|
|
// navItems: subSub,
|
|
// key: key++
|
|
// });
|
|
|
|
//PM GROUP SUBITEMS
|
|
//subSub = [];
|
|
//PM LIST
|
|
sub.push({
|
|
title: window.$gz.locale.get("WorkorderPreventiveMaintenanceList"),
|
|
icon: "business-time",
|
|
route: "/svc-pm-list",
|
|
key: key++
|
|
});
|
|
|
|
// //PM TEMPLATES LIST
|
|
// subSub.push({
|
|
// title: window.$gz.locale.get(
|
|
// "WorkorderPreventiveMaintenanceTemplate"
|
|
// ),
|
|
// icon: "stamp",
|
|
// route: "/svc-pm-templates",
|
|
// key: key++
|
|
// });
|
|
|
|
// //PM GROUP
|
|
// sub.push({
|
|
// title: window.$gz.locale.get("WorkorderPreventiveMaintenanceList"),
|
|
// icon: "business-time",
|
|
// route: undefined,
|
|
// navItems: subSub,
|
|
// key: key++
|
|
// });
|
|
|
|
//UNITS subitem
|
|
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
|
|
sub.push({
|
|
title: window.$gz.locale.get("LoanItemList"),
|
|
icon: "plug",
|
|
route: "/svc-loaners",
|
|
key: key++
|
|
});
|
|
|
|
//CONTRACTS subitem
|
|
sub.push({
|
|
title: window.$gz.locale.get("ContractList"),
|
|
icon: "file-contract",
|
|
route: "/svc-contracts",
|
|
key: key++
|
|
});
|
|
|
|
//CUSTOMER SERVICE REQUESTS subitem
|
|
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
|
|
//clear sublevel arrays
|
|
subSub = [];
|
|
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
|
|
|
|
//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)
|
|
addNavItem(
|
|
window.$gz.locale.get("VendorList"),
|
|
"store",
|
|
"/vendors",
|
|
[],
|
|
key++
|
|
);
|
|
|
|
//****************** ACCOUNTING
|
|
//clear sublevel arrays
|
|
subSub = [];
|
|
sub = [];
|
|
|
|
//FAKE subitem as is still TBD
|
|
sub.push({
|
|
title: window.$gz.locale.get("Accounting"),
|
|
icon: "calculator",
|
|
route: "/acc-accounting",
|
|
key: key++
|
|
});
|
|
|
|
// ** CUSTOMER (TOP)
|
|
addNavItem(
|
|
window.$gz.locale.get("Accounting"),
|
|
"calculator",
|
|
undefined,
|
|
sub,
|
|
key++
|
|
);
|
|
|
|
//****************** ADMINISTRATION
|
|
//clear sublevel arrays
|
|
subSub = [];
|
|
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
|
|
//clear sublevel arrays
|
|
subSub = [];
|
|
sub = [];
|
|
|
|
// ARCHIVE
|
|
sub.push({
|
|
title: window.$gz.locale.get("Backup"),
|
|
icon: "file-archive",
|
|
route: "/ops-backup",
|
|
key: key++
|
|
});
|
|
|
|
// 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)
|
|
addNavItem(
|
|
window.$gz.locale.get("WidgetList"),
|
|
"splotch",
|
|
"/testinventory",
|
|
[],
|
|
key++
|
|
);
|
|
|
|
//NOTE: If a user has read full record or better then they should have access to that area
|
|
|
|
// if (
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.TechLimited
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.TechFull
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.SubContractorLimited
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.SubContractorFull
|
|
// )
|
|
// ) {
|
|
// addNavItem(
|
|
// window.$gz.locale.get("Service"),
|
|
// "toolbox",
|
|
// "/service",
|
|
// undefined,
|
|
// key++
|
|
// );
|
|
// }
|
|
|
|
// if (
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.DispatchFull
|
|
// )
|
|
// ) {
|
|
// addNavItem(
|
|
// window.$gz.locale.get("Dispatch"),
|
|
// "shipping-fast",
|
|
// "/dispatch",
|
|
// undefined,
|
|
// key++
|
|
// );
|
|
// }
|
|
|
|
// if (
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.InventoryLimited
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.InventoryFull
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull
|
|
// )
|
|
// ) {
|
|
// addNavItem(
|
|
// window.$gz.locale.get("Inventory"),
|
|
// "dolly",
|
|
// "/inventory",
|
|
// undefined,
|
|
// key++
|
|
// );
|
|
// }
|
|
|
|
// if (
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.AccountingFull
|
|
// )
|
|
// ) {
|
|
// addNavItem(
|
|
// window.$gz.locale.get("Accounting"),
|
|
// "file-invoice-dollar",
|
|
// "/accounting",
|
|
// undefined,
|
|
// key++
|
|
// );
|
|
// }
|
|
|
|
// if (
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull
|
|
// )
|
|
// ) {
|
|
// addNavItem(
|
|
// window.$gz.locale.get("Administration"),
|
|
// "user-tie",
|
|
// "/admin",
|
|
// undefined,
|
|
// key++
|
|
// );
|
|
// }
|
|
|
|
// if (
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.OpsAdminFull
|
|
// ) ||
|
|
// window.$gz.role.hasRole(
|
|
// window.$gz.role.AUTHORIZATION_ROLES.OpsAdminLimited
|
|
// )
|
|
// ) {
|
|
// addNavItem(
|
|
// window.$gz.locale.get("Operations"),
|
|
// "cogs",
|
|
// "ops",
|
|
// undefined,
|
|
// key++
|
|
// );
|
|
// }
|
|
|
|
// console.log(window.$gz.store.state.navItems);
|
|
})
|
|
.then(() => {
|
|
//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 {
|
|
//TODO: also need the other locale settings such as number and date formats etc
|
|
var localOffset = new Date().getTimezoneOffset();
|
|
if (localOffset != 0) {
|
|
localOffset = (localOffset / 60) * -1; //time is in minutes and reversed from what we want or expect
|
|
}
|
|
|
|
if (res.data.timeZoneOffset != localOffset) {
|
|
//TODO: localize message and also actually have a fix for it here
|
|
//so this should be a confirm prompt but for now will just show it
|
|
|
|
//for now just show the message
|
|
window.$gz.eventBus.$emit(
|
|
"notify-info",
|
|
"Time zone offset for your account is set to " +
|
|
res.data.timeZoneOffset +
|
|
" which doesn't match the local timezone offset of " +
|
|
localOffset,
|
|
window.$gz.store.state.helpUrl + "intro/#searching"
|
|
);
|
|
}
|
|
|
|
// window.$gz.eventBus.$emit("notify-success", "Success");
|
|
// window.$gz.eventBus.$emit(
|
|
// "notify-warning",
|
|
// "This is a very long warning, it has a lot of text and goes on and on and on. Hard to understand why anyone would do it this way but whatever right?@!"
|
|
// );
|
|
// window.$gz.eventBus.$emit(
|
|
// "notify-error",
|
|
// "This is a medium error"
|
|
// );
|
|
|
|
//Store offset in locale data
|
|
//TODO: also need the other locale settings such as number and date formats etc to be added at server
|
|
window.$gz.store.commit("setLocale", {
|
|
decimalSeparator: ".",
|
|
currencySymbol: "$",
|
|
shortDate: "YYYY-MM-DD",
|
|
shortTime: "hh:mm:ss A",
|
|
shortDateAndTime: "YYYY-MM-DD hh:mm:ss A",
|
|
timeZoneOffset: res.data.timeZoneOffset
|
|
});
|
|
|
|
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;
|
|
}
|