From bd64c397dc738aace18619d3a6a86f6b86369adc Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Sat, 24 Jan 2026 14:35:12 +0100 Subject: [PATCH] =?UTF-8?q?Namespacing=20des=20dcc.Location=20pour=20?= =?UTF-8?q?=C3=A9viter=20les=20conflits=20entre=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/marche.py | 4 ++-- src/pages/tableau.py | 9 +++++---- src/pages/titulaire.py | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pages/marche.py b/src/pages/marche.py index 0e17c15..d23dec9 100644 --- a/src/pages/marche.py +++ b/src/pages/marche.py @@ -25,7 +25,7 @@ register_page( layout = [ dcc.Store(id="marche_data"), dcc.Store(id="titulaires_data"), - dcc.Location(id="url", refresh="callback-nav"), + dcc.Location(id="marche_url", refresh="callback-nav"), dbc.Container( className="marche_infos", children=[ @@ -73,7 +73,7 @@ layout = [ @callback( Output("marche_data", "data"), Output("titulaires_data", "data"), - Input(component_id="url", component_property="pathname"), + Input(component_id="marche_url", component_property="pathname"), ) def get_marche_data(url) -> tuple[dict, list]: marche_uid = url.split("/")[-1] diff --git a/src/pages/tableau.py b/src/pages/tableau.py index 5967e29..35bdfc9 100644 --- a/src/pages/tableau.py +++ b/src/pages/tableau.py @@ -47,7 +47,7 @@ datatable = html.Div( ) layout = [ - dcc.Location(id="url", refresh=False), + dcc.Location(id="tableau_url", refresh=False), html.Div( html.Details( children=[ @@ -190,8 +190,8 @@ def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None): Output("table", "filter_query"), Output("table", "sort_by"), Output("table", "hidden_columns"), - Output("url", "search", allow_duplicate=True), - Input("url", "search"), + Output("tableau_url", "search", allow_duplicate=True), + Input("tableau_url", "search"), prevent_initial_call=True, ) def restore_view_from_url(search): @@ -228,7 +228,8 @@ def restore_view_from_url(search): Input("table", "filter_query"), Input("table", "sort_by"), Input("table", "hidden_columns"), - State("url", "href"), + State("tableau_url", "href"), + prevent_initial_call=True, ) def sync_url_and_reset_button(filter_query, sort_by, hidden_columns, href): if not href: diff --git a/src/pages/titulaire.py b/src/pages/titulaire.py index 393907b..a17e505 100644 --- a/src/pages/titulaire.py +++ b/src/pages/titulaire.py @@ -47,7 +47,7 @@ datatable = html.Div( layout = [ dcc.Store(id="titulaire_data", storage_type="memory"), - dcc.Location(id="url", refresh="callback-nav"), + dcc.Location(id="titulaire_url", refresh="callback-nav"), html.Div( children=[ html.Div( @@ -152,7 +152,7 @@ layout = [ Output(component_id="titulaire_departement", component_property="children"), Output(component_id="titulaire_region", component_property="children"), Output(component_id="titulaire_lien_annuaire", component_property="href"), - Input(component_id="url", component_property="pathname"), + Input(component_id="titulaire_url", component_property="pathname"), ) def update_titulaire_infos(url): titulaire_siret = url.split("/")[-1] @@ -219,7 +219,7 @@ def update_titulaire_stats(data): Output("btn-download-data-titulaire", "disabled"), Output("btn-download-data-titulaire", "children"), Output("btn-download-data-titulaire", "title"), - Input(component_id="url", component_property="pathname"), + Input(component_id="titulaire_url", component_property="pathname"), Input(component_id="titulaire_year", component_property="value"), ) def get_titulaire_marches_data(url, titulaire_year: str) -> tuple: