From 2ffbb9a30dba31ac3edb257a2e3792e6117276bf Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 5 Dec 2020 00:34:08 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 25 ++- ayanova/src/api/authorizationroles.js | 19 ++- ayanova/src/api/initialize.js | 218 ++++++++++---------------- 3 files changed, 114 insertions(+), 148 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index fdaa4dde..acebaa7b 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -5,8 +5,16 @@ MISC ITEMS THAT CAME UP +todo: Cust-User requires User rights but that's a big thing because it exposes + inside user to edit possibly + Need to carve a workaround I guess in the User route and objects - +todo: No roles defined Users can login + Customer user with no roles can login and gets a CSR list screen + regular user with no roles can login and gets the evaluation screen + but shouldn't see that either or at least not be able to do anything serious there + Ideally they should be able to login and see their own home stuff and notifications and maybe memos, but nothing else + Initialize.js needs tweaking todo: if list view not found / deleted when grid list form is opened rather than erroring with object/object it should @@ -35,14 +43,17 @@ todo: deleting customer must attempt to delete the following as they are entered todo: deleting HeadOffice must attempt to delete all contacts too +todo: initialize.js is sketchy as hell, it replicates the entire role rights stuff essentially + it should be changed so that instead of checking for roles it should be checking for rights to individual items one by one + if it finds at least one item in the sub array for that group then it can make the container and insert the items -todo: No roles defined Users can login - Customer user with no roles can login and gets a CSR list screen - regular user with no roles can login and gets the evaluation screen - but shouldn't see that either or at least not be able to do anything serious there - Ideally they should be able to login and see their own home stuff and notifications and maybe memos, but nothing else - Initialize.js needs tweaking + + +todo: Initialize has an expired license section that prevents all other options + except fixing the license + however I think this is supposed to switch to readonly mode in most cases unless it's a rental license? + need to look into this, it's confusing what the intent is there todo: Case 3595 Mass delete extension Do this early as it will be copied over and over again diff --git a/ayanova/src/api/authorizationroles.js b/ayanova/src/api/authorizationroles.js index 19ef8989..22c827a4 100644 --- a/ayanova/src/api/authorizationroles.js +++ b/ayanova/src/api/authorizationroles.js @@ -63,6 +63,16 @@ export default { return (window.$gz.store.state.roles & desiredRole) != 0; } }, + ////////////////////////////////////////////////////////// + // Does current logged in user have *ANY* role? + // + // + hasAnyRole() { + if (!window.$gz.store.state.roles || window.$gz.store.state.roles === 0) { + return false; + } + return true; + }, /////////////////////////////////////////////////////////////////////// // Get a default empty rights object so that it can be present when a // form first loads @@ -151,15 +161,12 @@ export default { }, ///////////////////////////////// // convenience method for forms that deal with multiple object types - // (i.e. grids, history etc) + // (i.e. grids, history etc, initialization of main menu etc) // canOpen(oType) { let r = this.getRights(oType); - // //Am seeing where change is true but read is false, change trumps read so ... - // if (r.change == true) { - // return true; - // } - return r.read; + //convention is change might be defined but not read so canOpen is true eitehr way + return r.change == true || r.read == true; } }; /* diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index ad9c75dd..8342af61 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -37,7 +37,7 @@ function initNavPanel() { window.$gz.store.state.userType == 4; let isSubcontractorTypeUser = window.$gz.store.state.userType == 5; - //Customer "outside user" options + //### ALL OUTSIDE TYPE USERS (CUSTOMER / HEADOFFICE) ### if (isCustomerTypeUser) { //clear sublevel array sub = []; @@ -84,9 +84,10 @@ function initNavPanel() { return; } - //Non-customer ("inside user") options + //###### ALL INSIDE USERS FROM HERE DOWN ############### + + //******* EXPIRED LICENSE BLOCK - //******* License issue //Status NONE, EXPIREDTRIAL, EXPIREDPURCHASE, REVOKED //only show license and logout /* public enum LicenseStatus @@ -118,144 +119,91 @@ function initNavPanel() { return; } - //****************** HOME - //Most users except ops and client logins - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.InventoryLimited, - role.InventoryFull, - role.AccountingFull, - role.TechLimited, - role.TechFull, - role.SubContractorLimited, - role.SubContractorFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - //DASHBOARD - //KPI / METRICS / CHARTS AND STUFF APPROPRIATE TO ROLE - sub.push({ - title: "Dashboard", - icon: "$ayiTachometer", - route: "/home-dashboard", - key: key++ - }); + //******* LICENSE OK, set up menu options for inside users... + //####### HOME + + //all inside users + + //DASHBOARD + //KPI / METRICS / CHARTS AND STUFF APPROPRIATE TO ROLE + sub.push({ + title: "Dashboard", + icon: "$ayiTachometer", + route: "/home-dashboard", + key: key++ + }); + + //SEARCH + + sub.push({ + title: "Search", + icon: "$ayiSearch", + route: "/home-search", + key: key++ + }); + + //HISTORY / MRU / ACTIVITY (personal) + sub.push({ + title: "History", + icon: "$ayiHistory", + route: `/history/3/${window.$gz.store.state.userId}/true`, + key: key++ + }); + + //SCHEDULE (personal) + sub.push({ + title: "Schedule", + icon: "$ayiCalendarDay", + route: "/home-schedule", + key: key++ + }); + + //MEMOS + sub.push({ + title: "MemoList", + icon: "$ayiInbox", + route: "/home-memos", + key: key++ + }); + + //REMINDERS (SCHEDULE MARKERS) + sub.push({ + title: "ReminderList", + icon: "$ayiStickyNote", + route: "/home-reminders", + key: key++ + }); + + //USER SETTINGS + sub.push({ + title: "UserSettings", + icon: "$ayiUserCog", + route: "/home-user-settings", + key: key++ + }); + + //USER NOTIFICATION SUBSCRIPTIONS + + sub.push({ + title: "NotifySubscriptionList", + icon: "$ayiBullhorn", + route: "/home-notify-subscriptions", + key: key++ + }); + + //HOME + if (sub.length > 0) { //Set homePage in store to dashboard window.$gz.store.commit("setHomePage", "/home-dashboard"); - - //SEARCH - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.InventoryLimited, - role.InventoryFull, - role.AccountingFull, - role.TechLimited, - role.TechFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - sub.push({ - title: "Search", - icon: "$ayiSearch", - route: "/home-search", - key: key++ - }); - } - - //HISTORY / MRU / ACTIVITY (personal) - sub.push({ - title: "History", - icon: "$ayiHistory", - route: `/history/3/${window.$gz.store.state.userId}/true`, - key: key++ - }); - - //SCHEDULE (personal) - sub.push({ - title: "Schedule", - icon: "$ayiCalendarDay", - route: "/home-schedule", - key: key++ - }); - - //MEMOS - sub.push({ - title: "MemoList", - icon: "$ayiInbox", - route: "/home-memos", - key: key++ - }); - - //REMINDERS (SCHEDULE MARKERS) - sub.push({ - title: "ReminderList", - icon: "$ayiStickyNote", - route: "/home-reminders", - key: key++ - }); - - //USER SETTINGS - sub.push({ - title: "UserSettings", - icon: "$ayiUserCog", - route: "/home-user-settings", - key: key++ - }); - - //USER NOTIFICATION SUBSCRIPTIONS - if ( - //all but subcontractors (arbitrary decision without any facts ;) - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.InventoryLimited, - role.InventoryFull, - role.AccountingFull, - role.TechLimited, - role.TechFull, - role.SalesFull, - role.SalesLimited - ]) - ) { - sub.push({ - title: "NotifySubscriptionList", - icon: "$ayiBullhorn", - route: "/home-notify-subscriptions", - key: key++ - }); - } - - //HOME addNavItem("Home", "$ayiHome", undefined, sub, key++, "home"); } - //****************** CUSTOMERS - if ( - window.$gz.role.hasRole([ - role.BizAdminFull, - role.BizAdminLimited, - role.DispatchFull, - role.DispatchLimited, - role.TechFull, - role.TechLimited, - role.AccountingFull, - role.SalesFull, - role.SalesLimited - ]) - ) { + //######### CUSTOMERS + if (window.$gz.role.canOpen(window.$gz.type.Customer)) { + + //these all require Customer rights so all in the same block + //clear sublevel array sub = [];