7d51efc25e
- Add active_view and selected_comparison_directorate to app-state - Sidebar: rename to Patient Pathways + add Trust Comparison nav item - View container pattern: two view divs toggled by active_view - Navigation callback: sidebar clicks switch views + update active state - Trust Comparison placeholder landing page with tc-landing structure
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Callbacks for view switching between Patient Pathways and Trust Comparison."""
|
|
from dash import Input, Output
|
|
|
|
|
|
def register_navigation_callbacks(app):
|
|
"""Register view switching callbacks."""
|
|
|
|
@app.callback(
|
|
Output("patient-pathways-view", "style"),
|
|
Output("trust-comparison-view", "style"),
|
|
Output("nav-patient-pathways", "className"),
|
|
Output("nav-trust-comparison", "className"),
|
|
Input("app-state", "data"),
|
|
)
|
|
def switch_view(app_state):
|
|
"""Show/hide views and update sidebar active state based on active_view."""
|
|
if not app_state:
|
|
return {}, {"display": "none"}, "sidebar__item sidebar__item--active", "sidebar__item"
|
|
|
|
view = app_state.get("active_view", "patient-pathways")
|
|
show = {}
|
|
hide = {"display": "none"}
|
|
active_cls = "sidebar__item sidebar__item--active"
|
|
inactive_cls = "sidebar__item"
|
|
|
|
if view == "patient-pathways":
|
|
return show, hide, active_cls, inactive_cls
|
|
else:
|
|
return hide, show, inactive_cls, active_cls
|