diff --git a/modules/shared/auth/ui/home.php b/modules/shared/auth/ui/home.php index 507821f..2688e70 100644 --- a/modules/shared/auth/ui/home.php +++ b/modules/shared/auth/ui/home.php @@ -924,7 +924,8 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM echo " const heading = document.querySelector('[data-main-heading]');"; echo " if (heading && portalModuleHeadings[moduleName]) { heading.textContent = portalModuleHeadings[moduleName]; }"; echo "};"; - echo "const renderLeftNavigation = (moduleName) => {"; + echo "const updatePortalLocation = (moduleName, entryName = '') => { const url = new URL(window.location.href); url.searchParams.set('portal_module', moduleName); if (entryName) { url.searchParams.set('portal_section', entryName); } else { url.searchParams.delete('portal_section'); } window.history.replaceState({ ...(window.history.state || {}), portalModule: moduleName, portalSection: entryName }, '', url); };"; + echo "const renderLeftNavigation = (moduleName, requestedEntry = '') => {"; echo " const title = document.querySelector('[data-left-navigation-title]');"; echo " const contentTitle = document.querySelector('[data-left-navigation-content-title]');"; echo " const contentSection = document.querySelector('.sg-left-navigation-pattern__group-card--content');"; @@ -933,7 +934,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM echo " if (title) { title.textContent = moduleName; }"; echo " if (!menu) { return; }"; echo " const entries = portalModuleNavigation[moduleName] || [];"; - echo " const activeEntry = entries[0] || '';"; + echo " const activeEntry = entries.includes(requestedEntry) ? requestedEntry : (entries[0] || '');"; echo " if (contentTitle) { contentTitle.textContent = activeEntry; }"; echo " if (contentSection) { contentSection.setAttribute('aria-hidden', 'false'); }"; echo " if (contentBody) { contentBody.innerHTML = portalModuleContentCards[activeEntry] || ''; }"; @@ -961,10 +962,11 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM echo " if (contentTitle) { contentTitle.textContent = entryName; }"; echo " if (contentSection) { contentSection.setAttribute('aria-hidden', 'false'); }"; echo " if (contentBody) { contentBody.innerHTML = portalModuleContentCards[entryName] || ''; }"; - echo " if (entryName === 'Bestellungen') { initBestellungenBindings(); }"; - echo " if (entryName === 'Marktdurchführungen') { initMarketsBindings(); }"; - echo " if (entryName === 'Märkte') { initMarketDefinitionsBindings(); }"; - echo " if (entryName === 'Lager' || entryName === 'Artikel') { initLagerBindings(); }"; + echo " if (entryName === 'Bestellungen') { initBestellungenBindings(); }"; + echo " if (entryName === 'Marktdurchführungen') { initMarketsBindings(); }"; + echo " if (entryName === 'Märkte') { initMarketDefinitionsBindings(); }"; + echo " if (entryName === 'Lager' || entryName === 'Artikel') { initLagerBindings(); }"; + echo " updatePortalLocation(moduleName, entryName);"; echo " });"; echo " });"; echo "};"; @@ -978,9 +980,11 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM echo " });"; echo " renderMainHeading(button.textContent.trim());"; echo " renderLeftNavigation(button.textContent.trim());"; + echo " updatePortalLocation(button.textContent.trim());"; echo " });"; echo " });"; echo "});"; + echo "(() => { const url = new URL(window.location.href); const requestedModule = url.searchParams.get('portal_module') || 'ERP'; const moduleButton = Array.from(document.querySelectorAll('.sg-portal-header__tabs .sg-tab-button')).find((button) => button.textContent.trim() === requestedModule) || document.querySelector('.sg-portal-header__tabs .sg-tab-button'); if (!moduleButton) { return; } const moduleName = moduleButton.textContent.trim(); document.querySelectorAll('.sg-portal-header__tabs .sg-tab-button').forEach((button) => { const active = button === moduleButton; button.setAttribute('aria-selected', String(active)); button.dataset.componentState = active ? 'active' : 'inactive'; }); renderMainHeading(moduleName); renderLeftNavigation(moduleName, url.searchParams.get('portal_section') || ''); })();"; echo "document.querySelectorAll('.sg-sandwich-menu-wrap').forEach((wrap) => {"; echo " const button = wrap.querySelector('.sg-sandwich-button');"; echo " button.addEventListener('click', (event) => {";