feat: add trust selection to drawer with filter wiring (Task 5.1)

This commit is contained in:
Andrew Charlwood
2026-02-06 14:09:36 +00:00
parent e8145867c1
commit f0505ee43e
10 changed files with 104 additions and 17 deletions
+36 -2
View File
@@ -1,8 +1,9 @@
"""
Drug browser drawer component using Dash Mantine Components.
Filter drawer component using Dash Mantine Components.
Provides a right-side drawer with:
- "All Drugs" section: flat alphabetical list of all drugs from pathway_nodes
- "Trusts" section: all NHS trusts from pathway_nodes for trust filtering
- Directorate cards: grouped by PrimaryDirectorate from DimSearchTerm.csv,
with Accordion items per Search_Term containing drug fragment chips
- "Clear Filters" button at the bottom
@@ -11,7 +12,7 @@ Provides a right-side drawer with:
from dash import html
import dash_mantine_components as dmc
from dash_app.data.card_browser import build_directorate_tree, get_all_drugs
from dash_app.data.card_browser import build_directorate_tree, get_all_drugs, get_all_trusts
def _make_drug_chips(drugs: list[str]) -> dmc.ChipGroup:
@@ -27,6 +28,19 @@ def _make_drug_chips(drugs: list[str]) -> dmc.ChipGroup:
)
def _make_trust_chips(trusts: list[str]) -> dmc.ChipGroup:
"""Create a ChipGroup with multiple selection for the 'Trusts' section."""
return dmc.ChipGroup(
id="trust-chips",
multiple=True,
value=[],
children=[
dmc.Chip(trust, value=trust, size="xs")
for trust in trusts
],
)
def _make_directorate_card(directorate: str, indications: dict[str, list[str]]) -> dmc.AccordionItem:
"""
Create an AccordionItem for a single directorate.
@@ -97,6 +111,7 @@ def make_drawer():
Returns a dmc.Drawer that will be opened/closed via callbacks in Phase 4.2.
"""
drugs = get_all_drugs()
trusts = get_all_trusts()
directorate_tree = build_directorate_tree()
# All Drugs section
@@ -116,6 +131,23 @@ def make_drawer():
],
)
# Trusts section
trusts_section = html.Div(
className="drawer-section",
children=[
dmc.Text("Trusts", fw=700, size="sm", className="drawer-section-title"),
dmc.Text(
f"{len(trusts)} NHS trusts",
size="xs",
c="dimmed",
),
html.Div(
className="drawer-chips-wrap",
children=_make_trust_chips(trusts),
),
],
)
# Directorate cards section
directorate_items = [
_make_directorate_card(directorate, indications)
@@ -163,6 +195,8 @@ def make_drawer():
children=[
all_drugs_section,
dmc.Divider(),
trusts_section,
dmc.Divider(),
directorate_section,
clear_button,
],