Class: Anchor::Table::PaginationComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Anchor::Table::PaginationComponent
- Defined in:
- app/components/anchor/table/pagination_component.rb
Constant Summary
Constants included from ViewHelper
Instance Attribute Summary collapse
-
#paginatable ⇒ Object
readonly
Returns the value of attribute paginatable.
-
#paginate ⇒ Object
readonly
Returns the value of attribute paginate.
Instance Method Summary collapse
-
#initialize(paginate:, paginatable:, **kwargs) ⇒ PaginationComponent
constructor
A new instance of PaginationComponent.
- #next_page_link ⇒ Object
- #previous_page_link ⇒ Object
- #render? ⇒ Boolean
- #total ⇒ Object
Methods inherited from Component
Methods included from ViewHelper
#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes
Methods included from FetchOrFallbackHelper
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
#paginatable ⇒ Object (readonly)
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 (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
#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 |