Skip to content

Commit

Permalink
Add collapse all button in toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
proy30 committed Feb 24, 2025
1 parent 7a01bf2 commit d902679
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/python/impactx/dashboard/Input/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def on_input_state_change(**_):
if state_name == "kin_energy_on_ui":
InputParameters.on_kin_energy_unit_change()

@ctrl.add("collapse_all_sections")
def on_collapse_all_sections_click():
state.expand_all_sections = not state.expand_all_sections
for collapsable_section in DashboardDefaults.COLLAPSABLE_SECTIONS:
setattr(state, collapsable_section, state.expand_all_sections)

@state.change(*DashboardDefaults.COLLAPSABLE_SECTIONS)
def on_collapsable_section_change(**kwargs):
max_height = "1000px"
Expand Down
17 changes: 17 additions & 0 deletions src/python/impactx/dashboard/Toolbar/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
state.import_file_error = False
state.importing_file = False

state.expand_all_sections = False


class ToolbarImport:
@state.change("import_file")
Expand Down Expand Up @@ -81,6 +83,18 @@ def export_button() -> vuetify.VBtn:
vuetify.VIcon("mdi-download", left=True, small=True)
html.Span("Export")

@staticmethod
def collapse_all_sections_button():
with vuetify.VBtn(
click=ctrl.collapse_all_sections,
color="primary",
icon=True,
small=True,
):
vuetify.VIcon(
v_text=("expand_all_sections ? 'mdi-collapse-all' : 'mdi-expand-all'",)
)

@staticmethod
def import_button() -> None:
"""
Expand Down Expand Up @@ -141,6 +155,7 @@ def reset_inputs_button() -> vuetify.VBtn:
click=ctrl.reset_all,
outlined=True,
small=True,
classes="mr-4",
):
vuetify.VIcon("mdi-refresh", left=True)
html.Span("Reset")
Expand Down Expand Up @@ -218,6 +233,8 @@ def dashboard_toolbar(toolbar_name: str) -> None:
InputToolbar.import_button()
InputToolbar.export_button()
InputToolbar.reset_inputs_button()
vuetify.VDivider(vertical=True, classes="mr-2")
InputToolbar.collapse_all_sections_button()
elif toolbar_name == "run":
(GeneralToolbar.dashboard_info(),)
(vuetify.VSpacer(),)
Expand Down

0 comments on commit d902679

Please sign in to comment.