Skip to content

Commit

Permalink
feat(filtering): select images button reacts to image selection set
Browse files Browse the repository at this point in the history
Disable the Select Images button when the selection set
matches the user selected images.

Closes #161
  • Loading branch information
PaulHax committed Jan 3, 2025
1 parent fe895a1 commit 88b361c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/nrtk_explorer/app/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __init__(self, server):
self.state.filter_categories = []
self.state.filter_operator = "or"
self.state.filter_not = False
self.select_clicked = False
self.state.disable_select = False

self.server.controller.add("on_server_ready")(self.on_server_ready)

Expand All @@ -50,12 +52,29 @@ def on_server_ready(self, *args, **kwargs):
self.state.change("filter_categories")(self.on_filter_categories_change)
self.state.change("filter_operator")(self.on_filter_categories_change)

# disable select button when user selects ids and enable when parameters change
self.state.change("user_selected_ids")(self.on_user_selected_ids)
self.state.change(
"filter_operator", "filter_not", "categories", "filter_categories", "dataset"
)(self.enable_select_button)

def on_select_click(self):
self.select_clicked = True
if self.state.filter_not:
self._on_apply_filter(self._not_filter)
else:
self._on_apply_filter(self._filter)

def enable_select_button(self, **kwargs):
self.state.disable_select = False

def on_user_selected_ids(self, **kwargs):
if self.select_clicked:
self.select_clicked = False
self.state.disable_select = True
else:
self.enable_select_button()

def on_filter_categories_change(self, **kwargs):
self._filter.set_ids(self.state.filter_categories, self.state.filter_operator)

Expand Down Expand Up @@ -88,6 +107,7 @@ def filter_apply_ui(self):
quasar.QBtn(
"Select Images",
click=(self.on_select_click,),
disable=("disable_select",),
flat=True,
)

Expand Down

0 comments on commit 88b361c

Please sign in to comment.