-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Use ActiveRecord Enum labels in current filters status #7790
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
base: master
Are you sure you want to change the base?
Use ActiveRecord Enum labels in current filters status #7790
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. |
5eb6ba1
to
ff3c597
Compare
ff3c597
to
0221992
Compare
Great work on this @harunkumars, thank you! |
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:
