Module: Jav::Concerns::Pagination

Extended by:
ActiveSupport::Concern
Included in:
BaseResource
Defined in:
lib/jav/concerns/pagination.rb

Instance Method Summary collapse

Instance Method Details

#apply_pagination(index_params:, query:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jav/concerns/pagination.rb', line 30

def apply_pagination(index_params:, query:)
  extra_pagy_params = {}

  # Reset open filters when a user navigates to a new page
  extra_pagy_params[:keep_filters_panel_open] = ("0" if params[:keep_filters_panel_open] == "1")

  send PAGINATION_METHOD[pagination_type.to_sym],
       query,
       limit: index_params[:per_page],
       anchor_string: "data-turbo-frame=\"#{params[:turbo_frame]}\"",
       params: extra_pagy_params,
       size: pagination_hash[:size]
end

#pagination_typeObject



26
27
28
# File 'lib/jav/concerns/pagination.rb', line 26

def pagination_type
  @pagination_type ||= ActiveSupport::StringInquirer.new(pagination_hash[:type].to_s)
end