Make dashboard/home link role-aware: counter -> inventory, cashier -> POS
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-18 19:57:01 +00:00
parent c374cccd77
commit f2d4558b80
2 changed files with 19 additions and 1 deletions

View File

@@ -190,6 +190,21 @@
} catch(e) { return true; }
}
function updateHomeLinks(userRole, userPerms) {
// Point the dashboard/home icon to the role-specific default page.
var homeHref = '/pos/dashboard';
if (userRole === 'counter' && userPerms.indexOf('inventory.view') !== -1) {
homeHref = '/pos/inventory';
} else if (userRole === 'cashier' && userPerms.indexOf('pos.sell') !== -1) {
homeHref = '/pos/sale';
} else if (userRole === 'workshop' && userPerms.indexOf('workshop.view') !== -1 && moduleEnabled('workshop')) {
homeHref = '/pos/workshop';
}
document.querySelectorAll('a[href="/pos/dashboard"]').forEach(function(a) {
a.setAttribute('href', homeHref);
});
}
function isPageAllowed(pagePath, userRole, userPerms) {
if (userRole === 'owner' || userRole === 'admin') return true;
@@ -298,11 +313,14 @@
if (typeof window.renderSidebar === 'function') {
window.renderSidebar(window.POS_USER.modules || JSON.parse(localStorage.getItem('pos_modules') || '{}'));
}
updateHomeLinks(window.POS_USER.role, window.POS_USER.permissions);
}).catch(function() {
enforcePageGuard(role, payload.permissions || []);
updateHomeLinks(role, payload.permissions || []);
});
} catch(e) {
enforcePageGuard(role, payload.permissions || []);
updateHomeLinks(role, payload.permissions || []);
}
// ─── Preload enabled modules for sidebar filtering ───

View File

@@ -6,7 +6,7 @@
// The fetch handler normalizes static asset URLs (strips ?v= query strings)
// so templates can use cache-busting query params freely.
const VERSION = 53;
const VERSION = 54;
const CACHE_NAME = 'nexus-pos-v' + VERSION;
const APP_SHELL = [