Patch #5025 » query_sort_custom_fields.diff
| app/models/query.rb (working copy) | ||
|---|---|---|
|
def add_custom_fields_filters(custom_fields)
|
||
|
@available_filters ||= {}
|
||
|
|
||
|
custom_fields.select(&:is_filter?).each do |field|
|
||
|
custom_fields.select(&:is_filter?).each_with_index do |field, i|
|
||
|
order = 20 + i
|
||
|
case field.field_format
|
||
|
when "text"
|
||
|
options = { :type => :text, :order => 20 }
|
||
|
options = { :type => :text, :order => order }
|
||
|
when "list"
|
||
|
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
||
|
options = { :type => :list_optional, :values => field.possible_values, :order => order }
|
||
|
when "date"
|
||
|
options = { :type => :date, :order => 20 }
|
||
|
options = { :type => :date, :order => order }
|
||
|
when "bool"
|
||
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
||
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => order }
|
||
|
else
|
||
|
options = { :type => :string, :order => 20 }
|
||
|
options = { :type => :string, :order => order }
|
||
|
end
|
||
|
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
||
|
end
|
||