Module: Avo::Concerns::Pagination
- Extended by:
- ActiveSupport::Concern
- Included in:
- Resources::Base
- Defined in:
- lib/avo/concerns/pagination.rb
Instance Method Summary collapse
Instance Method Details
#apply_pagination(index_params:, query:, **args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/avo/concerns/pagination.rb', line 30 def apply_pagination(index_params:, query:, **args) extra_pagy_params = {} # Reset open filters when a user navigates to a new page if params[:keep_filters_panel_open] == "1" extra_pagy_params[:keep_filters_panel_open] = "0" end data_turbo_frame = "data-turbo-frame=\"#{CGI.escapeHTML(params[:turbo_frame]) if params[:turbo_frame]}\"" # Perform pagination and fallback to first page on Pagy::OverflowError begin perform_pagination(index_params:, query:, data_turbo_frame:, extra_pagy_params:, **args) rescue Pagy::OverflowError index_params[:page] = 1 perform_pagination(index_params:, query:, data_turbo_frame:, extra_pagy_params:, **args) end end |
#pagination_type ⇒ Object
26 27 28 |
# File 'lib/avo/concerns/pagination.rb', line 26 def pagination_type @pagination_type ||= ActiveSupport::StringInquirer.new(pagination_hash[:type].to_s) end |