Sha256: 219ee3b3c573b2812d553ba14b6d9bd685c12a76b9273576c22ebc72b62d0adf
Contents?: true
Size: 1.2 KB
Versions: 6
Compression:
Stored size: 1.2 KB
Contents
# -*- encoding : utf-8 -*- require 'search/conditions/abstract' require 'search/where' module RademadeAdmin module Search module Conditions class List < Abstract include RademadeAdmin::Search::Where protected def where @where_conditions = RademadeAdmin::Search::Part::Where.new(:and) search_by_fields regex_filter(@where_conditions, @params[:q]) @where_conditions end def order order_conditions = super list_order_field = order_field order_conditions.unshift(list_order_field, @params[:direction]) unless list_order_field.nil? order_conditions end def page @params[:page] || 1 end def per_page @params[:paginate] || 20 end private def order_field if @params[:sort] @params[:sort] else @data_items.has_field?(:position) ? :position : nil end end def search_by_fields @params.slice(*@data_items.origin_fields).each do |field, value| @where_conditions.add(field, value) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems