This commit is contained in:
2019-04-23 22:08:27 +00:00
parent f54a4d874a
commit 412f5273c8
4 changed files with 36 additions and 25 deletions

View File

@@ -39,8 +39,9 @@ All platforms and browsers
- DONE That way we can put anything into the data key again because in future might need whole objects etc (almost certainly will)
- 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
- DONE WIRE up save menu item and add code to disable save on broken rules (and make red, disabled etc)
- DONE Move wire up event code from app.vue to gzmenu and call it from app.vue
- Need rights in form state so can easily enable / disable etc
- 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

View File

@@ -104,31 +104,10 @@ export default {
},
created() {
//////////////////////////////////
// MENU EVENT HANDLERS
// WIRE UP MENU EVENT HANDLERS
//
//
var vm = this;
this.$gzevent.$on("menu-change", function handleMenuChange(ctx) {
vm.$gzmenu.handleMenuChange(vm, ctx);
});
this.$gzevent.$on("menu-replace-item", function handleReplaceMenuItem(
newItem
) {
vm.$gzmenu.handleReplaceMenuItem(vm, newItem);
});
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) {
vm.$gzmenu.handleAppClick(vm, menuitem);
});
this.$gzmenu.wireUpAppEventHandlers(this);
},
beforeDestroy() {
this.$gzevent.$off();

View File

@@ -155,6 +155,35 @@ export default {
disabled: menuItem.disabled,
vm: menuItem.vm ? menuItem.vm : null
};
},
///////////////////////////////
// WIRE UP MAIN APP EVENTS
//
// called only by app.vue
//
wireUpAppEventHandlers(vm) {
var self = this;
vm.$gzevent.$on("menu-change", function handleMenuChange(ctx) {
self.handleMenuChange(vm, ctx);
});
vm.$gzevent.$on("menu-replace-item", function handleReplaceMenuItem(
newItem
) {
self.handleReplaceMenuItem(vm, newItem);
});
vm.$gzevent.$on("menu-disable-item", function handleDisableMenuItem(key) {
self.handleDisableMenuItem(vm, key, true);
});
vm.$gzevent.$on("menu-enable-item", function handleDisableMenuItem(key) {
self.handleDisableMenuItem(vm, key, false);
});
vm.$gzevent.$on("menu-click", function handleMenuClick(menuitem) {
self.handleAppClick(vm, menuitem);
});
}
//new functions above here
};

View File

@@ -19,6 +19,7 @@ import gzutil from "./api/gzutil";
import locale from "./api/locale";
import gzapi from "./api/gzapi";
import gzform from "./api/gzform";
import roles from "./api/roles"
import "@/assets/css/main.css";
import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
@@ -27,6 +28,7 @@ import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
// LIBS AND GLOBAL ITEMS
// (https://medium.com/js-dojo/use-any-javascript-library-with-vue-js-3f7e2a4974a8)
//
Object.defineProperty(Vue.prototype, "$gzrole", { value: roles });
Object.defineProperty(Vue.prototype, "$gzevent", { value: gzeventbus });
Object.defineProperty(Vue.prototype, "$gzmenu", { value: gzmenu });
Object.defineProperty(Vue.prototype, "$gzutil", { value: gzutil });