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

Support all ransack predicates #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

goosys
Copy link
Contributor

@goosys goosys commented Oct 27, 2023

I made the following changes to enable the use of Ransack's extensive predicates expressions, in addition to ransackable_scope.
Please review and let me know if any further changes are needed.


Changes

  • Add AdministrateRansack.ransack? helper to check if a field name with predicates is valid.
  • Fix the labels to enable automatic translation of field names with predicates in i18n.

Breaking changes

  • Drop admin_scope option
    • For associations, admin_scope is no longer necessary as updated to use Field.associated_resource to get the collection.
    • If we want to do something similar, we can do it with Field::BelongsTo like this:
      • Field::BelongsTo.with_options(scope: ->{ Post.published })
    • Since Field::HasMany does not have a scope option, it cannot be done in the same way, but it can be achieved using the Field::ScopedHasMany plugin.
  • Drop admin_label option
    • For associations, use the value of display_resource as the label to match the title or heading of each admin pages.

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.

1 participant