Skip to content

Fix class filter selection in WebUI - #854

Merged
briemla merged 9 commits into
mainfrom
webui/02-class-filter-selection
Oct 15, 2026
Merged

briemla merged 9 commits into
mainfrom
webui/02-class-filter-selection

Conversation

@briemla

@briemla briemla commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

OP#10513

Problem

The class filter dialog of the WebUI (visualization_filters_form/container.py, open_classification_dialog) did not work:

  • The checkboxes were created but never built, so the dialog showed only the "Apply" button.
  • The on_value_change lambda bound the loop variable late, so every checkbox toggled the last class.
  • The internal class list always started with all classes, regardless of the current selection (get_class_filter_selection()). With a partial selection, "Apply" also passed classes whose checkbox was not checked.

Solution

  • The dialog is moved into its own class FilterClassificationForm (analogous to FilterDateRangeForm).
  • Its state is derived from the current class filter selection. If there is no selection (None), all classes are selected, as in the customtkinter GUI. An empty selection ([]) now shows no class checked, which also matches the customtkinter GUI (previously it was treated like "all").
  • Each checkbox is bound to its own class and evaluates the checkbox value instead of toggling.
  • "Apply" passes exactly the checked classes, in the order of get_classes(), and closes the dialog.
  • Buttons are built in _build_buttons, so a follow-up PR can add the reset button there (PR 6, webui/06-class-filter-reset, builds on this branch). The "Apply" label is still hard-coded; PR 6 moves it to the ResourceManager.

Tests

  • New unit tests in tests/unit/OTAnalytics/plugin_ui/nicegui_gui/pages/visualization_filters_form/test_container.py (NiceGUI User fixture):
    • toggling a checkbox changes only its own class (unchecking and checking)
    • applying an unchanged partial selection passes exactly that selection
    • without a selection all classes are checked and applied
    • an empty selection checks no class
    • "Apply" closes the dialog
  • The new tests fail on main (5 of 6) and pass with this change.
  • pytest tests/unit/OTAnalytics/plugin_ui: 220 passed, 5 skipped
  • pre-commit run --all-files: flake8, black, isort and mypy pass

🤖 Generated with Claude Code

briemla and others added 4 commits October 13, 2026 13:43
The tests describe the expected behaviour of the class filter dialog:
each checkbox toggles only its own class, an unchanged partial selection
is applied as is, and without a selection all classes are checked.
They fail until the dialog is fixed in the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dialog never rendered its checkboxes, bound every checkbox to the
last class created in the loop and always started from all classes, so
"Apply" also passed classes that were not selected.

Move the dialog into FilterClassificationForm, which derives its state
from the current class filter selection (all classes if there is none,
as in the customtkinter GUI), binds each checkbox to its own class and
evaluates the checkbox value instead of toggling. Buttons are built in a
dedicated method so further buttons can be added easily.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The class filter dialog now offers a Reset button that resets the class
filter via the view model and closes the dialog, as in the customtkinter
GUI. Apply and Reset take their labels from the ResourceManager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread OTAnalytics/plugin_ui/nicegui_gui/pages/visualization_filters_form/container.py Outdated
Comment thread OTAnalytics/plugin_ui/nicegui_gui/pages/visualization_filters_form/container.py Outdated
@briemla
briemla enabled auto-merge October 15, 2026 07:20
@briemla
briemla requested a review from schubsen October 15, 2026 07:20
@briemla
briemla merged commit ac82809 into main Oct 15, 2026
15 checks passed
@briemla
briemla deleted the webui/02-class-filter-selection branch October 15, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants