Class: Kadmin::Pager::Presenter

Inherits:
Kadmin::Presenter show all
Defined in:
app/components/kadmin/pager/presenter.rb

Overview

Generates HTML code to present the given pager

Constant Summary collapse

FIRST_PAGE_SYMBOL =

Returns HTML glyph representing ‘navigate to first page’.

Returns:

  • (String)

    HTML glyph representing ‘navigate to first page’

'«'
PREVIOUS_PAGE_SYMBOL =

Returns HTML glyph representing ‘navigate to previous page’.

Returns:

  • (String)

    HTML glyph representing ‘navigate to previous page’

'‹'
LAST_PAGE_SYMBOL =

Returns HTML glyph representing ‘navigate to last page’.

Returns:

  • (String)

    HTML glyph representing ‘navigate to last page’

'»'
NEXT_PAGE_SYMBOL =

Returns HTML glyph representing ‘navigate to next page’.

Returns:

  • (String)

    HTML glyph representing ‘navigate to next page’

'›'
SEPARATOR_SYMBOL =

Returns HTML glyph used to indicate skipped page numbers.

Returns:

  • (String)

    HTML glyph used to indicate skipped page numbers

'…'
DEFAULT_SIZES =

Returns default page size controls.

Returns:

  • (Array<Integer>)

    default page size controls

[50, 100, 500, 1000].freeze

Instance Method Summary collapse

Methods inherited from Kadmin::Presenter

#initialize, #present, #render

Constructor Details

This class inherits a constructor from Kadmin::Presenter

Instance Method Details

#generate(captured, page_sizes: DEFAULT_SIZES) ⇒ ActiveSupport::SafeBuffer

Generates HTML controls to change page, and pager behaviour.

Parameters:

  • page_sizes (Array<Integer>) (defaults to: DEFAULT_SIZES)

    list of page sizes for the controls

Returns:

  • (ActiveSupport::SafeBuffer)

    ‘safe’ HTML representing the navigation and page size controls



28
29
30
31
32
33
34
35
# File 'app/components/kadmin/pager/presenter.rb', line 28

def generate(captured, page_sizes: DEFAULT_SIZES, **)
  navigation = page_list
  controls = size_list(page_sizes)
  contents = navigation + controls
  contents << captured unless captured.nil?

  return "<div class='btn-toolbar'>#{contents}</div>".html_safe
end