Class: Voom::Presenters::DSL::Components::Table::Pagination
- Defined in:
- lib/voom/presenters/dsl/components/table.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#next_button ⇒ Object
Returns the value of attribute next_button.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#previous_button ⇒ Object
Returns the value of attribute previous_button.
-
#total ⇒ Object
Returns the value of attribute total.
Attributes inherited from Base
#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type
Instance Method Summary collapse
-
#initialize(**attribs_, &block) ⇒ Pagination
constructor
A new instance of Pagination.
- #next_button_icon(icon = :keyboard_arrow_right) ⇒ Object
- #per_page_select ⇒ Object
- #previous_button_icon(icon = :keyboard_arrow_left) ⇒ Object
- #range ⇒ Object
Methods inherited from Base
Methods included from Pluggable
#include_plugins, #plugin, #plugin_module
Methods included from Mixins::YieldTo
Methods included from Serializer
Methods included from Lockable
Constructor Details
#initialize(**attribs_, &block) ⇒ Pagination
Returns a new instance of Pagination.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 119 def initialize(**attribs_, &block) super(type: :pagination, **attribs_, &block) @page_size = attribs.delete(:page_size){10}.to_i @page_size_options = attribs.delete(:page_size_options){[10,20,30,40,50,100]} @total = attribs.delete(:total) @current_page = attribs.delete(:current_page){ 1 }.to_i @replace_id = attribs.delete(:replace_id) @replace_presenter = attribs.delete(:replace_presenter) per_page_select range end |
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
117 118 119 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 117 def current_page @current_page end |
#next_button ⇒ Object
Returns the value of attribute next_button.
117 118 119 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 117 def @next_button end |
#page_size ⇒ Object
Returns the value of attribute page_size.
117 118 119 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 117 def page_size @page_size end |
#per_page ⇒ Object
Returns the value of attribute per_page.
117 118 119 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 117 def per_page @per_page end |
#previous_button ⇒ Object
Returns the value of attribute previous_button.
117 118 119 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 117 def @previous_button end |
#total ⇒ Object
Returns the value of attribute total.
117 118 119 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 117 def total @total end |
Instance Method Details
#next_button_icon(icon = :keyboard_arrow_right) ⇒ Object
146 147 148 149 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 146 def (icon = :keyboard_arrow_right) return @next_button if locked? @next_button = (icon, [total_pages, @current_page+1].min) end |
#per_page_select ⇒ Object
151 152 153 154 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 151 def per_page_select return @per_page if locked? @per_page = select(@page_size_options, @page_size, @total) end |
#previous_button_icon(icon = :keyboard_arrow_left) ⇒ Object
141 142 143 144 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 141 def (icon = :keyboard_arrow_left) return @previous_button if locked? @previous_button = (icon, [1, @current_page-1].max) end |
#range ⇒ Object
134 135 136 137 138 139 |
# File 'lib/voom/presenters/dsl/components/table.rb', line 134 def range return @range if locked? end_range = @total - (@total - @page_size * @current_page.to_i) start_range = end_range - @page_size + 1 @range = [start_range, end_range] end |