class UiBibz::Ui::Ux::Tables::TablePagination

Create a pagination for table

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

Signatures

UiBibz::Ui::Ux::Tables::TablePagination.new(store: @store)

Helper

table_pagination(options = {})

Public Class Methods

new(options = nil, html_options = nil) click to toggle source

Initialize pagination with component item pagination require WillPaginate gem

# File lib/ui_bibz/ui/ux/tables/table_pagination.rb, line 35
def initialize(options = nil, html_options = nil)
  @pagination = UiBibz::Ui::Core::Component.new nil, options, html_options
end

Public Instance Methods

render() click to toggle source

Render html tag with boostrap pagination theme

# File lib/ui_bibz/ui/ux/tables/table_pagination.rb, line 40
def render
  paginate_parameters = { controller: store.controller }
  paginate_parameters = paginate_parameters.merge(store.parameters)
  paginate_parameters = paginate_parameters.merge({ store_id: store.id }) unless store.id.nil?
  paginate_parameters = paginate_parameters.merge({ link_type: 'pagination' })
  will_paginate(store.records, params: paginate_parameters.with_indifferent_access.reject { |k, v| default_parameters?(k) || v.blank? }, renderer: WillPaginate::ActionView::BootstrapLinkRenderer)
end

Private Instance Methods

default_parameters?(key) click to toggle source
# File lib/ui_bibz/ui/ux/tables/table_pagination.rb, line 50
def default_parameters?(key)
  %w[per_page page link_type].include?(key)
end
store() click to toggle source

Store must be generated by table_search_pagination method

# File lib/ui_bibz/ui/ux/tables/table_pagination.rb, line 55
def store
  @store ||= Store.new @pagination.options[:store]
end