feat: sync_observatoire_share_url encodes all 17 filter params
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -585,22 +585,29 @@ def restore_filters(search, _pathname, stored_filters):
|
|||||||
@callback(
|
@callback(
|
||||||
Output("observatoire-share-url", "value"),
|
Output("observatoire-share-url", "value"),
|
||||||
Output("observatoire-copy-container", "children"),
|
Output("observatoire-copy-container", "children"),
|
||||||
Input("dashboard_acheteur_id", "value"),
|
*[Input(fp[0], "value") for fp in FILTER_PARAMS],
|
||||||
Input("dashboard_titulaire_id", "value"),
|
|
||||||
State("dashboard_url", "href"),
|
State("dashboard_url", "href"),
|
||||||
prevent_initial_call=True,
|
prevent_initial_call=True,
|
||||||
)
|
)
|
||||||
def sync_observatoire_share_url(acheteur_id, titulaire_id, href):
|
def sync_observatoire_share_url(*args):
|
||||||
|
# Last arg is href (State), rest are filter values
|
||||||
|
filter_values = args[:-1]
|
||||||
|
href = args[-1]
|
||||||
|
|
||||||
if not href:
|
if not href:
|
||||||
return no_update, no_update
|
return no_update, no_update
|
||||||
|
|
||||||
base_url = href.split("?")[0]
|
base_url = href.split("?")[0]
|
||||||
|
|
||||||
params = {}
|
params = []
|
||||||
if acheteur_id:
|
for (_, url_key, is_multi, default), value in zip(FILTER_PARAMS, filter_values):
|
||||||
params["acheteur_id"] = acheteur_id
|
if value is None or value == default or value == [] or value == "":
|
||||||
if titulaire_id:
|
continue
|
||||||
params["titulaire_id"] = titulaire_id
|
if is_multi and isinstance(value, list):
|
||||||
|
for v in value:
|
||||||
|
params.append((url_key, v))
|
||||||
|
else:
|
||||||
|
params.append((url_key, value))
|
||||||
|
|
||||||
query_string = urllib.parse.urlencode(params)
|
query_string = urllib.parse.urlencode(params)
|
||||||
full_url = f"{base_url}?{query_string}" if query_string else base_url
|
full_url = f"{base_url}?{query_string}" if query_string else base_url
|
||||||
|
|||||||
Reference in New Issue
Block a user