Skip to content

Commit

Permalink
mobility update
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrein committed Jan 15, 2022
1 parent fdd112e commit e6610f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
5 changes: 3 additions & 2 deletions website/dashmap/layouts/tab_mobility/main_mobility.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def init_tab_mobility() -> object:
html.P(
"""
Geographic mobility is the measure of how populations and goods move over time.
Population mobility has a large impact on many sociological factors in a society and has implications ranging
from impacts on local economic growth to housing markets and demand for regional services.
Population mobility has a large impact on many sociological factors in a society and has
implications ranging from impacts on local economic growth to housing markets and demand
for regional services.
""",
className="card-text"
),
Expand Down
17 changes: 1 addition & 16 deletions website/dashmap/layouts/tab_mobility/mobility.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,10 @@ def init_mobility_accordion():
group_n=2
)

accord_3 = init_accordion_element(
title="Coming Soon!",
graph_id='id_tram_accordion',
tab_n=4,
group_n=3
)

accord_4 = init_accordion_element(
title="Coming Soon!",
graph_id='id_bikes_accordion',
tab_n=4,
group_n=4
)

mobility_accordion = [
accord_1,
accord_2,
accord_3,
accord_4

]

return assemble_accordion(mobility_accordion)
20 changes: 8 additions & 12 deletions website/dashmap/map_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ def toggle_accordion(n1, n2, is_open1, is_open2):

# Tab Mobility Section Accordion CallBacks
@dash_app.callback(
[Output(f"tab-4-collapse-{i}", "is_open") for i in range(1, 5)],
[Input(f"tab-4-group-{i}-toggle", "n_clicks") for i in range(1, 5)],
[State(f"tab-4-collapse-{i}", "is_open") for i in range(1, 5)],
[Output(f"tab-4-collapse-{i}", "is_open") for i in range(1, 3)],
[Input(f"tab-4-group-{i}-toggle", "n_clicks") for i in range(1, 3)],
[State(f"tab-4-collapse-{i}", "is_open") for i in range(1, 3)],
)
def toggle_accordion(n1, n2, n3, n4, is_open1, is_open2, is_open3, is_open4):
def toggle_accordion(n1, n2, is_open1, is_open2):
"""
Toggle accordion collapse & expand.
---
Expand All @@ -273,20 +273,16 @@ def toggle_accordion(n1, n2, n3, n4, is_open1, is_open2, is_open3, is_open4):
ctx = dash.callback_context

if not ctx.triggered:
return False, False, False, False
return False, False
else:
button_id = ctx.triggered[0]["prop_id"].split(".")[0]

if button_id == "tab-4-group-1-toggle" and n1:
return not is_open1, False, False, False
return not is_open1, False
elif button_id == "tab-4-group-2-toggle" and n2:
return False, not is_open2, False, False
elif button_id == "tab-4-group-3-toggle" and n3:
return False, False, not is_open3, False
elif button_id == "tab-4-group-4-toggle" and n4:
return False, False, False, not is_open4
return False, not is_open2

return False, False, False, False
return False, False

# Tab Environment Section Accordion CallBacks
@dash_app.callback(
Expand Down

0 comments on commit e6610f1

Please sign in to comment.