Skip to content
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

Hide present / blank filter options for required fields #3340

Merged

Conversation

codealchemy
Copy link
Contributor

Issue

For cases where a field is required (via validations, model config, or otherwise) and filterable, the associated filter dropdown includes present and blank 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 the present and blank options when the field is not required.

📝 I'm not sure how to best test the js changes aside from the tests added to index_spec.rb (which put it over the rubocop 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)

Screen Shot 2021-02-18 at 15 34 33

Optional field (team)

Screen Shot 2021-02-18 at 15 34 47

@codealchemy

This comment has been minimized.

@codealchemy codealchemy mentioned this pull request Feb 19, 2021
For cases where a field or association is required (via validations, model config, or otherwise) and is filterable, the associated filter dropdown includes 'present' and 'blank' options that are unnecessary as the field/association is always expected to be present.
@mshibuya mshibuya merged commit 7434497 into railsadminteam:master Feb 23, 2021
@mshibuya
Copy link
Member

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants