Enhance module navigation: update inventory and library navbar logic for improved module access and user session handling
This commit is contained in:
+18
-1
@@ -406,6 +406,9 @@ def _is_inventory_module_path(path):
|
|||||||
if not path:
|
if not path:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if path == '/' or path == '/home':
|
||||||
|
return True
|
||||||
|
|
||||||
inventory_prefixes = (
|
inventory_prefixes = (
|
||||||
'/scanner',
|
'/scanner',
|
||||||
'/inventory',
|
'/inventory',
|
||||||
@@ -431,11 +434,25 @@ def _enforce_module_access():
|
|||||||
|
|
||||||
def _get_current_module(path):
|
def _get_current_module(path):
|
||||||
"""Resolve the active UI module for navbar separation."""
|
"""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):
|
if cfg.LIBRARY_MODULE_ENABLED and _is_library_module_path(path):
|
||||||
|
session['last_module'] = 'library'
|
||||||
return 'library'
|
return 'library'
|
||||||
if cfg.INVENTORY_MODULE_ENABLED and _is_inventory_module_path(path):
|
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'
|
return 'inventory'
|
||||||
# Default fallback:
|
|
||||||
return 'library' if cfg.LIBRARY_MODULE_ENABLED else 'inventory'
|
return 'library' if cfg.LIBRARY_MODULE_ENABLED else 'inventory'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1032,6 +1032,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if 'username' in session %}
|
||||||
{% if CURRENT_MODULE != 'library' and inventory_module_enabled %}
|
{% if CURRENT_MODULE != 'library' and inventory_module_enabled %}
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark" id="inventoryNavbar">
|
<nav class="navbar navbar-expand-lg navbar-dark" id="inventoryNavbar">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
@@ -1263,6 +1264,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
{% endif %}
|
{% 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">
|
<div class="container">
|
||||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
|
|||||||
Reference in New Issue
Block a user