-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Filters: add ability to search for blank/null fields with boolean search #1893
Conversation
So how does this work? How could we use it e.x. in a index filter? I'd like to be able to search for any field that isn't empty/null. |
I think you could already do this before this commit, with this filter: filter :county_is_present, as: :boolean This commit adds the ability to do the opposite: filter :county_is_blank, as: :boolean |
Eh, I'd prefer it be inline to the existing filter. Like for a string, you'd have a checkbox whether to include it, and if it's checked and the text field is empty, it will search for null and blank values. |
Ah. I don't think that's possible without some hacking around in the filters code. Right now if the filter field is blank, that's how AA decides if the filter should be applied at all. It would complicate the UI enough that I wouldn't want that on by default, but I could see it being added as an option to filters (eg filter :county_name, allow_blank_search: true or something). |
In a similar vein, it would be useful to have |
@whatcould Could you post a quick screenshot of what this looks like on a resource listing page? |
Would the following produce a dropdown with options of "yes" & "no"? filter :country_is_blank, as: :select In general, I don't think having checkboxes in the filter sidebar is a good UI choice. |
Trying to make a boolean a select doesn't work; it tries to create a "county_is_blank_eq" filter, and that is not what you're looking for. There might be a way to hack it somehow but I suspect it would require more activeadmin hacking (and another pull request). In this case, on my project, the user just wants to occasionally find records where the county is blank (to fill them in); there is no reason to select records where the county is not blank. This seems like a pretty common use case. This commit is still useful regardless; it adds in some metasearch_conditions that already exist but are not accessible because they were left out of the boolean input filter. |
Filters: add ability to search for blank/null fields with boolean search
Also matching just the end of the supplied field name, which should only matter in case of some strange field names but is probably a good idea just in case.