Make dashboard/home link role-aware: counter -> inventory, cashier -> POS
This commit is contained in:
@@ -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 ───
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user