Project

General

Profile

Defect #5778 ยป custom_field_filter.patch

Yuki Kita, 2010-07-03 00:01

View differences:

app/models/query.rb (working copy)
:date_past => [ ">t-", "<t-", "t-", "t", "w" ],
:string => [ "=", "~", "!", "!~" ],
:text => [ "~", "!~" ],
:integer => [ "=", ">=", "<=", "!*", "*" ] }
:integer => [ "=", ">=", "<=", "!*", "*" ],
:float => [ "=", ">=", "<=", "!*", "*" ] }
cattr_reader :operators_by_filter_type
......
sql = "#{db_table}.#{db_field} IS NOT NULL"
sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter
when ">="
sql = "#{db_table}.#{db_field} >= #{value.first.to_i}"
sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) >= #{value.first.to_f}"
when "<="
sql = "#{db_table}.#{db_field} <= #{value.first.to_i}"
sql = "CAST(#{db_table}.#{db_field} AS decimal(60,3)) <= #{value.first.to_f}"
when "o"
sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id"
when "c"
......
options = { :type => :date, :order => 20 }
when "bool"
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
when "int"
options = { :type => :integer, :order => 20 }
when "float"
options = { :type => :float, :order => 20 }
else
options = { :type => :string, :order => 20 }
end
app/views/queries/_filters.rhtml (working copy)
<%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %> <%= l(:label_day_plural) %>
<% when :string, :text %>
<%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 30, :class => "select-small" %>
<% when :integer %>
<% when :integer, :float %>
<%= text_field_tag "values[#{field}][]", query.values_for(field), :id => "values_#{field}", :size => 3, :class => "select-small" %>
<% end %>
</div>
    (1-1/1)