feat(permissions): add dashboard.view permission for cashier/counter/workshop
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

This commit is contained in:
2026-07-02 22:37:28 +00:00
parent 1b51fe65b5
commit 982315bdaf
20 changed files with 56 additions and 42 deletions

View File

@@ -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';
})();