From df3b224e75f6d3d94e982b245bd2d95f1725e656 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Thu, 7 Nov 2024 08:50:18 -0500 Subject: [PATCH 1/4] show list of data to add for empty viewer * rather than opening data menu --- jdaviz/app.py | 2 +- ...ta_menu_add_data.vue => data_menu_add.vue} | 0 jdaviz/components/viewer_data_select.vue | 2 +- .../default/plugins/data_menu/data_menu.py | 22 +- .../default/plugins/data_menu/data_menu.vue | 351 ++++++++++-------- jdaviz/container.vue | 10 +- 6 files changed, 204 insertions(+), 183 deletions(-) rename jdaviz/components/{data_menu_add_data.vue => data_menu_add.vue} (100%) diff --git a/jdaviz/app.py b/jdaviz/app.py index 007f907d37..6736d4b830 100644 --- a/jdaviz/app.py +++ b/jdaviz/app.py @@ -154,7 +154,7 @@ def to_unit(self, data, cid, values, original_units, target_units): 'plugin-color-picker': 'components/plugin_color_picker.vue', 'plugin-input-header': 'components/plugin_input_header.vue', 'glue-state-sync-wrapper': 'components/glue_state_sync_wrapper.vue', - 'data-menu-add-data': 'components/data_menu_add_data.vue', + 'data-menu-add': 'components/data_menu_add.vue', 'data-menu-remove': 'components/data_menu_remove.vue', 'data-menu-subset-edit': 'components/data_menu_subset_edit.vue'} diff --git a/jdaviz/components/data_menu_add_data.vue b/jdaviz/components/data_menu_add.vue similarity index 100% rename from jdaviz/components/data_menu_add_data.vue rename to jdaviz/components/data_menu_add.vue diff --git a/jdaviz/components/viewer_data_select.vue b/jdaviz/components/viewer_data_select.vue index b8fb708b58..8ea1f17474 100644 --- a/jdaviz/components/viewer_data_select.vue +++ b/jdaviz/components/viewer_data_select.vue @@ -137,7 +137,7 @@ module.exports = { return { // default to passed values, whenever value or uncertainty are changed // updateTruncatedValues will overwrite the displayed values - data_menu_open: this.$props.viewer.open_data_menu_if_empty && Object.keys(this.$props.viewer.selected_data_items).length == 0 && this.$props.data_items.length > 0, + data_menu_open: false, multi_select: multi_select, showExtraItems: Object.keys(this.$props.viewer.selected_data_items).length == 0, valueTrunc: this.value, diff --git a/jdaviz/configs/default/plugins/data_menu/data_menu.py b/jdaviz/configs/default/plugins/data_menu/data_menu.py index be6c68fd92..ba3e3ed307 100644 --- a/jdaviz/configs/default/plugins/data_menu/data_menu.py +++ b/jdaviz/configs/default/plugins/data_menu/data_menu.py @@ -67,6 +67,7 @@ class DataMenu(TemplateMixin, LayerSelectMixin, DatasetSelectMixin): dm_layer_selected = List().tag(sync=True) + loaded_n_data = Integer(0).tag(sync=True) selected_n_layers = Integer(0).tag(sync=True) selected_n_data = Integer(0).tag(sync=True) selected_n_subsets = Integer(0).tag(sync=True) @@ -135,12 +136,6 @@ def user_api(self): def existing_subset_labels(self): return [sg.label for sg in self.app.data_collection.subset_groups] - @observe('layer_items') - def _update_data_not_in_viewer(self, msg): - # changing the layers in the viewer needs to trigger an update to dataset_items - # through the set filters - self.dataset._on_data_changed() - def _set_viewer_id(self): # viewer_ids are not populated on the viewer at init, so we'll keep checking and set # these the first time that they are available @@ -180,7 +175,7 @@ def _dm_layer_selected_changed(self, event={}): # not possible from UI interaction, but instead caused by a selected # layer being removed (deleting a selected subset, etc). We want # to update dm_layer_selected in order to preserve layer.selected - self._update_dm_layer_selected(event) + self._layers_changed(event) return with self.during_select_sync(): # map index in dm_layer_selected (inverse order of layer_items) @@ -190,7 +185,7 @@ def _dm_layer_selected_changed(self, event={}): for i in self.dm_layer_selected] @observe('layer_selected', 'layer_items') - def _update_dm_layer_selected(self, event={}): + def _layers_changed(self, event={}): if not hasattr(self, 'layer') or not self.layer.multiselect: # pragma: no cover return if not self._during_select_sync: @@ -200,13 +195,18 @@ def _update_dm_layer_selected(self, event={}): self.dm_layer_selected = [layer_labels.index(label) for label in self.layer.selected if label in layer_labels] + subset_labels = self.existing_subset_labels + if event.get('name') == 'layer_items': - # don't need to make the updates below unless the selection has been changed + # changing the layers in the viewer needs to trigger an update to dataset_items + # through the set filters + self.dataset._on_data_changed() + self.loaded_n_data = len([lyr for lyr in self.layer.choices + if lyr not in subset_labels]) return # update internal counts and tooltips self.selected_n_layers = len(self.layer.selected) - subset_labels = self.existing_subset_labels self.selected_n_subsets = len([lyr for lyr in self.layer.selected if lyr in subset_labels]) self.selected_n_data = self.selected_n_layers - self.selected_n_subsets @@ -229,7 +229,7 @@ def _update_dm_layer_selected(self, event={}): # with an update self.info_enabled = False self.info_tooltip = '' - if self.layer_items[self.dm_layer_selected[0]].get('from_plugin', False): + elif self.layer_items[self.dm_layer_selected[0]].get('from_plugin', False): self.info_enabled = False self.info_tooltip = 'Selected data layer is a plugin product and does not have metadata' # noqa else: diff --git a/jdaviz/configs/default/plugins/data_menu/data_menu.vue b/jdaviz/configs/default/plugins/data_menu/data_menu.vue index c1627a09c3..514ed6614b 100644 --- a/jdaviz/configs/default/plugins/data_menu/data_menu.vue +++ b/jdaviz/configs/default/plugins/data_menu/data_menu.vue @@ -1,175 +1,198 @@