Class: Anchor::Table::PaginationComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Anchor::Table::PaginationComponent
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
#fetch_or_fallback
Constructor Details
#initialize(paginate:, paginatable:, **kwargs) ⇒ 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
#paginatable ⇒ Object
Returns the value of attribute paginatable.
4
5
6
|
# File 'app/components/anchor/table/pagination_component.rb', line 4
def paginatable
@paginatable
end
|
#paginate ⇒ Object
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
#next_page_link ⇒ Object
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
|
#previous_page_link ⇒ Object
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
16
17
18
|
# File 'app/components/anchor/table/pagination_component.rb', line 16
def render?
paginatable_data.any? && paginate.present?
end
|
#total ⇒ Object
36
37
38
|
# File 'app/components/anchor/table/pagination_component.rb', line 36
def total
t(".total", count: paginatable_data.size)
end
|