feat(permissions): add dashboard.view permission for cashier/counter/workshop
This commit is contained in:
@@ -201,7 +201,8 @@
|
||||
'accounting.view': '/pos/accounting',
|
||||
'reports.view': '/pos/reports',
|
||||
'config.view': '/pos/config',
|
||||
'config.edit': '/pos/config'
|
||||
'config.edit': '/pos/config',
|
||||
'dashboard.view': '/pos/dashboard'
|
||||
};
|
||||
for (var p in permMap) {
|
||||
if (userPerms.indexOf(p) !== -1 && allowed.indexOf(permMap[p]) === -1) {
|
||||
@@ -211,14 +212,18 @@
|
||||
return allowed.indexOf(pagePath) !== -1;
|
||||
}
|
||||
|
||||
// Counter: fixed module set (no dashboard).
|
||||
// Counter: fixed module set. Dashboard only if explicitly granted.
|
||||
if (userRole === 'counter') {
|
||||
return ['/pos/sale','/pos/catalog','/pos/inventory','/pos/customers','/pos/workshop','/pos/remission-notes','/pos/reports'].indexOf(pagePath) !== -1;
|
||||
var allowed = ['/pos/sale','/pos/catalog','/pos/inventory','/pos/customers','/pos/workshop','/pos/remission-notes','/pos/reports'];
|
||||
if (userPerms.indexOf('dashboard.view') !== -1) allowed.push('/pos/dashboard');
|
||||
return allowed.indexOf(pagePath) !== -1;
|
||||
}
|
||||
|
||||
// Cashier: fixed module set (no dashboard).
|
||||
// Cashier: fixed module set. Dashboard only if explicitly granted.
|
||||
if (userRole === 'cashier') {
|
||||
return ['/pos/sale','/pos/catalog','/pos/inventory','/pos/customers','/pos/workshop','/pos/remission-notes','/pos/invoicing','/pos/reports'].indexOf(pagePath) !== -1;
|
||||
var allowed = ['/pos/sale','/pos/catalog','/pos/inventory','/pos/customers','/pos/workshop','/pos/remission-notes','/pos/invoicing','/pos/reports'];
|
||||
if (userPerms.indexOf('dashboard.view') !== -1) allowed.push('/pos/dashboard');
|
||||
return allowed.indexOf(pagePath) !== -1;
|
||||
}
|
||||
|
||||
// Always allow login/logout pages so users can sign out without hitting the guard.
|
||||
@@ -287,8 +292,9 @@
|
||||
(function hideBackToSystemForRestrictedRoles() {
|
||||
var backBtn = document.getElementById('backToSystemBtn');
|
||||
if (!backBtn) return;
|
||||
// owner/admin are the only roles that should see the dashboard shortcut from POS.
|
||||
// owner/admin always see it; others only if they have dashboard.view.
|
||||
if (role === 'owner' || role === 'admin') return;
|
||||
if ((window.POS_USER.permissions || []).indexOf('dashboard.view') !== -1) return;
|
||||
backBtn.style.display = 'none';
|
||||
})();
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ window.renderSidebar = function(modulesOverride) {
|
||||
'invoicing.view': 'invoicing',
|
||||
'quotations.view': 'quotations',
|
||||
'accounting.view': 'accounting',
|
||||
'reports.view': 'reports'
|
||||
'reports.view': 'reports',
|
||||
'dashboard.view': 'dashboard'
|
||||
};
|
||||
for (var p in permMap) {
|
||||
if (perms.indexOf(p) !== -1 && allowed.indexOf(permMap[p]) === -1) {
|
||||
@@ -63,10 +64,14 @@ window.renderSidebar = function(modulesOverride) {
|
||||
return allowed.indexOf(id) !== -1;
|
||||
}
|
||||
if (role === 'counter') {
|
||||
return ['pos','catalog','inventory','customers','workshop','remission_notes','reports'].indexOf(id) !== -1;
|
||||
var allowed = ['pos','catalog','inventory','customers','workshop','remission_notes','reports'];
|
||||
if (hasPerm('dashboard.view')) allowed.push('dashboard');
|
||||
return allowed.indexOf(id) !== -1;
|
||||
}
|
||||
if (role === 'cashier') {
|
||||
return ['pos','catalog','inventory','customers','workshop','remission_notes','invoicing','reports'].indexOf(id) !== -1;
|
||||
var allowed = ['pos','catalog','inventory','customers','workshop','remission_notes','invoicing','reports'];
|
||||
if (hasPerm('dashboard.view')) allowed.push('dashboard');
|
||||
return allowed.indexOf(id) !== -1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user