Class: RubyUI::DataTablePagination

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/data_table/data_table_pagination.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Constructor Details

#initialize(with: nil, pagy: nil, kaminari: nil, page: nil, per_page: nil, total_count: nil, page_param: "page", path: "", query: {}, window: 1, prev_label: "<", next_label: ">", **attrs) ⇒ DataTablePagination

Returns a new instance of DataTablePagination.



10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_ui/data_table/data_table_pagination.rb', line 10

def initialize(with: nil, pagy: nil, kaminari: nil, page: nil, per_page: nil, total_count: nil, page_param: "page", path: "", query: {}, window: 1, prev_label: "<", next_label: ">", **attrs)
  @adapter = resolve_adapter(with:, pagy:, kaminari:, page:, per_page:, total_count:)
  @page_param = page_param
  @path = path
  @query = query.to_h.transform_keys(&:to_s)
  @window = window
  @prev_label = prev_label
  @next_label = next_label
  super(**attrs)
end

Instance Method Details

#view_templateObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby_ui/data_table/data_table_pagination.rb', line 21

def view_template
  return if total <= 1

  render RubyUI::Pagination.new(class: "mx-0 w-auto justify-end", **attrs) do
    render RubyUI::PaginationContent.new do
      prev_item
      number_items
      next_item
    end
  end
end