Hide present / blank filter options for required fields #3340
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.
Issue
For cases where a field is required (via validations, model config, or otherwise) and filterable, the associated filter dropdown includes
present
andblank
options that are unnecessary as the field is always expected to be present.Proposed change
Pass the
required
field from the model through to the filter box javascript, keeping the existing order but only appending thepresent
andblank
options when the field is not required.📝 I'm not sure how to best test the
js
changes aside from the tests added toindex_spec.rb
(which put it over therubocop
TODO limit, so I added that file as an exception instead of bumping the max any further).Example using the spec
dummy_app
Required field (
name
)Optional field (
team
)