Sha256: 5eeb55f7d8e345e81f6dbb9808137760ce311ec088b4c4dbcdc2e5a78bd6059b

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'ui_bibz/ui/ux/tables/components/columns'
require 'ui_bibz/ui/ux/tables/components/column'
module UiBibz::Ui::Ux::Tables
  class Store
    attr_accessor :records

    # Store Use WillPaginate store methods
    def initialize(store)
      raise 'Store is nil!' if store.nil?
      raise 'Store can be created only with "table_search_pagination" method!' if store.try(:records).nil?

      @records = store.records
      @store   = store
      @model   = store.model
    end

    def total_pages
      @records.total_pages
    end

    def per_page
      @records.per_page
    end

    def total_entries
      @records.total_entries
    end

    def id
      @store.id
    end

    def sort
      @store.sort
    end

    def column_id
      @store.column_id
    end

    def direction
      @store.direction
    end

    def searchable_attributes
      @store.searchable_attributes
    end

    def current_page
      @records.current_page
    end

    def limit_value
      @records.limit_value
    end

    def columns
      @columns ||= Columns.new(model.attribute_names.map { |attribute_name| Column.new(attribute_name, { name: attribute_name.humanize }) })
    end

    attr_reader :model

    def search
      @store.search
    end

    def controller
      @store.controller
    end

    def actions_controller
      @store.actions_controller
    end

    def params
      @store.params || {}
    end

    def parameters
      @store.params.to_h
    end

    def action
      @store.action
    end

    def param_id
      @store.param_id
    end

    def id_key
      @store.id_key
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ui_bibz-4.0.0.beta14 lib/ui_bibz/ui/ux/tables/components/store.rb
ui_bibz-4.0.0.beta13 lib/ui_bibz/ui/ux/tables/components/store.rb