Sha256: fcc9e953bacfecf6ab7818b09f5de0c444018c1bbd2b878eb5895f32d820d033

Contents?: true

Size: 1011 Bytes

Versions: 12

Compression:

Stored size: 1011 Bytes

Contents

module UiBibz::Ui::Ux::Tables
  class Paginable < UiBibz::Ui::Base
    include WillPaginate::ActionView

    def initialize store, options, html_options = nil
      @store        = store
      @options      = options
      @html_options = html_options
    end

    # Render html tag
    def render
      content_tag :div, @html_options do
        concat UiBibz::Ui::Ux::Tables::TablePagination.new(store: @store).render
        concat UiBibz::Ui::Ux::Tables::TablePaginationPerPage.new(store: @store).render
        concat tag(:br, class: 'ui-bibz-clear')
      end
    end

    def paginable?
      @options[:paginable].nil? ? true : @options[:paginable]
    end

  private

    def store
      @store ||= if @search_field.options[:store].nil?
        raise 'Store is nil!'
      elsif @search_field.options[:store].try(:records).nil?
        raise 'Store can be created only with "table_search_pagination" method!'
      else
        Store.new @search_field.options.delete :store
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ui_bibz-2.0.0.alpha28 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha27 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha26 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha24 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha23 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha22 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha21 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha20 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha19 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha18 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha16 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb
ui_bibz-2.0.0.alpha15 lib/ui_bibz/ui/ux/tables/extensions/paginable.rb