feat: add trust selection to drawer with filter wiring (Task 5.1)
This commit is contained in:
@@ -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,
|
||||
],
|
||||
|
||||
@@ -47,7 +47,9 @@ def make_sidebar():
|
||||
_sidebar_item(
|
||||
"Drug Selection", "drug", item_id="sidebar-drug-selection"
|
||||
),
|
||||
_sidebar_item("Trust Selection", "trust"),
|
||||
_sidebar_item(
|
||||
"Trust Selection", "trust", item_id="sidebar-trust-selection"
|
||||
),
|
||||
_sidebar_item("Directory Selection", "directory"),
|
||||
_sidebar_item(
|
||||
"Indications", "indication", item_id="sidebar-indications"
|
||||
|
||||
Reference in New Issue
Block a user