Patch #5025 » query_sort_custom_fields.diff
| app/models/query.rb (working copy) | ||
|---|---|---|
| 532 | 532 |
def add_custom_fields_filters(custom_fields) |
| 533 | 533 |
@available_filters ||= {}
|
| 534 | 534 |
|
| 535 |
custom_fields.select(&:is_filter?).each do |field| |
|
| 535 |
custom_fields.select(&:is_filter?).each_with_index do |field, i| |
|
| 536 |
order = 20 + i |
|
| 536 | 537 |
case field.field_format |
| 537 | 538 |
when "text" |
| 538 |
options = { :type => :text, :order => 20 }
|
|
| 539 |
options = { :type => :text, :order => order }
|
|
| 539 | 540 |
when "list" |
| 540 |
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
|
| 541 |
options = { :type => :list_optional, :values => field.possible_values, :order => order }
|
|
| 541 | 542 |
when "date" |
| 542 |
options = { :type => :date, :order => 20 }
|
|
| 543 |
options = { :type => :date, :order => order }
|
|
| 543 | 544 |
when "bool" |
| 544 |
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
|
| 545 |
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => order }
|
|
| 545 | 546 |
else |
| 546 |
options = { :type => :string, :order => 20 }
|
|
| 547 |
options = { :type => :string, :order => order }
|
|
| 547 | 548 |
end |
| 548 | 549 |
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
| 549 | 550 |
end |