diff --git a/pos/static/js/app-init.js b/pos/static/js/app-init.js index eda4ddb..82a2363 100644 --- a/pos/static/js/app-init.js +++ b/pos/static/js/app-init.js @@ -190,6 +190,9 @@ if (data) { localStorage.setItem('pos_modules', JSON.stringify(data)); window.POS_USER.modules = data; + if (typeof window.renderSidebar === 'function') { + window.renderSidebar(data); + } } }).catch(function() {}); } catch(e) {} diff --git a/pos/static/js/sidebar.js b/pos/static/js/sidebar.js index 4ab972a..c679e28 100644 --- a/pos/static/js/sidebar.js +++ b/pos/static/js/sidebar.js @@ -3,7 +3,7 @@ * Replaces existing sidebar in each page with a consistent, themed version. * Uses i18n t() for all labels when available. */ -(function() { +window.renderSidebar = function(modulesOverride) { 'use strict'; // i18n helper — falls back to raw string if i18n.js not loaded @@ -18,9 +18,13 @@ var currentLang = localStorage.getItem('pos_lang') || 'es'; var modules = {}; - try { - modules = JSON.parse(localStorage.getItem('pos_modules') || '{}'); - } catch(e) { modules = {}; } + if (modulesOverride && typeof modulesOverride === 'object') { + modules = modulesOverride; + } else { + try { + modules = JSON.parse(localStorage.getItem('pos_modules') || '{}'); + } catch(e) { modules = {}; } + } function moduleEnabled(key) { // Default to true if not configured yet @@ -135,10 +139,6 @@ if (main) main.classList.add('pos-main-offset'); // ── Tablet/mobile: sidebar toggle + overlay ───────────────────── - // Creates a hamburger button + overlay for screens < 1024px. - // The CSS in pos-glass.css hides the sidebar by default on tablets - // and shows it as a slide-in drawer when .open is added. - var sidebar = document.querySelector('.pos-sidebar, .sidebar, #sidebar'); var overlay = document.getElementById('sidebar-overlay'); @@ -193,5 +193,7 @@ // Reveal sidebar smoothly after replacement to avoid flash/stun document.body.classList.add('sidebar-ready'); +}; -})(); +// Initial render +window.renderSidebar();