Enhance module navigation: update inventory and library navbar logic for improved module access and user session handling

This commit is contained in:
2026-05-08 12:03:38 +02:00
parent 5cb59f4b63
commit 6c73f79866
2 changed files with 251 additions and 220 deletions
+18 -1
View File
@@ -406,6 +406,9 @@ def _is_inventory_module_path(path):
if not path:
return False
if path == '/' or path == '/home':
return True
inventory_prefixes = (
'/scanner',
'/inventory',
@@ -431,11 +434,25 @@ def _enforce_module_access():
def _get_current_module(path):
"""Resolve the active UI module for navbar separation."""
# Check if referer indicates we came from library
referrer = request.referrer or ''
if cfg.LIBRARY_MODULE_ENABLED and _is_library_module_path(path):
session['last_module'] = 'library'
return 'library'
if cfg.INVENTORY_MODULE_ENABLED and _is_inventory_module_path(path):
session['last_module'] = 'inventory'
return 'inventory'
last_module = session.get('last_module')
if last_module == 'library' and cfg.LIBRARY_MODULE_ENABLED:
return 'library'
if last_module == 'inventory' and cfg.INVENTORY_MODULE_ENABLED:
return 'inventory'
# Default fallback: prefer inventory if enabled, otherwise library, else inventory
if cfg.INVENTORY_MODULE_ENABLED:
return 'inventory'
# Default fallback:
return 'library' if cfg.LIBRARY_MODULE_ENABLED else 'inventory'
+14
View File
@@ -1032,6 +1032,7 @@
</div>
</div>
{% endif %}
{% if 'username' in session %}
{% if CURRENT_MODULE != 'library' and inventory_module_enabled %}
<nav class="navbar navbar-expand-lg navbar-dark" id="inventoryNavbar">
<div class="container-fluid">
@@ -1263,6 +1264,19 @@
</div>
</nav>
{% endif %}
{% else %}
<nav class="navbar navbar-expand-lg navbar-dark" id="loginNavbar">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url_for('home') }}" data-icon="🔹">Invario</a>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="{{ url_for('impressum') }}">Impressum</a>
</li>
</ul>
</div>
</nav>
{% endif %}
<div class="container">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}