Skip to content

Commit

Permalink
Bugfix in VolumetricAnalysis to trigger callbacks on page refresh (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tnatt authored Aug 31, 2021
1 parent ec5aad3 commit b12c3d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def selections_controllers(
State(get_uuid("page-selected"), "data"),
State(get_uuid("tabs"), "value"),
State(get_uuid("selections"), "data"),
State(get_uuid("initial-load-info"), "data"),
State({"id": get_uuid("selections"), "tab": ALL, "selector": ALL}, "id"),
State({"id": get_uuid("filters"), "tab": ALL, "selector": ALL}, "id"),
)
Expand All @@ -33,6 +34,7 @@ def _update_selections(
selected_page: str,
selected_tab: str,
previous_selection: dict,
initial_load: dict,
selector_ids: list,
filter_ids: list,
) -> dict:
Expand All @@ -57,7 +59,9 @@ def _update_selections(
page_selections.update(Colorscale=colorscale)
page_selections.update(ctx_clicked=ctx["prop_id"])

if previous_selection.get(selected_page) is None:
# check if a page needs to be updated due to page refresh or
# change in selections/filters
if initial_load[selected_page]:
page_selections.update(update=True)
else:
equal_list = []
Expand All @@ -71,6 +75,17 @@ def _update_selections(
previous_selection[selected_page] = page_selections
return previous_selection

@app.callback(
Output(get_uuid("initial-load-info"), "data"),
Input(get_uuid("page-selected"), "data"),
State(get_uuid("initial-load-info"), "data"),
)
def _store_initial_load_info(page_selected: str, initial_load: dict) -> dict:
if initial_load is None:
initial_load = {}
initial_load[page_selected] = page_selected not in initial_load
return initial_load

@app.callback(
Output(
{"id": get_uuid("selections"), "tab": "voldist", "selector": ALL},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ def clientside_stores(get_uuid: Callable) -> html.Div:
"""Contains the clientside stores"""
return html.Div(
children=[
dcc.Store(id=get_uuid("filter-voldist"), storage_type="session"),
dcc.Store(id=get_uuid("selections"), storage_type="session"),
dcc.Store(id=get_uuid("page-selected"), storage_type="session"),
dcc.Store(id=get_uuid("voldist-page-selected"), storage_type="session"),
dcc.Store(id=get_uuid("test"), storage_type="session"),
dcc.Store(id=get_uuid("initial-load-info"), storage_type="memory"),
html.Div(
style={"display": "none"},
children=dcc.Download(id=get_uuid("download-dataframe")),
Expand Down

0 comments on commit b12c3d1

Please sign in to comment.