Class: Anchor::Table::PaginationComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/anchor/table/pagination_component.rb

Constant Summary

Constants included from ViewHelper

ViewHelper::ANCHOR_HELPERS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

generate_id

Methods included from ViewHelper

#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Constructor Details

#initialize(paginate:, paginatable:, **kwargs) ⇒ PaginationComponent

Returns a new instance of PaginationComponent.



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

def initialize(paginate:, paginatable:, **kwargs)
  @paginate = paginate
  @paginatable = paginatable

  super(**kwargs)
end

Instance Attribute Details

#paginatableObject (readonly)

Returns the value of attribute paginatable.



4
5
6
# File 'app/components/anchor/table/pagination_component.rb', line 4

def paginatable
  @paginatable
end

#paginateObject (readonly)

Returns the value of attribute paginate.



4
5
6
# File 'app/components/anchor/table/pagination_component.rb', line 4

def paginate
  @paginate
end

Instance Method Details



20
21
22
23
24
25
26
# File 'app/components/anchor/table/pagination_component.rb', line 20

def next_page_link
  page_link(
    condition: page < total_pages,
    name: t(".next"),
    page: page + 1
  )
end


28
29
30
31
32
33
34
# File 'app/components/anchor/table/pagination_component.rb', line 28

def previous_page_link
  page_link(
    condition: page > 1,
    name: t(".previous"),
    page: page - 1
  )
end

#render?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/components/anchor/table/pagination_component.rb', line 16

def render?
  paginatable_data.any? && paginate.present?
end

#totalObject



36
37
38
# File 'app/components/anchor/table/pagination_component.rb', line 36

def total
  t(".total", count: paginatable_data.size)
end