diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 5ff0e5530..b0283ab7e 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -605,6 +605,20 @@ class IssueQuery < Query else "1=0" end + when "=+" + ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq + if ids.present? + "(#{Issue.table_name}.parent_id IN (#{ids.join(",")}) OR #{Issue.table_name}.id IN (#{ids.join(",")}))" + else + "1=0" + end + when "~+" + root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first + if root_id && lft && rgt + "#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft >= #{lft} AND #{Issue.table_name}.rgt <= #{rgt}" + else + "1=0" + end when "!*" "#{Issue.table_name}.parent_id IS NULL" when "*" @@ -630,6 +644,25 @@ class IssueQuery < Query else "1=0" end + when "=+" + child_ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq + ids = Issue.where(:id => child_ids).pluck(:parent_id).compact.uniq + if child_ids.present? + if ids.present? + "(#{Issue.table_name}.id IN (#{ids.join(",")}) OR #{Issue.table_name}.id IN (#{child_ids.join(",")}))" + else + "#{Issue.table_name}.id IN (#{child_ids.join(",")})" + end + else + "1=0" + end + when "~+" + root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first + if root_id && lft && rgt + "#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft <= #{lft} AND #{Issue.table_name}.rgt >= #{rgt}" + else + "1=0" + end when "!*" "#{Issue.table_name}.rgt - #{Issue.table_name}.lft = 1" when "*" diff --git a/app/models/query.rb b/app/models/query.rb index fad3930aa..1ba54ebf8 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -306,6 +306,8 @@ class Query < ActiveRecord::Base "!p" => :label_no_issues_in_project, "*o" => :label_any_open_issues, "!o" => :label_no_open_issues, + "=+" => :label_equals_inclusive, + "~+" => :label_contains_inclusive, } class_attribute :operators_by_filter_type @@ -321,7 +323,7 @@ class Query < ActiveRecord::Base :integer => [ "=", ">=", "<=", "><", "!*", "*" ], :float => [ "=", ">=", "<=", "><", "!*", "*" ], :relation => ["=", "!", "=p", "=!p", "!p", "*o", "!o", "!*", "*"], - :tree => ["=", "~", "!*", "*"] + :tree => ["=", "~", "!*", "*", "=+", "~+"] } class_attribute :available_columns diff --git a/config/locales/en.yml b/config/locales/en.yml index 9d779a2fe..e9c865197 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -771,6 +771,7 @@ en: label_filter_add: Add filter label_filter_plural: Filters label_equals: is + label_equals_inclusive: is (inclusive) label_not_equals: is not label_in_less_than: in less than label_in_more_than: in more than @@ -797,6 +798,7 @@ en: label_more_than_ago: more than days ago label_ago: days ago label_contains: contains + label_contains_inclusive: contains (inclusive) label_not_contains: doesn't contain label_starts_with: starts with label_ends_with: ends with diff --git a/config/locales/it.yml b/config/locales/it.yml index d49b5c3e9..1ca98dac0 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -426,6 +426,7 @@ it: label_filter_add: Aggiungi filtro label_filter_plural: Filtri label_equals: è + label_equals_inclusive: è (incluso) label_not_equals: non è label_in_less_than: è minore di label_in_more_than: è maggiore di @@ -436,6 +437,7 @@ it: label_more_than_ago: più di giorni fa label_ago: giorni fa label_contains: contiene + label_contains_inclusive: contiene (incluso) label_not_contains: non contiene label_day_plural: giorni label_repository: Repository