From cbe2e252e2c0275a82984aa35bada23059f93e2d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 17 Apr 2019 22:09:49 +0000 Subject: [PATCH] --- ayanova/src/App.vue | 89 ++++++++++++--------------------------- ayanova/src/api/gzmenu.js | 37 ++++++++++++++++ 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/ayanova/src/App.vue b/ayanova/src/App.vue index d1dc9328..bd278cb1 100644 --- a/ayanova/src/App.vue +++ b/ayanova/src/App.vue @@ -131,45 +131,6 @@ export default { var that = this; this.$gzevent.$on("menu-change", function(ctx) { gzmenu.handleMenuChange(that, ctx); - - // that.appBar.isMain = ctx.isMain; - // that.appBar.icon = ctx.icon; - // that.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 = []; - - // //CONTEXT TOP PORTION - // //populate the context portion of the menu so handle accordingly - // if (ctx.menuItems) { - // that.appBar.menuItems = ctx.menuItems; - // //DIVIDER - // //Insert the devider between context and global items - // that.appBar.menuItems.push({ divider: true, inset: false }); - // } - - // //GLOBAL BOTTOM PORTION - - // //Global sub-heading - // //Likely won't want this but here anyway to see - // //that.appBar.menuItems.push({ header: "GLOBAL" }); - - // //global menu items - - // //Logout - // that.appBar.menuItems.push({ - // title: this.$gzlocale.get("Logout"), - // icon: "sign-out-alt", - // color: "pink", - // key: "app:logout" - // }); - - // //Insert help item - // that.appBar.menuItems.push({ - // title: this.$gzlocale.get("MenuHelp"), - // icon: "question-circle", - // key: "app:help:" + that.appBar.helpUrl - // }); }); //END OF EVENT ////////////////////////////////// @@ -178,35 +139,37 @@ export default { // (used to update a key in place more efficiently) // this.$gzevent.$on("menu-replace-item", function(newItem) { - if (!that.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) { - //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); - return; - } - } + gzmenu.handleReplaceMenuItem(that, newItem); + // if (!that.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) { + // //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); + // return; + // } + // } }); //END OF EVENT ////////////////////////////////// //CLICK EVENT HANDLER // - this.$gzevent.$on("menu-click", function(item) { - if (!item.disabled && item.key.startsWith("app:")) { - if (item.key.startsWith("app:help:")) { - // "https://www.ayanova.com/AyaNova7webHelp/" + - var helpurl = - that.$store.state.helpUrl + item.key.replace("app:help:", ""); - window.open(helpurl, "_blank"); - } else { - alert("STUB: App.vue::menu click: " + item.key); - } - } + this.$gzevent.$on("menu-click", function(menuitem) { + gzmenu.handleClick(that, menuitem); + // if (!item.disabled && item.key.startsWith("app:")) { + // if (item.key.startsWith("app:help:")) { + // // "https://www.ayanova.com/AyaNova7webHelp/" + + // var helpurl = + // that.$store.state.helpUrl + item.key.replace("app:help:", ""); + // window.open(helpurl, "_blank"); + // } else { + // alert("STUB: App.vue::menu click: " + item.key); + // } + // } }); }, beforeDestroy() { diff --git a/ayanova/src/api/gzmenu.js b/ayanova/src/api/gzmenu.js index 02180e82..e671c951 100644 --- a/ayanova/src/api/gzmenu.js +++ b/ayanova/src/api/gzmenu.js @@ -48,6 +48,43 @@ export default { icon: "question-circle", key: "app:help:" + that.appBar.helpUrl }); + }, + /////////////////////////////// + // CHANGE HANDLER + // + // Deal with a menu item update request + // called from App.vue + handleReplaceMenuItem(that, newItem) { + if (!that.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) { + //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); + return; + } + } + }, + /////////////////////////////// + // CLICK HANDLER + // + // Deal with a menu change request + // called from App.vue + handleClick(that, menuitem) { + if (!menuitem.disabled && menuitem.key.startsWith("app:")) { + if (menuitem.key.startsWith("app:help:")) { + // "https://www.ayanova.com/AyaNova7webHelp/" + + var helpurl = + that.$store.state.helpUrl + menuitem.key.replace("app:help:", ""); + window.open(helpurl, "_blank"); + } else { + alert("STUB gzmenu::handleClick - menu item clicked: " + menuitem.key); + } + } } //new functions above here };