This commit is contained in:
2020-12-05 00:34:08 +00:00
parent 376aeab6d2
commit 2ffbb9a30d
3 changed files with 114 additions and 148 deletions

View File

@@ -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;
}
};
/*

View File

@@ -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 = [];