Skip to content

Commit

Permalink
added buttons to select all or remove all columns in UI table (#134)
Browse files Browse the repository at this point in the history
* added buttons to select all or remove all columns in UI table

* removed UI project explorer files from test coverage
  • Loading branch information
shania-m committed Oct 26, 2021
1 parent de52092 commit bad4877
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Expand Up @@ -7,3 +7,5 @@ exclude_lines =
omit =
versioneer.py
rubicon_ml/_version.py
rubicon_ml/ui/views/project_explorer.py
rubicon_ml/ui/callbacks/project_selection.py
29 changes: 29 additions & 0 deletions rubicon_ml/ui/callbacks/project_explorer.py
Expand Up @@ -98,6 +98,7 @@ def _update_project_explorer(values):
Triggered when a project is selected in the project selection list.
"""

# if all values are 0, the user hasn't clicked a project yet
is_waiting_for_first_click = True
for value in values:
Expand Down Expand Up @@ -163,3 +164,31 @@ def _update_selected_experiment_table_rows(

# "clear all" or nothing yet is clicked: return no row indicies
return []

@app.callback(
Output({"type": "experiment-table", "index": MATCH}, "hidden_columns"),
[
Input({"type": "select-all-col-btn", "index": MATCH}, "n_clicks_timestamp"),
Input({"type": "clear-all-col-btn", "index": MATCH}, "n_clicks_timestamp"),
],
[State({"type": "experiment-table", "index": MATCH}, "columns")],
)
def _update_selected_experiment_table_cols(
last_select_col_click,
last_clear_col_click,
experiment_table_cols,
):

"""The callback to select or deselect all columns in the experiment table.
Triggered when the select all columns or clear all columns button is clicked.
"""

last_select_col_click = last_select_col_click if last_select_col_click else 0
last_clear_col_click = last_clear_col_click if last_clear_col_click else 0

if int(last_select_col_click) >= int(last_clear_col_click):
return []
# "clear all" or nothing yet is clicked: return no row indicies
ret = [i["id"] for i in experiment_table_cols if i["id"] != "id"]
return ret
13 changes: 13 additions & 0 deletions rubicon_ml/ui/views/project_explorer.py
Expand Up @@ -149,9 +149,22 @@ def make_individual_project_explorer_layout(rubicon_model, commit_hash, page_siz
),
html.Button(
"Clear All",
style={"margin-left": "10px"},
id={"type": "clear-all-btn", "index": id},
className="btn-progressive",
),
html.Button(
"Select All Columns",
style={"margin-left": "10px"},
id={"type": "select-all-col-btn", "index": id},
className="btn-progressive",
),
html.Button(
"Clear All Columns",
style={"margin-left": "10px"},
id={"type": "clear-all-col-btn", "index": id},
className="btn-progressive",
),
],
)

Expand Down

0 comments on commit bad4877

Please sign in to comment.