Sha256: d27103ae085a76f9d1b2f1fadbb039d1771a86e3c892fd529f9ab22c29906a8e

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

module UiBibz::Ui
  class Paginable < Ui
    include WillPaginate::ActionView

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

    def render
      content_tag :div do
        concat UiBibz::Ui::TablePagination.new(store: @store).render
        concat UiBibz::Ui::TablePaginationPerPage.new(store: @store).render
        concat tag(:br, class: '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

2 entries across 2 versions & 1 rubygems

Version Path
ui_bibz-1.0.0 lib/ui_bibz/ui/table/ux/paginable.rb
ui_bibz-0.9.0 lib/ui_bibz/ui/table/ux/paginable.rb