-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Variant Searcher for Autocomplete #4197
Use Variant Searcher for Autocomplete #4197
Conversation
Our admin has already mostly moved over to using the new search class in a few places. This adds it as an option to the API index endpoint. After this change, we'll be able to update our autocomplete JS logic to use the new search object instead of the hardcoded ransack queries it currently does. Eventually allowing us a much easier configuration interface we can use to ensure the variant searching works for all users who wan't to tweak it to include other search fields. (e.g.: Globalize wants to search different translated columns.) The existing behaviour is also easy enough to keep in, which prevents us from having to make a breaking change.
Instead of trying to generate some hardcoded Ransack search values, we can use the APIs ability to use our Search::Variant class instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally fine with merging this in a minor release since it preserves the old behaviour even if you have weird overrides.
Excellent idea, but I'm not entirely sure about the implementation. What about creating another |
@waiting-for-dev I'm not sure I follow. The default |
@adammathys, sorry, I overlooked that the current It's nice the extra flexibility that this PR adds to the variant autocomplete code for JS. And it makes sense to have the API controller perform both fuzzy and conventional search (as the backend needs the fuzzy one while the API request needs the traditional one). My comment was more about creating a second However, that would broaden this PR's scope as we're discussing a more concrete need. So, I'm ok with merging this straightaway. |
Description
Update
/api/variants
to be able to search either using the configurablevariant_search_class
or Ransack. This makes it possible for users to more easily override the search behaviour ofvariantAutocomplete
based on their needs. (e.g.: If they're using Globalize and need to search the translated fields instead of just the base columns that won't be in use.)The existing behaviour is maintained to ensure the API is completely backwards compatible.
Ref #4175
Checklist: