Skip to content

Feat(exercises): search options - version 1.11.0 #1170 - wger-project/wger#2279 - #1182

Closed
pankaj-basnet wants to merge 16 commits into
wger-project:masterfrom
pankaj-basnet:feat(exercises)/search-options--v-1-11-0--flutter-1170--wger-2279
Closed

pankaj-basnet wants to merge 16 commits into
wger-project:masterfrom
pankaj-basnet:feat(exercises)/search-options--v-1-11-0--flutter-1170--wger-2279

Conversation

@pankaj-basnet

Copy link
Copy Markdown
Contributor

Better search options for exercises.

Proposed Changes

  • Added toggle icon to show/hide multiple search options.

  • Added Exact Match toggle (switches API call from name__search to name__exact)

  • Added local storage logic to save user search preferences

Files created (new files):

  • lib/models/exercises/exercise_filters.dart — new data model for exercise search filters
  • lib/providers/exercise_filters_riverpod.dart — new Riverpod notifier for filter state
  • lib/providers/exercise_filters_riverpod.g.dart — auto-generated by dart run build_runner build
  • test/exercises/exercise_filters_provider_test.dart — unit tests for the notifier

Files modified (existing files):

  • lib/helpers/shared_preferences.dart — add save/get methods for exercise filter preferences
  • lib/providers/exercises.dart — update searchExercise() to accept filter params, update findByFilters() to call API with new params
  • lib/widgets/exercises/filter_row.dart — add filter button (icon that shows/hides options) similar to IngredientTypeahead.filterButton()

Django backend: No changes needed. The ExerciseFilterSet in filtersets.py now supports name__search (fulltext), name__exact (exact), language__code, and category filters via the existing exerciseinfo endpoint.

Related Issue(s)

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Set a 100-character limit to avoid white space diffs (run dart format .)
**1. ** **2. ** **3. ** **4. **
1. 2. 3. 4.

…s. Better search options - flutter , wger-project/wger#2279 . Backend version-2.5 & flutter version-1.11.0

lib/models/exercises/exercise_filters.dart          (new)
  lib/helpers/shared_preferences.dart                 (modified)
…st file

lib/providers/exercise_filters_riverpod.dart        (new)
  lib/providers/exercise_filters_riverpod.g.dart      (generated)
  test/exercises/exercise_filters_provider_test.dart  (new)
…ompleter and FilterRow

lib/widgets/exercises/autocompleter.dart            (modified)
  lib/widgets/exercises/filter_row.dart               (modified)
  lib/widgets/exercises/filter_modal.dart             (modified)
@rolandgeider

Copy link
Copy Markdown
Member

Your other older PR #1170 can be closed right?

@rolandgeider rolandgeider added the next version Incompatible changes that will be merged for the next version label Apr 23, 2026
Comment thread lib/widgets/exercises/filter_row.dart Outdated

/// The filter icon button — opens dialog with language, category, and search mode options.
/// Mirrors the filterButton() in IngredientTypeahead.
Widget _filterButton(BuildContext context) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is basically duplicated right? I would extract this to something like ExerciseFilterButton

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracting and using the _filterButton component for IngredientTypeahead and ExerciseAutocompleter might complicate code because the logic is so tightly coupled to the providers and states. if you prefer the shared widget , let me know and I will refactor it.

Comment thread lib/widgets/exercises/filter_row.dart Resolved
…ters

next, separate  the new Riverpod-based filters from the legacy filter system, as per  maintainer's review.   -  The existing Filters class in ExercisesProvider is designed for local filtering.

- It loads all exercises into memory and then uses filteredItems.where(...) to narrow them down based on Category or Equipment.

- create new searchExerciseWithSearchMode() function for (ExerciseFiltersNotifier) Riverpod-managed filters , to send data to backend for  Server-Side Filtering.
…ded searchExerciseWithSearchMode() function in exercises provider

- Integrated 'searchExerciseWithSearchMode' for exact vs. fuzzy matching, multi-language support (current vs. current+English fallback)
  and category filtering.
- Added a 'Reset' action to the filter dialog to clear all search state via the notifier.
- Switched to localized language strings (searchLanguageCurrent) as per maintainer's review/suggestion
…rovider

- Add support for PostgreSQL trigram similarity via name__search

- Add support for exact name matching via name__exact

- Implement multi-language filtering logic (current, English fallback, or all)

- Integrate category-specific filtering in search queries
…d ingredient search filters

- Create search_options.dart in models/core as per maintainer's review/suggestion

- Update imports in other Exercises modules code files to use centralized enums
- Add _sentinel to ExerciseFilters to allow explicit nulling of categories via copyWith

- Add resetAll() to ExerciseFiltersProvider to revert to default state
- Add exerciseSearchExactName and exerciseSearchExactNameSubtitle

- Add searchLanguageAll with descriptive metadata for translators
… enums

- Update imports to use models/core/search_options.dart
This reverts commit 7f3e06e.

revert commmit for fastlane metadata files ,commit undo
@pankaj-basnet

pankaj-basnet commented May 2, 2026 •

Copy link
Copy Markdown
Contributor Author
1 2 3 4
1. 2. 3. 4.

@rolandgeider

Copy link
Copy Markdown
Member

(in case you're wondering, I couldn't push to this branch and I wanted to squash these commits)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next version Incompatible changes that will be merged for the next version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants