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

Prioritize filters with predicates in active filter labels (#7702) #7717

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ray-curran
Copy link
Contributor

@ray-curran ray-curran commented Nov 9, 2022

When there are filters for a single field and a multi-field ransack search with predicate, the multi-field label on the active filter should use the custom label from the filter input box.

Reproduction steps:

./app/admin/posts.rb

ActiveAdmin.register Post do
  filter :title_or_body_contains, as: :string, label: 'Title or Body'
  filter :title_or_body, as: :string, filters: [:equals], label: 'Title/Body'
  filter :title, as: :string

  ...
end

Navigate to the posts path for a user like
localhost:3000/admin/users/4/posts

Complete search in all fields, note that all three active filters use the label "Title contains".
The title_or_body_contains should use the label from the filter "Title or Body contains".
The title_or_body should use the label from the filter: "Title/Body equals".

Fixes #7702

Copy link

@corlissc corlissc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ray-curran looks good. This will resolve the issue that I submitted.

@javierjulio javierjulio force-pushed the 7702-prioritize-predicate-labels branch from d46e559 to 420bc74 Compare March 13, 2023 00:16
@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (12c39a7) 99.05% compared to head (7e29df2) 99.05%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7717   +/-   ##
=======================================
  Coverage   99.05%   99.05%           
=======================================
  Files         184      184           
  Lines        4740     4740           
=======================================
  Hits         4695     4695           
  Misses         45       45           
Files Coverage Δ
lib/active_admin/filters/active_filter.rb 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…in#7702)

When there are filters for a single field and a multi-field ransack
search with predicate, the multi-field label on the active filter
should use the custom label from the filter input box.

Reproduction steps:

./app/admin/posts.rb
```
ActiveAdmin.register Post do
  filter :title_or_body_contains, as: :string, label: 'Title or Body'
  filter :title, as: :string

  ...
end
```

Navigate to the posts path for a user like
`localhost:3000/admin/users/4/posts`

Complete search in both fields, note that both active filters use the
label "Title contains". The `title_or_body_contains` should use the
label from the filter "Title or Body contains".
@ray-curran ray-curran force-pushed the 7702-prioritize-predicate-labels branch from 420bc74 to 7e29df2 Compare November 3, 2023 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants