Sha256: 880f53dc324d1072285a04e25ebae83cb4479cb57884161d7ccebc9e6100dd80

Contents?: true

Size: 585 Bytes

Versions: 16

Compression:

Stored size: 585 Bytes

Contents

module TableSortable
  class QueryParams

    attr_reader :page, :page_size
    def initialize(params, columns, column_offset = 0)
      @page = params[PAGE].to_i
      @page_size = params[PAGESIZE].to_i

      # reset column filters and sorters
      columns.each do |col|
        col_index = (columns.find_index(col) + column_offset)
        col.filter.query = params[FCOL] ? params[FCOL][col_index.to_s] : nil
        col.sorter.sort_order = params[SCOL] && params[SCOL][col_index.to_s] ? ((params[SCOL][col_index.to_s] == SORT_ASC) ? :asc : :desc) : nil
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
table_sortable-1.0.0.pre.alpha.3 lib/table_sortable/query_params.rb
table_sortable-1.0.0.pre.alpha.2 lib/table_sortable/query_params.rb
table_sortable-1.0.0.pre.alpha.1 lib/table_sortable/query_params.rb
table_sortable-0.4.7 lib/table_sortable/query_params.rb
table_sortable-0.4.6 lib/table_sortable/query_params.rb
table_sortable-0.4.5 lib/table_sortable/query_params.rb
table_sortable-0.4.4 lib/table_sortable/query_params.rb
table_sortable-0.4.3 lib/table_sortable/query_params.rb
table_sortable-0.4.2 lib/table_sortable/query_params.rb
table_sortable-0.4.1 lib/table_sortable/query_params.rb
table_sortable-0.4.0 lib/table_sortable/query_params.rb
table_sortable-0.3.3 lib/table_sortable/query_params.rb
table_sortable-0.3.2 lib/table_sortable/query_params.rb
table_sortable-0.3.1 lib/table_sortable/query_params.rb
table_sortable-0.3.0 lib/table_sortable/query_params.rb
table_sortable-0.2.0 lib/table_sortable/query_params.rb