This commit is contained in:
2019-04-23 19:32:21 +00:00
parent b25a5834bf
commit 3cc5cd53a4
4 changed files with 121 additions and 83 deletions

View File

@@ -10,21 +10,21 @@ export default {
//
// Deal with a menu change request
// called from App.vue
handleMenuChange(that, ctx) {
that.appBar.isMain = ctx.isMain;
that.appBar.icon = ctx.icon;
that.appBar.title = ctx.title;
handleMenuChange(vm, ctx) {
vm.appBar.isMain = ctx.isMain;
vm.appBar.icon = ctx.icon;
vm.appBar.title = ctx.title;
//set the help url if presented or default to the top of the index
that.appBar.helpUrl = ctx.helpUrl ? ctx.helpUrl : "index.html";
that.appBar.menuItems = [];
vm.appBar.helpUrl = ctx.helpUrl ? ctx.helpUrl : "index.html";
vm.appBar.menuItems = [];
//CONTEXT TOP PORTION
//populate the context portion of the menu so handle accordingly
if (ctx.menuItems) {
that.appBar.menuItems = ctx.menuItems;
vm.appBar.menuItems = ctx.menuItems;
//DIVIDER
//Insert the devider between context and global items
that.appBar.menuItems.push({ divider: true, inset: false });
vm.appBar.menuItems.push({ divider: true, inset: false });
}
//GLOBAL BOTTOM PORTION
@@ -36,27 +36,27 @@ export default {
//global menu items
//LOGOUT
that.appBar.menuItems.push({
title: that.$gzlocale.get("Logout"),
vm.appBar.menuItems.push({
title: vm.$gzlocale.get("Logout"),
icon: "sign-out-alt",
color: "pink",
key: "app:logout"
});
//divider
that.appBar.menuItems.push({ divider: true, inset: false });
vm.appBar.menuItems.push({ divider: true, inset: false });
//HELP
that.appBar.menuItems.push({
title: that.$gzlocale.get("MenuHelp"),
vm.appBar.menuItems.push({
title: vm.$gzlocale.get("MenuHelp"),
icon: "question-circle",
key: "app:help",
data: that.appBar.helpUrl
data: vm.appBar.helpUrl
});
//ABOUT
that.appBar.menuItems.push({
title: that.$gzlocale.get("HelpAboutAyaNova"),
vm.appBar.menuItems.push({
title: vm.$gzlocale.get("HelpAboutAyaNova"),
icon: "info-circle",
key: "app:nav:abt",
data: "about"
@@ -67,27 +67,45 @@ export default {
//
// Deal with a menu item update request
// called from App.vue
handleReplaceMenuItem(that, newItem) {
if (!that.appBar.menuItems || !newItem) {
handleReplaceMenuItem(vm, newItem) {
if (!vm.appBar.menuItems || !newItem) {
return;
}
//Find the key that is in the collection and replace it
for (var i = 0; i < that.appBar.menuItems.length; i++) {
if (that.appBar.menuItems[i].key == newItem.key) {
for (var i = 0; i < vm.appBar.menuItems.length; i++) {
if (vm.appBar.menuItems[i].key == newItem.key) {
//NOTE: since we are adding a new object, it has no reactivity in it so we need to use the Vue.Set to set it which
//automatically adds the setters and getters that trigger reactivity
//If it was set directly on the array it wouldn't update the UI
that.$set(that.appBar.menuItems, i, newItem);
vm.$set(vm.appBar.menuItems, i, newItem);
return;
}
}
},
///////////////////////////////
// ENABLE / DISABLE HANDLER
//
// Deal with a menu item enable / disable
// called from App.vue
handleDisableMenuItem(vm, key, disabled) {
if (!vm.appBar.menuItems || !key) {
return;
}
//Find the key that is in the collection and replace it
for (var i = 0; i < vm.appBar.menuItems.length; i++) {
var menuItem = vm.appBar.menuItems[i];
if (menuItem.key == key) {
menuItem.disabled = disabled;
}
return;
}
},
///////////////////////////////
// APP (GLOBAL) CLICK HANDLER
//
// Deal with a menu change request
// called from App.vue
handleAppClick(that, menuItem) {
handleAppClick(vm, menuItem) {
//Key will start with the string "app:" if it's a global application command that should be handled here,
//otherwise it's a local command for a local form only
//If there is any extended information required for the command it will be in the data property of the menu item
@@ -99,15 +117,15 @@ export default {
if (!item.disabled && item.owner == "app") {
switch (item.key) {
case "help":
var helpurl = that.$store.state.helpUrl + item.data;
var helpurl = vm.$store.state.helpUrl + item.data;
window.open(helpurl, "_blank");
break;
case "logout":
processLogout();
that.$router.push({ name: "login" });
vm.$router.push({ name: "login" });
break;
case "nav":
that.$router.push({ name: item.data });
vm.$router.push({ name: item.data });
break;
default:
alert(