/* xxxeslint-disable */ ///////////////////////////////// // Menu utils and handlers // export default { /////////////////////////////////////////// // TECH SUPPORT / CONTACT FORUM URL // contactSupportUrl() { let dbId = encodeURIComponent( window.$gz.store.state.globalSettings.serverDbId ); let company = encodeURIComponent( window.$gz.store.state.globalSettings.company ); return `https://contact.ayanova.com/contact?dbid=${dbId}&company=${company}`; }, /////////////////////////////// // CHANGE HANDLER // // Deal with a menu change request // called from App.vue handleMenuChange(vm, ctx) { let UTILITY_TYPES = [ window.$gz.type.NoType, window.$gz.type.Global, window.$gz.type.NoType, window.$gz.type.ServerState, window.$gz.type.License, window.$gz.type.LogFile, window.$gz.type.ServerJob, window.$gz.type.TrialSeeder, window.$gz.type.ServerMetrics, window.$gz.type.UserOptions, window.$gz.type.FormCustom, window.$gz.type.DataListView, window.$gz.type.GlobalOps, window.$gz.type.BizMetrics, window.$gz.type.Backup, window.$gz.type.Notification, window.$gz.type.NotifySubscription ]; vm.appBar.isMain = ctx.isMain; vm.appBar.icon = ctx.icon; vm.appBar.title = ctx.title; if (ctx.title) { document.title = "AyaNova " + vm.$ay.t(ctx.title); } else { document.title = "AyaNova"; } //Parse the formdata if present //FORMDATA is OPTIONAL and only required for forms that need to allow //viewing object history, attachments, custom fields, etc that kind of thing //usually CORE objects with an id, NOT utility type forms let formAyaType = 0; let formRecordId = 0; if (ctx.formData) { if (ctx.formData.ayaType != null) { formAyaType = ctx.formData.ayaType; } if (ctx.formData.recordId != null) { formRecordId = ctx.formData.recordId; } } //flag for if it's wikiable, reviewable, attachable, searchable, historical let isCoreBizObject = formAyaType != 0 && formRecordId != 0; //set the help url if presented or default to the User section intro vm.appBar.helpUrl = ctx.helpUrl ? ctx.helpUrl : "user-intro"; vm.appBar.menuItems = []; //CONTEXT TOP PORTION //populate the context portion of the menu so handle accordingly if (ctx.menuItems) { vm.appBar.menuItems = ctx.menuItems; //DIVIDER //Insert the devider between context and global items // vm.appBar.menuItems.push({ divider: true, inset: false }); } //WIKI, ATTACHMENTS, RECORD HISTORY //NOTE: This applies equally to all core business object types that are basically real world and have an id and a type (all are wikiable, attachable and reviewable) //Not utility type objects like datalist etc //there will be few exceptions so they will be coded in later if needed but assume anything with an id and a type if (isCoreBizObject) { // vm.appBar.menuItems.push({ // title: "Attachments"), // icon: "fa - paperclip", // key: "app:attachments", // data: { ayaType: formAyaType, recordId: formRecordId } // }); // vm.appBar.menuItems.push({ // title: "WikiPage"), // icon: "fa - feather", // key: "app:wiki", // data: { ayaType: formAyaType, recordId: formRecordId } // }); //"Review" was follow up type of schedule marker //basically it's now a "Reminder" type of object but it's own thing with separate collection vm.appBar.menuItems.push({ title: "Review", icon: "$ayiCalendarCheck", key: "app:review", data: { ayaType: formAyaType, recordId: formRecordId } }); //AFAIK right now any item with an id and a type can have a history //anything not would be the exception rather than the rule vm.appBar.menuItems.push({ title: "History", icon: "$ayiHistory", key: "app:history", data: { ayaType: formAyaType, recordId: formRecordId } }); } //CUSTOMIZE //set custom fields and link to translation text editor if ( isCoreBizObject && ctx.formData && ctx.formData.formCustomTemplateKey != undefined && window.$gz.role.hasRole([ window.$gz.role.AUTHORIZATION_ROLES.BizAdminFull, window.$gz.role.AUTHORIZATION_ROLES.BizAdminLimited ]) ) { //NOTE: BizAdminFull can edit, bizadminlimited can read only //add customize menu item //DIVIDER //Insert the devider between context and global items // vm.appBar.menuItems.push({ divider: true, inset: false }); //customize vm.appBar.menuItems.push({ title: "Customize", icon: "$ayiCustomize", data: ctx.formData.formCustomTemplateKey, key: "app:customize" }); } //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 //divider //vm.appBar.menuItems.push({ divider: true, inset: false }); //SEARCH //all forms except the search form if (!ctx.hideSearch && !UTILITY_TYPES.includes(formAyaType)) { //For all forms but not on the search form itself; if this is necessary for others then make a nosearch or something flag controlled by incoming ctx but if not then this should suffice vm.appBar.menuItems.push({ title: "Search", icon: "$ayiSearch", key: "app:search", data: formAyaType }); } //HELP vm.appBar.menuItems.push({ title: "MenuHelp", icon: "$ayiQuestionCircle", key: "app:help", data: vm.appBar.helpUrl }); //ABOUT if (!isCoreBizObject && ctx.helpUrl != "form-ay-about") { vm.appBar.menuItems.push({ title: "HelpAboutAyaNova", icon: "$ayiInfoCircle", key: "app:nav:abt", data: "ay-about" }); } }, /////////////////////////////// // CHANGE HANDLER // // Deal with a menu item update request // called from App.vue handleReplaceMenuItem(vm, newItem) { if (!vm.appBar.menuItems || !newItem) { return; } //Find the key that is in the collection and replace it for (let 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 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 menu item and set it to disabled and recolor it to disabled color and return for (let i = 0; i < vm.appBar.menuItems.length; i++) { let menuItem = vm.appBar.menuItems[i]; if (menuItem.key == key) { vm.$set(vm.appBar.menuItems[i], "disabled", disabled); //menuItem.disabled = disabled; vm.$set(vm.appBar.menuItems[i], "color", disabled ? "disabled" : ""); return; } } }, /////////////////////////////// // CHANGE ICON HANDLER // Change icon dymanically // (note, can pass null for new icon to clear it) // handleChangeMenuItemIcon(vm, key, newIcon) { if (!vm.appBar.menuItems || !key) { return; } //Find the menu item and change it's icon for (let i = 0; i < vm.appBar.menuItems.length; i++) { let menuItem = vm.appBar.menuItems[i]; if (menuItem.key == key) { vm.$set(vm.appBar.menuItems[i], "icon", newIcon); return; } } }, /////////////////////////////// // APP (GLOBAL) CLICK HANDLER // // Deal with a menu change request // called from App.vue 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 //split a key into component parts, part one is the responsible party, part two is the command, part three only exists to make it unique if necessary //each part is separated by a colon //Handle different items let item = this.parseMenuItem(menuItem); if (!item.disabled && item.owner == "app") { switch (item.key) { case "help": let helpurl = vm.$store.state.helpUrl + item.data; window.open(helpurl, "_blank"); break; case "search": vm.$router.push({ name: "home-search", params: { ayatype: item.data } }); break; // case "attachments": // vm.$router.push({ // name: "ay-attachments", // params: { ayatype: item.data.ayaType, recordid: item.data.recordId } // }); // break; // case "plugin": // alert("STUB: plugin / more"); // break; case "review": vm.$router.push({ name: "ay-review", params: { ayatype: item.data.ayaType, recordid: item.data.recordId } }); break; case "history": vm.$router.push({ name: "ay-history", params: { ayatype: item.data.ayaType, recordid: item.data.recordId } }); break; case "customize": vm.$router.push({ name: "ay-customize", params: { formCustomTemplateKey: item.data } }); break; case "nav": vm.$router.push({ name: item.data }); break; default: window.$gz.eventBus.$emit( "notify-warning", "gzmenu:handleAppClick - unrecognized command [" + menuItem.key + "]" ); } } }, /////////////////////////////// // PARSE MENU ITEM CLICK // // parse out the parts of a // menu item from a click event // parseMenuItem(menuItem) { //format is "AREA:KEY:UNIQUEID" //and data is in data portion let keyparts = menuItem.key.split(":"); let ret = { owner: keyparts[0], key: keyparts[1], data: menuItem.data, disabled: menuItem.disabled, vm: menuItem.vm ? menuItem.vm : null }; if (keyparts.length > 2) { ret.id = keyparts[2]; } return ret; }, /////////////////////////////////// // WIRE UP MENU EVENTS // // called once from app.vue only // wireUpEventHandlers(vm) { let self = this; window.$gz.eventBus.$on("menu-change", function handleMenuChange(ctx) { self.handleMenuChange(vm, ctx); }); window.$gz.eventBus.$on("menu-replace-item", function handleReplaceMenuItem( newItem ) { self.handleReplaceMenuItem(vm, newItem); }); window.$gz.eventBus.$on("menu-disable-item", function handleDisableMenuItem( key ) { self.handleDisableMenuItem(vm, key, true); }); window.$gz.eventBus.$on("menu-enable-item", function handleDisableMenuItem( key ) { self.handleDisableMenuItem(vm, key, false); }); window.$gz.eventBus.$on( "menu-change-item-icon", function handleChangeMenuItemIcon(key, newIcon) { self.handleChangeMenuItemIcon(vm, key, newIcon); } ); window.$gz.eventBus.$on("menu-click", function handleMenuClick(menuitem) { self.handleAppClick(vm, menuitem); }); } //new functions above here };