Class: TinyAdmin::Views::Components::Pagination
- Inherits:
-
BasicComponent
- Object
- Phlex::HTML
- BasicComponent
- TinyAdmin::Views::Components::Pagination
- Defined in:
- lib/tiny_admin/views/components/pagination.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#query_string ⇒ Object
Returns the value of attribute query_string.
-
#total_count ⇒ Object
Returns the value of attribute total_count.
Instance Method Summary collapse
Methods inherited from BasicComponent
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
7 8 9 |
# File 'lib/tiny_admin/views/components/pagination.rb', line 7 def current @current end |
#pages ⇒ Object
Returns the value of attribute pages.
7 8 9 |
# File 'lib/tiny_admin/views/components/pagination.rb', line 7 def pages @pages end |
#query_string ⇒ Object
Returns the value of attribute query_string.
7 8 9 |
# File 'lib/tiny_admin/views/components/pagination.rb', line 7 def query_string @query_string end |
#total_count ⇒ Object
Returns the value of attribute total_count.
7 8 9 |
# File 'lib/tiny_admin/views/components/pagination.rb', line 7 def total_count @total_count end |
Instance Method Details
#view_template ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tiny_admin/views/components/pagination.rb', line 9 def view_template div(class: 'container') { div(class: 'row') { div(class: 'col total-count') { "#{total_count} items" } div(class: 'col col-6 text-center pagination-div') { nav(class: 'd-inline-block', 'aria-label': 'Pagination') { ul(class: 'pagination') { if pages <= 10 pages_range(1..pages) elsif current <= 4 || current >= pages - 3 pages_range(1..(current <= 4 ? current + 2 : 4), with_dots: true) pages_range((current > pages - 4 ? current - 2 : pages - 2)..pages) else pages_range(1..1, with_dots: true) pages_range(current - 2..current + 2, with_dots: true) pages_range(pages..pages) end } } } div(class: 'col') } } end |