feat: add Trends sidebar nav item + 3-view switching (Task E.2)

This commit is contained in:
Andrew Charlwood
2026-02-07 22:12:13 +00:00
parent 956ad8ca7b
commit 190aefdf56
5 changed files with 40 additions and 17 deletions
+5 -1
View File
@@ -75,13 +75,14 @@ def register_filter_callbacks(app):
Input("trust-chips", "value"),
Input("nav-patient-pathways", "n_clicks"),
Input("nav-trust-comparison", "n_clicks"),
Input("nav-trends", "n_clicks"),
Input({"type": "tc-selector", "index": ALL}, "n_clicks"),
Input("tc-back-btn", "n_clicks"),
State("app-state", "data"),
)
def update_app_state(
_dir_clicks, _ind_clicks, initiated, last_seen, selected_drugs,
selected_trusts, _nav_pp_clicks, _nav_tc_clicks,
selected_trusts, _nav_pp_clicks, _nav_tc_clicks, _nav_trends_clicks,
_tc_selector_clicks, _tc_back_clicks, current_state
):
"""Update app-state when any filter, nav, or TC selector changes."""
@@ -96,6 +97,7 @@ def register_filter_callbacks(app):
"selected_trusts": [],
"active_view": "patient-pathways",
"selected_comparison_directorate": None,
"selected_trends_directorate": None,
}
triggered_id = ctx.triggered_id
@@ -114,6 +116,8 @@ def register_filter_callbacks(app):
active_view = "patient-pathways"
elif triggered_id == "nav-trust-comparison":
active_view = "trust-comparison"
elif triggered_id == "nav-trends":
active_view = "trends"
# Trust Comparison directorate selection
selected_comparison_directorate = current_state.get("selected_comparison_directorate")
+13 -8
View File
@@ -1,4 +1,4 @@
"""Callbacks for view switching between Patient Pathways and Trust Comparison."""
"""Callbacks for view switching between Patient Pathways, Trust Comparison, and Trends."""
from dash import Input, Output
@@ -8,22 +8,27 @@ def register_navigation_callbacks(app):
@app.callback(
Output("patient-pathways-view", "style"),
Output("trust-comparison-view", "style"),
Output("trends-view", "style"),
Output("nav-patient-pathways", "className"),
Output("nav-trust-comparison", "className"),
Output("nav-trends", "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 not app_state:
return show, hide, hide, active_cls, inactive_cls, inactive_cls
view = app_state.get("active_view", "patient-pathways")
if view == "patient-pathways":
return show, hide, active_cls, inactive_cls
else:
return hide, show, inactive_cls, active_cls
return show, hide, hide, active_cls, inactive_cls, inactive_cls
elif view == "trust-comparison":
return hide, show, hide, inactive_cls, active_cls, inactive_cls
else: # trends
return hide, hide, show, inactive_cls, inactive_cls, active_cls