Skip to content

Commit

Permalink
open_menu() method
Browse files Browse the repository at this point in the history
to programmatically open the viewer in any existing viewer instances
  • Loading branch information
kecnry committed Nov 13, 2024
1 parent 1626bac commit 278c4df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jdaviz/configs/default/plugins/data_menu/data_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DataMenu(TemplateMixin, LayerSelectMixin, DatasetSelectMixin):
Only the following attributes and methods are available through the
:ref:`public API <plugin-apis>`:
* :meth:`open_menu`
* ``layer`` (:class:`~jdaviz.core.template_mixin.LayerSelect`):
actively selected layer(s)
* ``orientation`` (:class:`~jdaviz.core.template_mixin.LayerSelect`):
Expand All @@ -57,6 +58,8 @@ class DataMenu(TemplateMixin, LayerSelectMixin, DatasetSelectMixin):
"""
template_file = __file__, "data_menu.vue"

force_open_menu = Bool(False).tag(sync=True)

viewer_id = Unicode().tag(sync=True)
viewer_reference = Unicode().tag(sync=True)

Expand Down Expand Up @@ -146,13 +149,19 @@ def data_not_in_viewer(data):

@property
def user_api(self):
expose = ['layer', 'set_layer_visibility', 'toggle_layer_visibility',
expose = ['open_menu', 'layer', 'set_layer_visibility', 'toggle_layer_visibility',
'create_subset', 'modify_subset', 'add_data', 'view_info',
'remove_from_viewer', 'remove_from_app']
if self.app.config == 'imviz':
expose += ['orientation']
return UserApiWrapper(self, expose=expose)

def open_menu(self):
"""
Open all instances of the data menu.
"""
self.force_open_menu = True

@property
def existing_subset_labels(self):
return [sg.label for sg in self.app.data_collection.subset_groups]
Expand Down
8 changes: 8 additions & 0 deletions jdaviz/configs/default/plugins/data_menu/data_menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@
element = element.parentElement;
}
},
watch: {
force_open_menu: function (val) {
if (val) {
this.data_menu_open = true;
this.force_open_menu = false;
}
}
},
methods: {
onScroll(e) {
const dataMenuHeight = document.getElementById(`layer-legend-${this.viewer_id}`).parentElement.getBoundingClientRect().height
Expand Down

0 comments on commit 278c4df

Please sign in to comment.