Use ActiveRecord Enum labels in current filters status#7790
Open
harunkumars wants to merge 10 commits intoactiveadmin:masterfrom
Open
Use ActiveRecord Enum labels in current filters status#7790harunkumars wants to merge 10 commits intoactiveadmin:masterfrom
harunkumars wants to merge 10 commits intoactiveadmin:masterfrom
Conversation
17eada7 to
18135b2
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #7790 +/- ##
=======================================
Coverage 98.92% 98.93%
=======================================
Files 197 197
Lines 4950 4963 +13
=======================================
+ Hits 4897 4910 +13
Misses 53 53
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
ff3c597 to
0221992
Compare
Contributor
|
Great work on this @harunkumars, thank you! |
|
Any updates on this PR? |
0221992 to
396d75b
Compare
Author
|
Just had to Fix use of deprecated enum syntax. Ready for review. Same example from before with current version of ActiveAdmin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Fixes Issue #3157 - Display Enum labels for Active Filters in Current Search Status
ActiveAdmin::Filters::ActiveFilter#values controls the displayed value for active filters.
This currently does not have any special handling for Enums.
For e.g. with an enum definition like
enum status: [:inactive, :active], when filtering for :inactive status, the Current Search Status widget shows "Status is 0"This PR, uses ActiveRecord::Enum.defined_enums to translate the display value for the filter to the associated label for enums. The Current Search Status widget will now show "Status is Inactive"
If a custom collection is provided when registering the ActiveAdmin resource e.g.
filter :status, as: :select, collection: [[:not_active, 0], [:active, 1]]which specifies dropdown labels that are different from the enum labels, then the dropdown label from the custom collection is used. The Current Search Status widget will now show "Status is Not Active"Sample before and after screenshots attached:

Before Fix:
After Fix:
