Skip to content

Commit

Permalink
deselect all
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Jan 9, 2025
1 parent 4392488 commit 3f35b90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jdaviz/configs/imviz/plugins/catalogs/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Catalogs(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect, Tabl
def user_api(self):
return PluginUserApi(self, expose=('clear_table', 'export_table',
'zoom_to_selected', 'select_rows',
'select_all'))
'select_all', 'deselect_all'))

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
5 changes: 5 additions & 0 deletions jdaviz/configs/imviz/tests/test_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,8 @@ def test_select_catalog_table_rows(imviz_helper, image_2d_wcs, tmp_path):
# test select_all
catalogs_plugin.select_all()
assert len(plugin_table.selected_rows) == 6

# test deselect all
catalogs_plugin.deselect_all()
assert len(plugin_table.selected_rows) == 0

11 changes: 10 additions & 1 deletion jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4714,7 +4714,8 @@ def __init__(self, plugin, name='table', selected_rows_changed_callback=None,
@property
def user_api(self):
return UserApiWrapper(self, ('clear_table', 'export_table',
'select_rows', 'select_all'))
'select_rows', 'select_all',
'deselect_all'))

def default_value_for_column(self, colname=None, value=None):
if colname in self._default_values_by_colname:
Expand Down Expand Up @@ -4865,6 +4866,10 @@ def select_all(self):
""" Select all rows in table."""
self.select_rows(slice(0, len(self) + 1))

def deselect_all(self):
""" Deselect all rows in table."""
self.selected_rows = []

def vue_clear_table(self, data=None):
# if the plugin (or via the TableMixin) has its own clear_table implementation,
# call that, otherwise call the one defined here
Expand Down Expand Up @@ -4957,6 +4962,10 @@ def select_all(self):
""" Select all rows in table."""
self.table.select_all()

def deselect_all(self):
""" Deselect all rows in table."""
self.table.deselect_all()


class Plot(PluginSubcomponent):
"""
Expand Down

0 comments on commit 3f35b90

Please sign in to comment.