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

Allow config.paginate to be a block #8007

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

Conversation

allomov
Copy link

@allomov allomov commented Jul 10, 2023

Hello, everyone!

I propose this change to allow config.paginate option to be set as a block that will return a value based on resource configuration.

In my case, I have a Sessions resource with an index that can be displayed as a table (default view) and as a calendar. With the calendar view, the pagination is replaced by the start/end time filter.

Using this change I can initialize resources in the following way:

ActiveAdmin.register Session, as: "All Sessions" do
  config.paginate = proc { params[:as] != "calendar" }
  index(as: :calendar)
end

which will allow ActiveAdmin::Views::IndexAsCalendar will handle filtering instead of pagination.

Thank you for your attention! Please, tell me what you think about it.

@allomov
Copy link
Author

allomov commented Jul 18, 2023

I am not sure why CI is failing, because the same command for test (3.2, rails_70) and other configurations work fine, but fail on test (3.2, rails_61)

@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.26 🎉

Comparison is base (15800ce) 98.84% compared to head (b037309) 99.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8007      +/-   ##
==========================================
+ Coverage   98.84%   99.11%   +0.26%     
==========================================
  Files         197      197              
  Lines        4950     4949       -1     
==========================================
+ Hits         4893     4905      +12     
+ Misses         57       44      -13     
Impacted Files Coverage Δ
lib/active_admin/resource/pagination.rb 100.00% <100.00%> (ø)
...ib/active_admin/resource_controller/data_access.rb 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

None yet

1 participant