feat: restore_filters reads all 17 filter params from URL
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+40
-22
@@ -514,6 +514,28 @@ Alors, on fait comment ?
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
FILTER_PARAMS = [
|
||||||
|
# (component_id, url_key, is_multi, default_value)
|
||||||
|
("dashboard_year", "annee", False, None),
|
||||||
|
("dashboard_acheteur_id", "acheteur_id", False, None),
|
||||||
|
("dashboard_acheteur_categorie", "acheteur_cat", False, None),
|
||||||
|
("dashboard_acheteur_departement_code", "acheteur_dept", True, None),
|
||||||
|
("dashboard_titulaire_id", "titulaire_id", False, None),
|
||||||
|
("dashboard_titulaire_categorie", "titulaire_cat", False, None),
|
||||||
|
("dashboard_titulaire_departement_code", "titulaire_dept", True, None),
|
||||||
|
("dashboard_marche_type", "type", False, None),
|
||||||
|
("dashboard_marche_objet", "objet", False, None),
|
||||||
|
("dashboard_marche_code_cpv", "cpv", False, None),
|
||||||
|
("dashboard_montant_min", "montant_min", False, None),
|
||||||
|
("dashboard_montant_max", "montant_max", False, None),
|
||||||
|
("dashboard_marche_techniques", "techniques", True, None),
|
||||||
|
("dashboard_marche_innovant", "innovant", False, "all"),
|
||||||
|
("dashboard_marche_sousTraitanceDeclaree", "sous_traitance", False, "all"),
|
||||||
|
("dashboard_marche_considerationsSociales", "social", True, None),
|
||||||
|
("dashboard_marche_considerationsEnvironnementales", "env", True, None),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output("dashboard_year", "value"),
|
Output("dashboard_year", "value"),
|
||||||
Output("dashboard_acheteur_id", "value"),
|
Output("dashboard_acheteur_id", "value"),
|
||||||
@@ -539,28 +561,24 @@ Alors, on fait comment ?
|
|||||||
def restore_filters(search, _pathname, stored_filters):
|
def restore_filters(search, _pathname, stored_filters):
|
||||||
if search:
|
if search:
|
||||||
params = urllib.parse.parse_qs(search.lstrip("?"))
|
params = urllib.parse.parse_qs(search.lstrip("?"))
|
||||||
acheteur_id = (params.get("acheteur_id") or [None])[0] or None
|
known_keys = {fp[1] for fp in FILTER_PARAMS}
|
||||||
titulaire_id = (params.get("titulaire_id") or [None])[0] or None
|
if any(k in params for k in known_keys):
|
||||||
if acheteur_id or titulaire_id:
|
values = []
|
||||||
return (
|
for _comp_id, url_key, is_multi, default in FILTER_PARAMS:
|
||||||
None,
|
if url_key in params:
|
||||||
acheteur_id,
|
if is_multi:
|
||||||
None,
|
values.append(params[url_key])
|
||||||
None,
|
else:
|
||||||
titulaire_id,
|
raw = params[url_key][0]
|
||||||
None,
|
if url_key in ("montant_min", "montant_max"):
|
||||||
None,
|
try:
|
||||||
None,
|
raw = float(raw)
|
||||||
None,
|
except (ValueError, TypeError):
|
||||||
None,
|
raw = None
|
||||||
None,
|
values.append(raw)
|
||||||
None,
|
else:
|
||||||
None,
|
values.append(default)
|
||||||
None,
|
return tuple(values)
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
return (no_update,) * 17
|
return (no_update,) * 17
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user