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';
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user