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

@@ -141,7 +141,7 @@ export default {
},
beforeDestroy() {
//UNWIRE ALL EVENT HANDLERS FROM GZEVENTBUS
window.$gz.eventbus.$off();
window.$gz.eventBus.$off();
},
mounted() {
//redirect to login if not authenticated
@@ -174,7 +174,7 @@ export default {
this.$root.$emit("triggerScroll");
},
clickMenuItem(item) {
window.$gz.eventbus.$emit("menu-click", item);
window.$gz.eventBus.$emit("menu-click", item);
}
}
};

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;
});
}

View File

@@ -207,7 +207,7 @@ export default {
});
},
filterMe() {
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"notify-info",
"inventoryWidgetList::filterMe -> STUB (selected items count=" +
this.selected.length +

View File

@@ -26,7 +26,7 @@ import gzapi from "./api/gzapi";
import gzreport from "./api/gzreport";
import gzform from "./api/gzform";
import gzformcustomtemplate from "./api/form-custom-template";
import roles from "./api/authorizationroles";
import authorizationroles from "./api/authorizationroles";
import gztype from "./api/ayatype";
import "@/assets/css/main.css";
@@ -47,8 +47,8 @@ window.$gz = {
locale: locale,
formCustomTemplate: gzformcustomtemplate,
type: gztype,
role: roles,
eventbus: gzeventbus,
role: authorizationroles,
eventBus: gzeventbus,
menu: gzmenu,
dialog: gzdialog,
util: gzutil,

View File

@@ -161,7 +161,7 @@ function clickHandler(menuItem) {
window.$gz.util.copyToClipboard(text + "\nCLIENT LOG\n" + logText);
break;
default:
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"notify-warning",
"About.vue::context click: [" + m.key + "]"
);
@@ -202,7 +202,7 @@ export default {
.then(function() {
vm.formState.ready = true;
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: false,
icon: "fa-info-circle",
title: window.$gz.locale.get("HelpAboutAyaNova"),
@@ -223,7 +223,7 @@ export default {
}
]
});
window.$gz.eventbus.$on("menu-click", clickHandler);
window.$gz.eventBus.$on("menu-click", clickHandler);
})
.catch(err => {
vm.formState.ready = true;

View File

@@ -10,7 +10,7 @@ export default {
HelloWorld
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-home",
title: window.$gz.locale.get("Home")

View File

@@ -10,7 +10,7 @@ export default {
UnderConstruction
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-file-invoice-dollar",
title: window.$gz.locale.get("Accounting")

View File

@@ -10,7 +10,7 @@ export default {
UnderConstruction
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-user-tie",
title: window.$gz.locale.get("Administration")

View File

@@ -10,7 +10,7 @@ export default {
UnderConstruction
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "sliders-h",
title: window.$gz.locale.get("Customize")

View File

@@ -10,7 +10,7 @@ export default {
UnderConstruction
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-shipping-fast",
title: window.$gz.locale.get("Dispatch")

View File

@@ -260,7 +260,7 @@ export default {
created() {
this.rights = window.$gz.role.getRights(window.$gz.type.Widget);
window.$gz.eventbus.$on("menu-click", clickHandler);
window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one
if (this.$route.params.id != 0) {
this.getDataFromApi(this.$route.params.id);
@@ -307,7 +307,7 @@ export default {
}
},
beforeDestroy() {
window.$gz.eventbus.$off("menu-click", clickHandler);
window.$gz.eventBus.$off("menu-click", clickHandler);
},
components: {},
data() {
@@ -356,20 +356,20 @@ export default {
//enable / disable save button
var canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) {
window.$gz.eventbus.$emit("menu-enable-item", FORM_KEY + ":save");
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
window.$gz.eventbus.$emit("menu-disable-item", FORM_KEY + ":save");
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
}
//enable / disable duplicate button
var canDuplicate = !val.dirty && val.valid && !val.readOnly;
if (canDuplicate) {
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":duplicate"
);
} else {
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"menu-disable-item",
FORM_KEY + ":duplicate"
);
@@ -598,7 +598,7 @@ function clickHandler(menuItem) {
.getReportChoice(m.vm, reportList, selectedItem)
.then(res => {
if (res) {
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"notify-success",
FORM_KEY + "::report click, selected is: [" + res + "]"
);
@@ -607,7 +607,7 @@ function clickHandler(menuItem) {
break;
default:
window.$gz.eventbus.$emit(
window.$gz.eventBus.$emit(
"notify-warning",
FORM_KEY + "::context click: [" + m.key + "]"
);
@@ -666,7 +666,7 @@ function generateMenu(vm) {
vm: vm
});
window.$gz.eventbus.$emit("menu-change", menuOptions);
window.$gz.eventBus.$emit("menu-change", menuOptions);
}
var JUST_DELETED = false;

View File

@@ -60,7 +60,7 @@ export default {
});
},
created() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-dolly",
title: window.$gz.locale.get("Inventory")

View File

@@ -23,7 +23,7 @@
/* Xeslint-disable */
export default {
created() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: false,
icon: "fa-info-circle",
title: window.$gz.locale.get("Log"),

View File

@@ -73,7 +73,7 @@ export default {
};
},
created() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "",
title: ""

View File

@@ -16,7 +16,7 @@
<script>
export default {
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-dragon",
title: "404 - " + window.$gz.locale.get("ErrorAPI2010")

View File

@@ -10,7 +10,7 @@ export default {
UnderConstruction
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-cogs",
title: window.$gz.locale.get("Operations")

View File

@@ -10,7 +10,7 @@ export default {
UnderConstruction
},
beforeCreate() {
window.$gz.eventbus.$emit("menu-change", {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-toolbox",
title: window.$gz.locale.get("Service")