diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue_query.rb | 11 | ||||
-rw-r--r-- | app/models/query.rb | 15 | ||||
-rw-r--r-- | app/views/context_menus/issues.html.erb | 5 |
3 files changed, 26 insertions, 5 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index c97de0a19..c4ab37d59 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -245,6 +245,8 @@ class IssueQuery < Query add_available_filter "parent_id", :type => :tree, :label => :field_parent_issue add_available_filter "child_id", :type => :tree, :label => :label_subtask_plural + add_available_filter "issue_id", :type => :integer, :label => :label_issue + Tracker.disabled_core_fields(trackers).each {|field| delete_available_filter field } @@ -509,6 +511,15 @@ class IssueQuery < Query end end + def sql_for_issue_id_field(field, operator, value) + ids = value.first.to_s.scan(/\d+/).map(&:to_i).join(",") + if ids.present? + "#{Issue.table_name}.id IN (#{ids})" + else + "1=0" + end + end + def sql_for_relations(field, operator, value, options={}) relation_options = IssueRelation::TYPES[field] return relation_options unless relation_options diff --git a/app/models/query.rb b/app/models/query.rb index 3a30e2769..68beb3c97 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -264,9 +264,9 @@ class Query < ActiveRecord::Base if values_for(field) case type_for(field) when :integer - add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^[+-]?\d+$/) } + add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(,[+-]?\d+)*\z/) } when :float - add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^[+-]?\d+(\.\d*)?$/) } + add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\.\d*)?\z/) } when :date, :date_past case operator_for(field) when "=", ">=", "<=", "><" @@ -771,10 +771,15 @@ class Query < ActiveRecord::Base when :date, :date_past sql = date_clause(db_table, db_field, parse_date(value.first), parse_date(value.first), is_custom_filter) when :integer - if is_custom_filter - sql = "(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})" + int_values = value.first.to_s.scan(/[+-]?\d+/).map(&:to_i).join(",") + if int_values.present? + if is_custom_filter + sql = "(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) IN (#{int_values}))" + else + sql = "#{db_table}.#{db_field} IN (#{int_values})" + end else - sql = "#{db_table}.#{db_field} = #{value.first.to_i}" + sql = "1=0" end when :float if is_custom_filter diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb index df3d73e9b..891432054 100644 --- a/app/views/context_menus/issues.html.erb +++ b/app/views/context_menus/issues.html.erb @@ -133,6 +133,11 @@ <li><%= watcher_link(@issues, User.current) %></li> <% end %> +<% unless @issue %> + <li><%= context_menu_link l(:button_filter), _project_issues_path(@project, :set_filter => 1, :issue_id => @issue_ids.join(",")), + :class => 'icon-list' %></li> +<% end %> + <% if @issue.present? %> <% if @can[:log_time] -%> <li><%= context_menu_link l(:button_log_time), new_issue_time_entry_path(@issue), |