Backend: Make order search fields configurable #5776
Merged
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.
The order search depends on legacy promotion system associations to be present, but we don't want to introduce Deface as a core dependency. Therefore, we must make the search fields for orders configurable.
This introduces a new configuration option on the Backend configuration:
Spree::Backend::Config.order_search_fields
. This Array holds hashes with a:partial
key that indicates which partial should render this search field.Optionally, one can specify an
:if
key with a lambda as the value that gets executed at runtime, so that unnecessary fields ("Store" for installations with only one store instance) are not displayed.Complex fields can be done by specifying a custom partial, such as the
:date_range_picker
partial in this PR.Labels for the search fields can be specified as two-value arrays that represent arguments to
I18n.t
. By the time this array is loaded,I18n
does not have its translations loaded, so I have to go this somewhat complicated route.Because the input fields have to be a flat list now, we can't do the sorting into columns thing we did before, but we can use a column for each input to make things flow nicely.
Before:
After:
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs: