This commit is contained in:
2019-07-24 15:15:52 +00:00
parent 565a092251
commit a14e64644d
22 changed files with 132 additions and 93 deletions

View File

@@ -20,7 +20,7 @@ function dealWithError(msg, vm) {
msg;
//eslint-disable-next-line
console.log(errMsg);
window.$gz.eventbus.$emit("notify-error", errMsg);
window.$gz.eventBus.$emit("notify-error", errMsg);
}
//If a form instance was provided (vue instance)

View File

@@ -17,7 +17,7 @@ export default {
///////////
//ERROR
window.$gz.eventbus.$on("notify-error", function handleNotifyWarn(msg) {
window.$gz.eventBus.$on("notify-error", function handleNotifyWarn(msg) {
vm.$dialog.notify.info(msg, {
position: "bottom-right",
icon: "fa-exclamation-triangle",
@@ -27,7 +27,7 @@ export default {
///////////
//WARNING
window.$gz.eventbus.$on("notify-warning", function handleNotifyWarn(msg) {
window.$gz.eventBus.$on("notify-warning", function handleNotifyWarn(msg) {
vm.$dialog.notify.warning(msg, {
position: "bottom-right",
icon: "fa-exclamation",
@@ -37,7 +37,7 @@ export default {
///////////
//INFO
window.$gz.eventbus.$on("notify-info", function handleNotifyWarn(msg) {
window.$gz.eventBus.$on("notify-info", function handleNotifyWarn(msg) {
vm.$dialog.notify.info(msg, {
position: "bottom-right",
icon: "fa-info-circle",
@@ -47,7 +47,7 @@ export default {
///////////
//SUCCESS
window.$gz.eventbus.$on("notify-success", function handleNotifyWarn(msg) {
window.$gz.eventBus.$on("notify-success", function handleNotifyWarn(msg) {
vm.$dialog.notify.success(msg, {
position: "bottom-right",
icon: "fa-check-circle ",

View File

@@ -320,7 +320,7 @@ export default {
//
serverErrors(vm, ref) {
//CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDED DATA ATTRIBUTES ETC
if (window.$gz.window.$gz.errorHandler.devMode()) {
if (window.$gz.errorHandler.devMode()) {
//make sure formState.serverErrors is defined on data
if (!window.$gz._.has(vm, "formState.serverError")) {
throw "DEV ERROR gzform::formState.serverErrors -> formState.serverError seems to be missing from form's vue data object";

View File

@@ -1,5 +1,4 @@
/* XXXeslint-disable */
//import { processLogout } from "./authutil";
/////////////////////////////////
// Menu utils and handlers
@@ -155,7 +154,7 @@ export default {
vm.$router.push({ name: item.data });
break;
default:
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"notify-warning",
"gzmenu:handleAppClick - unrecognized command [" +
menuItem.key +
@@ -189,29 +188,29 @@ export default {
//
wireUpEventHandlers(vm) {
var self = this;
window.$gz.eventbus.$on("menu-change", function handleMenuChange(ctx) {
window.$gz.eventBus.$on("menu-change", function handleMenuChange(ctx) {
self.handleMenuChange(vm, ctx);
});
window.$gz.eventbus.$on("menu-replace-item", function handleReplaceMenuItem(
window.$gz.eventBus.$on("menu-replace-item", function handleReplaceMenuItem(
newItem
) {
self.handleReplaceMenuItem(vm, newItem);
});
window.$gz.eventbus.$on("menu-disable-item", function handleDisableMenuItem(
window.$gz.eventBus.$on("menu-disable-item", function handleDisableMenuItem(
key
) {
self.handleDisableMenuItem(vm, key, true);
});
window.$gz.eventbus.$on("menu-enable-item", function handleDisableMenuItem(
window.$gz.eventBus.$on("menu-enable-item", function handleDisableMenuItem(
key
) {
self.handleDisableMenuItem(vm, key, false);
});
window.$gz.eventbus.$on("menu-click", function handleMenuClick(menuitem) {
window.$gz.eventBus.$on("menu-click", function handleMenuClick(menuitem) {
self.handleAppClick(vm, menuitem);
});
}

View File

@@ -1,7 +1,5 @@
/* Xeslint-disable */
import _ from "../libs/lodash.min.js";
/////////////////////////////////
// General utility library
//
@@ -78,7 +76,7 @@ export default {
//
normalizeTag: function(tagName) {
//kebab case takes care of all the things we need for tags in one go
tagName = _.kebabCase(tagName);
tagName = window.$gz._.kebabCase(tagName);
//No longer than 255 characters
tagName = tagName.length > 255 ? tagName.substr(0, 255 - 1) : tagName;

View File

@@ -1,12 +1,7 @@
/* xeslint-disable */
import store from "../store";
import roles from "./authorizationroles";
import locale from "./locale";
import api from "./gzapi";
import gzevent from "./eventbus";
function addNavItem(title, icon, route) {
store.commit("addNavItem", {
window.$gz.store.commit("addNavItem", {
title,
icon,
route
@@ -18,83 +13,127 @@ function addNavItem(title, icon, route) {
// on change of authentication status
export default function initialize() {
var promise = new Promise(function(resolve) {
if (store.state.authenticated) {
if (window.$gz.store.state.authenticated) {
//Fetch the core localized text keys that will always be required by user
locale
.fetch(locale.coreKeys)
window.$gz.locale
.fetch(window.$gz.locale.coreKeys)
.then(function putFetchedNavItemsInStore() {
//put nav items into store
//Everyone has a home
addNavItem(locale.get("Home"), "home", "/");
addNavItem(window.$gz.locale.get("Home"), "home", "/");
//NOTE: If a user has read full record or better then they should have access to that area
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.TechLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.TechFull) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.SubContractorLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.SubContractorFull)
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(locale.get("Service"), "toolbox", "/service");
addNavItem(window.$gz.locale.get("Service"), "toolbox", "/service");
}
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.DispatchLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.DispatchFull)
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.DispatchLimited
) ||
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.DispatchFull
)
) {
addNavItem(locale.get("Dispatch"), "shipping-fast", "/dispatch");
}
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryFull) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminFull)
) {
addNavItem(locale.get("Inventory"), "dolly", "/inventory");
}
if (roles.hasRole(roles.AUTHORIZATION_ROLES.AccountingFull)) {
addNavItem(
locale.get("Accounting"),
window.$gz.locale.get("Dispatch"),
"shipping-fast",
"/dispatch"
);
}
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"
);
}
if (
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.AccountingFull
)
) {
addNavItem(
window.$gz.locale.get("Accounting"),
"file-invoice-dollar",
"/accounting"
);
}
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminFull)
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited
) ||
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull
)
) {
addNavItem(locale.get("Administration"), "user-tie", "/admin");
addNavItem(
window.$gz.locale.get("Administration"),
"user-tie",
"/admin"
);
}
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.OpsAdminFull) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.OpsAdminLimited)
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.OpsAdminFull
) ||
window.$gz.role.hasRole(
window.$gz.role.AUTHORIZATION_ROLES.OpsAdminLimited
)
) {
addNavItem(locale.get("Operations"), "cogs", "ops");
addNavItem(window.$gz.locale.get("Operations"), "cogs", "ops");
}
//MOVED TO MENU OUT OF NAV
//Everyone can see about and logout
// addNavItem(locale.get("HelpAboutAyaNova"), "info-circle", "/about");
// addNavItem(locale.get("Logout"), "sign-out-alt", "/login");
// addNavItem(window.$gz.locale.get("HelpAboutAyaNova"), "info-circle", "/about");
// addNavItem(window.$gz.locale.get("Logout"), "sign-out-alt", "/login");
})
.then(() => {
//CACHE LOCALE SETTINGS
api
.get("UserOptions/" + store.state.userId)
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 = api.apiErrorToHumanString(res.error);
store.commit(
var msg = window.$gz.api.apiErrorToHumanString(res.error);
window.$gz.store.commit(
"logItem",
"Initialize::() fetch useroptions -> error" + msg
);
gzevent.$emit("notify-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();
@@ -107,7 +146,7 @@ export default function initialize() {
//so this should be a confirm prompt but for now will just show it
//for now just show the message
gzevent.$emit(
window.$gz.eventBus.$emit(
"notify-info",
"Time zone offset for this account is set to " +
res.data.timeZoneOffset +
@@ -119,7 +158,7 @@ export default function initialize() {
//Store offset in locale data
//TODO: also need the other locale settings such as number and date formats etc to be added at server
store.commit("setLocale", {
window.$gz.store.commit("setLocale", {
decimalSeparator: ".",
currencySymbol: "$",
shortDate: "YYYY-MM-DD",
@@ -132,7 +171,7 @@ export default function initialize() {
}
})
.catch(function handleFetchUserOptionsError(error) {
store.commit(
window.$gz.store.commit(
"logItem",
"Initialize::() fetch useroptions -> error" + error
);
@@ -140,7 +179,10 @@ export default function initialize() {
});
})
.catch(function handleIntializeError(error) {
store.commit("logItem", "Initialize::() ltfetch -> error" + error);
window.$gz.store.commit(
"logItem",
"Initialize::() ltfetch -> error" + error
);
throw error;
});
}