From 55e29925598e0b6e790d6f59d8c0962b4886fe71 Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Mon, 2 Feb 2026 19:51:09 +0100 Subject: [PATCH] id table => tableau_datatable --- src/pages/tableau.py | 46 ++++++++++++++++++++++---------------------- src/utils.py | 7 +++---- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/pages/tableau.py b/src/pages/tableau.py index ab95c80..a64b0e3 100644 --- a/src/pages/tableau.py +++ b/src/pages/tableau.py @@ -54,7 +54,7 @@ register_page( datatable = html.Div( className="marches_table", children=DataTable( - dtid="table", + dtid="tableau_datatable", page_size=20, page_action="custom", filter_action="custom", @@ -276,19 +276,19 @@ layout = [ @callback( - Output("table", "data"), - Output("table", "columns"), - Output("table", "tooltip_header"), - Output("table", "data_timestamp"), + Output("tableau_datatable", "data"), + Output("tableau_datatable", "columns"), + Output("tableau_datatable", "tooltip_header"), + Output("tableau_datatable", "data_timestamp"), Output("nb_rows", "children"), Output("btn-download-data", "disabled"), Output("btn-download-data", "children"), Output("btn-download-data", "title"), - Input("table", "page_current"), - Input("table", "page_size"), + Input("tableau_datatable", "page_current"), + Input("tableau_datatable", "page_size"), Input("tableau-filters", "data"), Input("tableau-sort", "data"), - State("table", "data_timestamp"), + State("tableau_datatable", "data_timestamp"), ) def update_table(page_current, page_size, filter_query, sort_by, data_timestamp): # if ctx.triggered_id != "url": @@ -303,9 +303,9 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp) @callback( Output("download-data", "data"), Input("btn-download-data", "n_clicks"), - State("table", "filter_query"), - State("table", "sort_by"), - State("table", "hidden_columns"), + State("tableau_datatable", "filter_query"), + State("tableau_datatable", "sort_by"), + State("tableau_datatable", "hidden_columns"), prevent_initial_call=True, ) def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None): @@ -329,8 +329,8 @@ def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None): @callback( - Output("table", "filter_query"), - Output("table", "sort_by"), + Output("tableau_datatable", "filter_query"), + Output("tableau_datatable", "sort_by"), Output("tableau-hidden-columns", "data"), Output("tableau_url", "search"), Output("filter-cleanup-trigger", "data"), @@ -389,9 +389,9 @@ clientside_callback( @callback( Output("share-url", "value"), Output("copy-container", "children"), - Input("table", "filter_query"), - Input("table", "sort_by"), - Input("table", "hidden_columns"), + Input("tableau_datatable", "filter_query"), + Input("tableau_datatable", "sort_by"), + Input("tableau_datatable", "hidden_columns"), State("tableau_url", "href"), prevent_initial_call=True, ) @@ -473,7 +473,7 @@ def update_hidden_columns_from_checkboxes(selected_columns): @callback( - Output("table", "hidden_columns"), + Output("tableau_datatable", "hidden_columns"), Input( "tableau-hidden-columns", "data", @@ -485,11 +485,11 @@ def store_hidden_columns(hidden_columns): @callback( Output("tableau_column_list", "selected_rows"), - Input("table", "hidden_columns"), + Input("tableau_datatable", "hidden_columns"), State("tableau_column_list", "selected_rows"), # pour éviter la boucle infinie ) def update_checkboxes_from_hidden_columns(hidden_cols, current_checkboxes): - hidden_cols = hidden_cols or get_default_hidden_columns(None) + hidden_cols = hidden_cols or get_default_hidden_columns("tableau") # Show all columns that are NOT hidden visible_cols = [columns.index(col) for col in columns if col not in hidden_cols] @@ -508,19 +508,19 @@ def toggle_tableau_columns(click_open, click_close, is_open): return is_open -@callback(Output("tableau-filters", "data"), Input("table", "filter_query")) +@callback(Output("tableau-filters", "data"), Input("tableau_datatable", "filter_query")) def sync_filters_to_local_storage(filter_query): return filter_query -@callback(Output("tableau-sort", "data"), Input("table", "sort_by")) +@callback(Output("tableau-sort", "data"), Input("tableau_datatable", "sort_by")) def sync_sort_to_local_storage(sort_by): return sort_by @callback( - Output("table", "filter_query", allow_duplicate=True), - Output("table", "sort_by", allow_duplicate=True), + Output("tableau_datatable", "filter_query", allow_duplicate=True), + Output("tableau_datatable", "sort_by", allow_duplicate=True), Input("btn-tableau-reset", "n_clicks"), prevent_initial_call=True, ) diff --git a/src/utils.py b/src/utils.py index f870f56..bcb62a6 100644 --- a/src/utils.py +++ b/src/utils.py @@ -428,12 +428,11 @@ def get_default_hidden_columns(page): "codeCPV", "dureeRestanteMois", ] + elif page == "titulaire": + displayed_columns = os.getenv("DISPLAYED_COLUMNS") else: displayed_columns = os.getenv("DISPLAYED_COLUMNS") - if displayed_columns is None: - raise ValueError("DISPLAYED_COLUMNS n'est pas configuré") - else: - displayed_columns = displayed_columns.replace(" ", "").split(",") + logger.warning(f"Invalid page: {page}") hidden_columns = []