From 358a2b53d4a84481708ee3775f66d7d6ce51d583 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 23 Apr 2019 20:16:50 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 1 + ayanova/src/App.vue | 11 ++++--- ayanova/src/api/gzmenu.js | 4 ++- ayanova/src/views/inventory-widget-edit.vue | 36 ++++++++++++--------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index fdedf73b..a820883a 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -40,6 +40,7 @@ All platforms and browsers - DONE Move ABOUT item to just above HELP in menu and remove from main NAV and make it navigate properly on click - DONE Make about contextual and insert a menu item to view log - WIRE up save menu item and add code to disable save on broken rules (and make red, disabled etc) + - Move wire up event code from app.vue to gzmenu and call it from app.vue - Wire up delete menu item - api code is stubbed out for delete, need to write that as well - DONE TODO navigating through menu doesn't "back" properly when clicking back on browser controls diff --git a/ayanova/src/App.vue b/ayanova/src/App.vue index 6a6a818d..b1c515fa 100644 --- a/ayanova/src/App.vue +++ b/ayanova/src/App.vue @@ -118,11 +118,12 @@ export default { vm.$gzmenu.handleReplaceMenuItem(vm, newItem); }); - this.$gzevent.$on("menu-disable-item", function handleDisableMenuItem( - key, - disabled - ) { - vm.$gzmenu.handleDisableMenuItem(vm, key, disabled); + this.$gzevent.$on("menu-disable-item", function handleDisableMenuItem(key) { + vm.$gzmenu.handleDisableMenuItem(vm, key, true); + }); + + this.$gzevent.$on("menu-enable-item", function handleDisableMenuItem(key) { + vm.$gzmenu.handleDisableMenuItem(vm, key, false); }); this.$gzevent.$on("menu-click", function handleMenuClick(menuitem) { diff --git a/ayanova/src/api/gzmenu.js b/ayanova/src/api/gzmenu.js index 982f3385..cf7a0c42 100644 --- a/ayanova/src/api/gzmenu.js +++ b/ayanova/src/api/gzmenu.js @@ -95,8 +95,10 @@ export default { for (var i = 0; i < vm.appBar.menuItems.length; i++) { var menuItem = vm.appBar.menuItems[i]; if (menuItem.key == key) { - menuItem.disabled = disabled; + vm.$set(vm.appBar.menuItems[i], "disabled", disabled); + //menuItem.disabled = disabled; } + vm.$set(vm.appBar.menuItems[i], "color", disabled ? "error" : ""); return; } }, diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index 78d83e33..bd6c817d 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -263,21 +263,27 @@ export default { } }; }, - // , - // watch: { - // canSave: { - // // xeslint-disable-next-line - // handler: function(newState) { - // this.$gzevent.$emit( - // "menu-replace-item", - // "inventory-widget-edit:save", - // newState - // ); - // //todo: change the save button state here - // //console.log("Valid CHANGED, was " + oldObj + " Now is " + newObj); - // } - // } - // }, + //WATCHERS + watch: { + formState: { + // eslint-disable-next-line + handler: function(val, oldVal) { + if (this.formState.loading) { + return; + } + var canSave = val.dirty && val.valid; + if (canSave) { + this.$gzevent.$emit("menu-enable-item", "inventory-widget-edit:save"); + } else { + this.$gzevent.$emit( + "menu-disable-item", + "inventory-widget-edit:save" + ); + } + }, + deep: true + } + }, computed: { canSave: function() { return this.formState.valid && this.formState.dirty;