Improve shift report mode navigation

This commit is contained in:
admin committed 2026-10-20 15:19:07 +02:00
1 parent dcde029bc7
commit 211fb45d52
5 files changed
+61 -3

No files matched your search

@@ -0,0 +1,29 @@
"""Shared, server-rendered navigation between the two web workflows."""
from typing import Literal
Mode = Literal["shift", "order"]
MODE_NAV_CSS = """
.mode-nav{display:inline-flex;gap:.25rem;padding:.25rem;margin-bottom:1rem;
background:#e8eef3;border:1px solid #aab9c5;border-radius:.55rem}
.mode-nav a{display:block;padding:.55rem .85rem;border:1px solid transparent;
border-radius:.35rem;color:#182c3b;font-weight:600;text-decoration:none}
.mode-nav a:hover{background:#d4e0e9}
.mode-nav a[aria-current="page"]{background:#294d67;border-color:#294d67;color:white}
.mode-nav a[aria-current="page"]:hover{background:#294d67}
.mode-nav a:focus-visible{outline:3px solid #bf6525;outline-offset:2px}
"""
def render_mode_navigation(active: Mode) -> str:
if active not in ("shift", "order"):
raise ValueError("Unknown web workflow")
links = (("shift", "/", "Schichtbericht"),
("order", "/orders", "Fertigungsauftrag"))
items = "".join(
f'<a href="{href}"' + (' aria-current="page"' if mode == active else "")
+ f">{label}</a>"
for mode, href, label in links
)
return f'<nav class="mode-nav" aria-label="Bereich wählen">{items}</nav>'
@@ -3,6 +3,10 @@
from html import escape
from urllib.parse import urlencode
from production_analytics.presentation.mode_navigation import (
MODE_NAV_CSS,
render_mode_navigation,
)
from production_analytics.service.production_order import (
ProductionOrderDetail,
ProductionOrderSearchResult,
@@ -23,8 +27,8 @@ table {{width:100%;border-collapse:collapse}} th,td {{text-align:left;padding:.7
border-bottom:1px solid #c9d1d8}} th {{background:#e8eef3}}
.table-scroll {{overflow-x:auto}} .metadata {{color:#526473;font-size:.9rem}}
.error {{padding:1rem;background:#ffe8e5;border-left:4px solid #a32920}}
</style></head><body><main><nav><a href="/">Schichtberichte</a> ·
<a href="/orders">Fertigungsauftrag suchen</a></nav>{body}</main></body></html>'''
{MODE_NAV_CSS}</style></head><body><main>{render_mode_navigation("order")}
{body}</main></body></html>'''
def _form(query: str) -> str:
@@ -3,6 +3,10 @@
from html import escape
from math import fsum
from production_analytics.presentation.mode_navigation import (
MODE_NAV_CSS,
render_mode_navigation,
)
from production_analytics.presentation.shift_report import (
MaterialPieBlock,
TableBlock,
@@ -117,7 +121,7 @@ width:220px; max-width:100%; margin:.75rem auto}}
.material-swatch {{width:.9rem; height:.9rem; flex-shrink:0; margin-top:.2rem}}
@media(max-width:850px) {{.material-layout {{grid-template-columns:minmax(0, 1fr)}}}}
.error {{padding:1rem; background:#ffe8e5; border-left:4px solid #a32920}}
</style></head><body><main><nav><a href="/orders">Fertigungsauftrag suchen</a></nav>
{MODE_NAV_CSS}</style></head><body><main>{render_mode_navigation("shift")}
<h1>Live-Schichtberichte</h1>
<form method="get" action="/">
<label>Datum (Schichtbeginn)<input type="date" name="date" required