all apparently working and cleaned up

This commit is contained in:
2020-06-10 21:40:05 +00:00
parent 0a43e53ab7
commit 3dd7e05549
9 changed files with 12 additions and 985 deletions

View File

@@ -15,7 +15,6 @@ function addNavItem(title, icon, route, navItems, key, testid) {
}
function initNavPanal() {
console.log("INITIALIZE:initNavPanal TOP");
let key = 0;
let sub = [];
@@ -698,13 +697,9 @@ function initNavPanal() {
//*** LOGOUT - all users
addNavItem(t("Logout"), "fa-sign-out-alt", "/login", [], key++, "logout");
console.log("initialize:INitnavpanel BOTTOM / DONE");
}
function getUserOptions() {
//GET USER OPTIONS
console.log("INITIALIZE:getUserOptions top");
return (
window.$gz.api
.get("user-option/" + window.$gz.store.state.userId)
@@ -765,858 +760,18 @@ function getUserOptions() {
// on change of authentication status
export default function initialize() {
return new Promise(async function(resolve) {
console.log("INITIALIZE:TOP");
// console.log("** authutil calling test delay");
// await window.$gz.api.doDelayAsync();
// console.log("** authutil back from delay continuing..");
if (!window.$gz.store.state.authenticated) {
throw "initialize: Error, called but user not authenticated!";
}
try {
// (async function() {
console.log("INITIALIZE:calling translation.cacheTranslations...");
await window.$gz.translation.cacheTranslations(
window.$gz.translation.coreKeys
);
console.log("INITIALIZE: calling initnavpanel");
await initNavPanal();
console.log("INITIALIZE:calling get user options");
await getUserOptions();
console.log("INITIALIZE:done inside chain");
console.log("INITIALIZE: calling resolve");
resolve();
// })();
} catch (err) {
reject(err);
}
});
}
// //Fetch the core translated text keys that will always be required by user
// window.$gz.translation
// .fetch(window.$gz.translation.coreKeys)
// .then(function initializeNavPanel() {
// let key = 0;
// let sub = [];
// let t = window.$gz.translation.get;
// let role = window.$gz.role.AUTHORIZATION_ROLES;
// //****************** HOME
// //Most users except ops and client logins
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.InventoryLimited,
// role.InventoryFull,
// role.AccountingFull,
// role.TechLimited,
// role.TechFull,
// role.SubContractorLimited,
// role.SubContractorFull,
// role.SalesFull,
// role.SalesLimited
// ])
// ) {
// //DASHBOARD
// sub.push({
// title: t("Dashboard"),
// icon: "fa-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([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.InventoryLimited,
// role.InventoryFull,
// role.AccountingFull,
// role.TechLimited,
// role.TechFull,
// role.SalesFull,
// role.SalesLimited
// ])
// ) {
// sub.push({
// title: t("Search"),
// icon: "fa-search",
// route: "/home-search",
// key: key++
// });
// }
// //SCHEDULE (personal)
// sub.push({
// title: t("Schedule"),
// icon: "fa-calendar-day",
// route: "/home-schedule",
// key: key++
// });
// //MEMOS
// sub.push({
// title: t("MemoList"),
// icon: "fa-inbox",
// route: "/home-memos",
// key: key++
// });
// //REMINDERS (SCHEDULE MARKERS)
// sub.push({
// title: t("ReminderList"),
// icon: "fa-sticky-note",
// route: "/home-reminders",
// key: key++
// });
// //USER SETTINGS
// sub.push({
// title: t("UserSettings"),
// icon: "fa-user-cog",
// route: "/home-user-settings",
// key: key++
// });
// //Moved these two into user settings
// // //USER TRANSLATE
// // sub.push({
// // title: t("Translation"),
// // icon: "fa-language",
// // route: "/home-translation",
// // key: key++
// // });
// // //SET LOGIN
// // sub.push({
// // title: t("SetLoginPassword"),
// // icon: "fa-key",
// // route: "/home-password",
// // key: key++
// // });
// //USER NOTIFICATION SUBSCRIPTIONS
// if (
// //all but subcontractors (arbitrary decision without any facts ;)
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.InventoryLimited,
// role.InventoryFull,
// role.AccountingFull,
// role.TechLimited,
// role.TechFull,
// role.SalesFull,
// role.SalesLimited
// ])
// ) {
// sub.push({
// title: t("NotifySubscriptionList"),
// icon: "fa-bullhorn",
// route: "/home-notify-subscriptions",
// key: key++
// });
// }
// //HOME
// addNavItem(t("Home"), "fa-home", undefined, sub, key++, "home");
// }
// //****************** CUSTOMERS
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited,
// role.AccountingFull,
// role.SalesFull,
// role.SalesLimited
// ])
// ) {
// //clear sublevel array
// sub = [];
// //CUSTOMERS subitem
// sub.push({
// title: t("CustomerList"),
// icon: "fa-address-card",
// route: "/cust-customers",
// key: key++
// });
// //HEAD OFFICES subitem
// sub.push({
// title: t("HeadOfficeList"),
// icon: "fa-sitemap",
// route: "/cust-headoffices",
// key: key++
// });
// // ** CUSTOMER (TOP)
// addNavItem(
// t("CustomerList"),
// "fa-address-book",
// undefined,
// sub,
// key++,
// "customer"
// );
// }
// //****************** SERVICE
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited,
// role.SalesFull,
// role.SalesLimited
// ])
// ) {
// //clear sublevel array
// sub = [];
// //SCHEDULE (combined)
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("Schedule"),
// icon: "fa-calendar-alt",
// route: "/svc-schedule",
// key: key++
// });
// }
// //WORKORDERS LIST (was service workorders)
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("WorkOrderList"),
// icon: "fa-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: t("WorkOrderServiceTemplate"),
// // icon: "fa-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: t("QuoteList"),
// icon: "fa-pencil-alt",
// route: "/svc-quotes",
// key: key++
// });
// //PM LIST
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("PMList"),
// icon: "fa-business-time",
// route: "/svc-pm-list",
// key: key++
// });
// }
// //UNITS subitem
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("UnitList"),
// icon: "fa-fan",
// route: "/svc-units",
// key: key++
// });
// //UNIT MODELS subitem
// sub.push({
// title: t("UnitModels"),
// icon: "fa-dice-d20",
// route: "/svc-unit-models",
// key: key++
// });
// }
// //LOANERS subitem
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("LoanUnitList"),
// icon: "fa-plug",
// route: "/svc-loaners",
// key: key++
// });
// }
// //CONTRACTS subitem
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("ContractList"),
// icon: "fa-file-contract",
// route: "/svc-contracts",
// key: key++
// });
// }
// //CUSTOMER SERVICE REQUESTS subitem
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.DispatchFull,
// role.DispatchLimited,
// role.TechFull,
// role.TechLimited
// ])
// ) {
// sub.push({
// title: t("CustomerServiceRequestList"),
// icon: "fa-child",
// route: "/svc-csr-list",
// key: key++
// });
// }
// //**** Service (TOP GROUP)
// addNavItem(
// t("Service"),
// "fa-toolbox",
// undefined,
// sub,
// key++,
// "service"
// );
// }
// //****************** INVENTORY
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.InventoryFull,
// role.InventoryLimited
// ])
// ) {
// //clear sublevel array
// sub = [];
// //PARTS (part list)
// sub.push({
// title: t("PartList"),
// icon: "fa-boxes",
// route: "/inv-parts",
// key: key++
// });
// //INVENTORY
// sub.push({
// title: t("PartByWarehouseInventoryList"),
// icon: "fa-pallet",
// route: "/inv-part-inventory",
// key: key++
// });
// //PART REQUESTS
// sub.push({
// title: t("WorkOrderItemPartRequestList"),
// icon: "fa-paper-plane",
// route: "/inv-part-requests",
// key: key++
// });
// //PURCHASE ORDERS
// sub.push({
// title: t("InventoryPurchaseOrders"),
// icon: "fa-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: t("InventoryPurchaseOrderReceipts"),
// icon: "fa-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: t("InventoryPartInventoryAdjustments"),
// icon: "fa-dolly",
// route: "/inv-adjustments",
// key: key++
// });
// //**** INVENTORY (TOP GROUP)
// addNavItem(
// t("Inventory"),
// "fa-box",
// undefined,
// sub,
// key++,
// "inventory"
// );
// }
// //**** VENDORS (TOP GROUP)
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.AccountingFull,
// role.DispatchFull,
// role.DispatchLimited,
// role.InventoryFull,
// role.InventoryLimited
// ])
// ) {
// addNavItem(
// t("VendorList"),
// "fa-store",
// "/vendors",
// [],
// key++,
// "vendor"
// );
// }
// //****************** ACCOUNTING
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.AccountingFull,
// role.BizAdminLimited
// ])
// ) {
// sub = [];
// //FAKE subitem as is still TBD
// sub.push({
// title: t("Accounting"),
// icon: "fa-calculator",
// route: "/acc-accounting",
// key: key++
// });
// // ** ACCOUNTING (TOP)
// addNavItem(
// t("Accounting"),
// "fa-calculator",
// undefined,
// sub,
// key++,
// "accounting"
// );
// }
// //****************** ADMINISTRATION
// if (
// window.$gz.role.hasRole([role.BizAdminFull, role.BizAdminLimited])
// ) {
// //clear sublevel array
// sub = [];
// // GLOBAL SETTINGS
// sub.push({
// title: t("AdministrationGlobalSettings"),
// icon: "fa-cogs",
// route: "/adm-global-settings",
// key: key++
// });
// // LICENSE
// sub.push({
// title: t("HelpLicense"),
// icon: "fa-ticket-alt",
// route: "/adm-license",
// key: key++
// });
// // USERS
// sub.push({
// title: t("UserList"),
// icon: "fa-users",
// route: "/adm-users",
// key: key++
// });
// // CUSTOM FIELD DESIGNER NOT REQUIRED, OPENS FROM INDIVIDUAL FORMS
// //TRANSLATION
// sub.push({
// title: t("Translation"),
// icon: "fa-language",
// route: "/adm-translation",
// key: key++
// });
// //REPORT TEMPLATES
// sub.push({
// title: t("ReportList"),
// icon: "fa-th-list",
// route: "/adm-report-templates",
// key: key++
// });
// //FILES IN DATABASE
// sub.push({
// title: t("Attachments"),
// icon: "fa-folder",
// route: "/adm-attachments",
// key: key++
// });
// //EVENT LOG / HISTORY
// sub.push({
// title: t("History"),
// icon: "fa-history",
// route: "/adm-history",
// key: key++
// });
// //KPI / METRICS / CHARTS AND STUFF
// sub.push({
// title: t("Statistics"),
// icon: "fa-chart-line",
// route: "/adm-statistics",
// key: key++
// });
// // ** ADMINISTRATION (TOP)
// addNavItem(
// t("Administration"),
// "fa-user-tie",
// undefined,
// sub,
// key++,
// "administration"
// );
// }
// //****************** OPERATIONS
// if (
// window.$gz.role.hasRole([role.OpsAdminFull, role.OpsAdminLimited])
// ) {
// //clear sublevel array
// sub = [];
// // ARCHIVE
// sub.push({
// title: t("Backup"),
// icon: "fa-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");
// }
// // SERVER STATE
// sub.push({
// title: t("ServerState"),
// icon: "fa-door-open",
// route: "/ops-server-state",
// key: key++
// });
// // JOBS
// sub.push({
// title: t("ServerJobs"),
// icon: "fa-robot",
// route: "/ops-jobs",
// key: key++
// });
// // LOGS
// sub.push({
// title: t("ServerLog"),
// icon: "fa-history",
// route: "/ops-log",
// key: key++
// });
// //METRICS
// sub.push({
// title: t("ServerMetrics"),
// icon: "fa-file-medical-alt",
// route: "/ops-metrics",
// key: key++
// });
// //PROFILE
// sub.push({
// title: t("ServerProfiler"),
// icon: "fa-binoculars",
// route: "/ops-profile",
// key: key++
// });
// //NOTIFICATION CONFIG AND HISTORY
// sub.push({
// title: t("NotificationSettings"),
// icon: "fa-bullhorn",
// route: "/ops-notification-settings",
// key: key++
// });
// // ** OPERATIONS (TOP)
// addNavItem(
// t("Operations"),
// "fa-server",
// undefined,
// sub,
// key++,
// "operations"
// );
// }
// //**** WIDGETS (TOP GROUP)
// if (
// window.$gz.role.hasRole([
// role.BizAdminFull,
// role.BizAdminLimited,
// role.InventoryFull,
// role.InventoryLimited
// ])
// ) {
// addNavItem(
// t("WidgetList"),
// "fa-vial",
// "/widgets",
// [],
// key++,
// "widgets"
// );
// }
// //****************** CUSTOMER USER / HEAD OFFICE USER UI
// if (
// window.$gz.role.hasRole([role.CustomerFull, role.CustomerLimited]) &&
// (window.$gz.store.state.userType == 4 ||
// window.$gz.store.state.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: t("CustomerServiceRequestList"),
// icon: "fa-child",
// route: "/customer-csr-list",
// key: key++
// });
// //WORKORDERS subitem
// sub.push({
// title: t("WorkOrderList"),
// icon: "fa-tools",
// route: "/customer-workorders",
// key: key++
// });
// //** CUSTOMER LOGIN HOME (TOP)
// addNavItem(
// t("Home"),
// "fa-home",
// undefined,
// sub,
// key++,
// "homecustomer"
// );
// }
// //*** LOGOUT - all users
// addNavItem(
// t("Logout"),
// "fa-sign-out-alt",
// "/login",
// [],
// key++,
// "logout"
// );
// console.log("INITIALIZE:Done menu init");
// })
// .then(() => {
// //GET USER OPTIONS
// window.$gz.api
// .get("user-option/" + window.$gz.store.state.userId)
// // eslint-disable-next-line
// .then((res) => {
// if (res.error) {
// //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
// let 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 {
// //Check if overrides and use them here
// //or else use browser defaults
// let l = {
// languageOverride: null,
// timeZoneOverride: null,
// currencyName: null,
// hour12: true
// };
// //get language to use, try user set override first, if empty then browser set, if empty then default to en-us
// l.languageOverride =
// res.data.languageOverride ||
// window.$gz.locale.getBrowserFirstLanguage() ||
// "en-US";
// l.timeZoneOverride =
// res.data.timeZoneOverride ||
// window.$gz.locale.getBrowserTimeZoneName() ||
// "America/New_York";
// //No browser setting for this so meh
// l.currencyName = res.data.currencyName || "USD";
// if (res.data.hour12 != null) {
// l.hour12 = res.data.hour12;
// }
// window.$gz.store.commit("setLocale", l);
// resolve();
// }
// })
// .catch(function handleFetchUserOptionsError(error) {
// window.$gz.store.commit(
// "logItem",
// "Initialize::() fetch useroptions -> error" + error
// );
// throw error;
// });
// })
// .then(() => {
// //GET GLOBAL SETTINGS
// window.$gz.api
// .get("global-biz-setting/client")
// // eslint-disable-next-line
// .then((res) => {
// if (res.error) {
// //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
// let msg = window.$gz.api.apiErrorToHumanString(res.error);
// window.$gz.store.commit(
// "logItem",
// "Initialize::() fetch global-biz-setting/client -> error" + msg
// );
// window.$gz.eventBus.$emit("notify-error", msg);
// } else {
// //Check if overrides and use them here
// //or else use browser defaults
// window.$gz.store.commit("setGlobalSettings", res.data);
// resolve();
// }
// })
// .catch(function handleFetchClientGlobalSettingsError(error) {
// window.$gz.store.commit(
// "logItem",
// "Initialize::() fetch global-biz-setting/client -> error" + error
// );
// throw error;
// });
// })
// .catch(function handleIntializeError(error) {
// window.$gz.store.commit(
// "logItem",
// "Initialize::() ltfetch -> error" + error
// );
// throw error;
// });
// });