Add vegan/vegetarian filter toggles to ingredient autocompleter#1197
Open
stuckvgn wants to merge 1 commit intowger-project:masterfrom
Open
Add vegan/vegetarian filter toggles to ingredient autocompleter#1197stuckvgn wants to merge 1 commit intowger-project:masterfrom
stuckvgn wants to merge 1 commit intowger-project:masterfrom
Conversation
5 tasks
Member
|
you're on fire! I'll try to look at this later |
Member
Contributor
Author
|
The PR has been updated to align with the approach you implemented — filters are in a popup (Popover with TuneIcon), and labels use 'Vegan' / 'Vegetarian' without 'only'. Also added the missing |
Contributor
Author
|
Closing this PR — on reflection, this change may not be the right fit for this project. Thanks for your time! |
Contributor
Author
|
Apologies for the accidental close — this has your feedback incorporated and is ready for review. |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Companion frontend to wger-project/wger#2218, which adds
is_veganandis_vegetarianfields to theIngredientmodel and exposes them via theingredientinfoAPI endpoint.This PR surfaces those fields in the meal form ingredient search so users can filter results by dietary preference directly in the autocompleter.
Changes:
ApiIngredientType— addis_vegan: boolean | nullandis_vegetarian: boolean | nullIngredientmodel — addisVegan/isVegetarianproperties with adapter mapping from JSONsearchIngredient()service — accept optionalisVegan/isVegetarianparams, passed as?is_vegan=true/?is_vegetarian=truequery params to theingredientinfoAPIIngredientAutocompleter— add "Vegan only" and "Vegetarian only"Switchtoggles rendered as a row below the search input; toggling either filter immediately re-triggers searchnutrition.filterVeganandnutrition.filterVegetariantranslation keysBehaviour
When both toggles are off (default), search behaves exactly as before — no dietary filter params are sent. Enabling a toggle appends
?is_vegan=trueor?is_vegetarian=trueto the API query. Both can be enabled simultaneously.Ingredients with
NULLdietary status (unknown) are excluded when a filter is active, since the API uses exact matching (True/False/NULL).Dependencies
Requires wger-project/wger#2218 to be merged and the
ingredientinfoAPI to returnis_vegan/is_vegetarianfields. The autocompleter degrades gracefully before that — the new fields will just benullon all ingredients and the toggle UI still renders, it just won't filter anything until the backend lands.