Module: RubyCms::AdminPagination
- Extended by:
- ActiveSupport::Concern
- Included in:
- RubyCms::Admin::ContentBlocksController, RubyCms::Admin::PermissionsController, RubyCms::Admin::UsersController, RubyCms::Admin::VisitorErrorsController
- Defined in:
- app/controllers/concerns/ruby_cms/admin_pagination.rb
Overview
Unified pagination concern for all admin index pages. Uses RubyCms::Preference for per_page when configured via paginates(per_page: proc).
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DEFAULT_MIN_PER_PAGE =
5- DEFAULT_MAX_PER_PAGE =
200
Instance Method Summary collapse
- #paginate_collection(collection, per_page: nil, turbo_frame: nil) ⇒ Object
- #set_pagination_vars(collection, per_page: nil, turbo_frame: nil) ⇒ Object
Instance Method Details
#paginate_collection(collection, per_page: nil, turbo_frame: nil) ⇒ Object
36 37 38 |
# File 'app/controllers/concerns/ruby_cms/admin_pagination.rb', line 36 def paginate_collection(collection, per_page: nil, turbo_frame: nil) set_pagination_vars(collection, per_page:, turbo_frame:) end |
#set_pagination_vars(collection, per_page: nil, turbo_frame: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/concerns/ruby_cms/admin_pagination.rb', line 21 def set_pagination_vars(collection, per_page: nil, turbo_frame: nil) per_page = calculate_per_page(per_page) turbo_frame ||= self.class.pagination_turbo_frame page = sanitize_page_param(params[:page]) paginated, total_count, total_pages, offset = paginate_collection_internal(collection, page, per_page) @pagination = build_pagination_hash(page, per_page, total_count, total_pages, offset) @pagination_path = build_pagination_path_lambda @turbo_frame = turbo_frame paginated end |