Class: Blacklight::Response::PaginationComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/response/pagination_component.rb

Overview

Render a pagination widget for search results

Instance Method Summary collapse

Methods inherited from Component

reset_compiler!, sidecar_files, upstream_sidecar_files

Constructor Details

#initialize(response:, html: {}, classes: 'paginate-section', **pagination_args) ⇒ PaginationComponent

Returns a new instance of PaginationComponent.

Parameters:

  • response (Blacklight::Response)
  • html (Hash) (defaults to: {})

    html options for the pagination container



9
10
11
12
13
14
# File 'app/components/blacklight/response/pagination_component.rb', line 9

def initialize(response:, html: {}, classes: 'paginate-section', **pagination_args)
  @response = response
  @html = html
  @classes = classes
  @pagination_args = pagination_args
end

Instance Method Details

#configured_optionsObject



25
26
27
# File 'app/components/blacklight/response/pagination_component.rb', line 25

def configured_options
  controller.blacklight_config.index.pagination_options
end

#html_attrObject



16
17
18
# File 'app/components/blacklight/response/pagination_component.rb', line 16

def html_attr
  { aria: { label: t('views.pagination.aria.container_label') } }.merge(@html)
end

#paginationObject



20
21
22
23
# File 'app/components/blacklight/response/pagination_component.rb', line 20

def pagination
  args = configured_options.merge(@pagination_args).compact
  helpers.paginate @response, **args
end