Feature #16621 » filter-relations-d4e1f70-r14601.patch
| app/models/issue_query.rb | ||
|---|---|---|
|
op = (operator == "!p" ? 'NOT IN' : 'IN')
|
||
|
comp = (operator == "=!p" ? '<>' : '=')
|
||
|
"#{Issue.table_name}.id #{op} (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column} FROM #{IssueRelation.table_name}, #{Issue.table_name} relissues WHERE #{IssueRelation.table_name}.relation_type = '#{self.class.connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id AND relissues.project_id #{comp} #{value.first.to_i})"
|
||
|
when "!|c", "*&o"
|
||
|
op = (operator == "!|c" ? 'NOT IN' : 'IN')
|
||
|
"#{Issue.table_name}.id #{op} (SELECT DISTINCT #{IssueRelation.table_name}.#{join_column} FROM #{IssueRelation.table_name}, #{Issue.table_name} relissues WHERE #{IssueRelation.table_name}.relation_type = '#{self.class.connection.quote_string(relation_type)}' AND #{IssueRelation.table_name}.#{target_join_column} = relissues.id AND relissues.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{self.class.connection.quoted_false}))"
|
||
|
end
|
||
|
if relation_options[:sym] == field && !options[:reverse]
|
||
| app/models/query.rb | ||
|---|---|---|
|
"!~" => :label_not_contains,
|
||
|
"=p" => :label_any_issues_in_project,
|
||
|
"=!p" => :label_any_issues_not_in_project,
|
||
|
"!p" => :label_no_issues_in_project
|
||
|
"!p" => :label_no_issues_in_project,
|
||
|
"*&o" => :label_any_open_issues,
|
||
|
"!|c" => :label_none_or_closed_issues
|
||
|
}
|
||
|
class_attribute :operators_by_filter_type
|
||
| ... | ... | |
|
:text => [ "~", "!~", "!*", "*" ],
|
||
|
:integer => [ "=", ">=", "<=", "><", "!*", "*" ],
|
||
|
:float => [ "=", ">=", "<=", "><", "!*", "*" ],
|
||
|
:relation => ["=", "=p", "=!p", "!p", "!*", "*"],
|
||
|
:relation => ["=", "=p", "=!p", "!p", "*&o", "!|c", "!*", "*"],
|
||
|
:tree => ["=", "~", "!*", "*"]
|
||
|
}
|
||
| ... | ... | |
|
# filter requires one or more values
|
||
|
(values_for(field) and !values_for(field).first.blank?) or
|
||
|
# filter doesn't require any value
|
||
|
["o", "c", "!*", "*", "t", "ld", "w", "lw", "l2w", "m", "lm", "y"].include? operator_for(field)
|
||
|
["o", "c", "!*", "*", "t", "ld", "w", "lw", "l2w", "m", "lm", "y", "*&o", "!|c"].include? operator_for(field)
|
||
|
end if filters
|
||
|
end
|
||
| config/locales/en-GB.yml | ||
|---|---|---|
|
permission_view_private_notes: View private notes
|
||
|
permission_set_notes_private: Set notes as private
|
||
|
label_no_issues_in_project: no issues in project
|
||
|
label_any_open_issues: any open issues
|
||
|
label_none_or_closed_issues: none or closed issues
|
||
|
label_any: all
|
||
|
label_last_n_weeks: last %{count} weeks
|
||
|
setting_cross_project_subtasks: Allow cross-project subtasks
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_any_issues_in_project: any issues in project
|
||
|
label_any_issues_not_in_project: any issues not in project
|
||
|
label_no_issues_in_project: no issues in project
|
||
|
label_any_open_issues: any open issues
|
||
|
label_none_or_closed_issues: none or closed issues
|
||
|
label_day_plural: days
|
||
|
label_repository: Repository
|
||
|
label_repository_new: New repository
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
case "y":
|
||
|
case "o":
|
||
|
case "c":
|
||
|
case "!|c":
|
||
|
case "*&o":
|
||
|
enableValues(field, []);
|
||
|
break;
|
||
|
case "><":
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert_not_include 3, ids
|
||
|
end
|
||
|
def test_filter_on_relations_with_any_open_issues
|
||
|
IssueRelation.delete_all
|
||
|
# Issue 1 is blocked by 8, which is closed
|
||
|
IssueRelation.create!(:relation_type => "blocked", :issue_from => Issue.find(1), :issue_to => Issue.find(8))
|
||
|
# Issue 2 is blocked by 3, which is open
|
||
|
IssueRelation.create!(:relation_type => "blocked", :issue_from => Issue.find(2), :issue_to => Issue.find(3))
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.filters = {"blocked" => {:operator => "*&o", :values => ['']}}
|
||
|
ids = find_issues_with_query(query).map(&:id)
|
||
|
assert_equal [], ids & [1]
|
||
|
assert_include 2, ids
|
||
|
end
|
||
|
def test_filter_on_relations_with_none_or_closed_issues
|
||
|
IssueRelation.delete_all
|
||
|
# Issue 1 is blocked by 8, which is closed
|
||
|
IssueRelation.create!(:relation_type => "blocked", :issue_from => Issue.find(1), :issue_to => Issue.find(8))
|
||
|
# Issue 2 is blocked by 3, which is open
|
||
|
IssueRelation.create!(:relation_type => "blocked", :issue_from => Issue.find(2), :issue_to => Issue.find(3))
|
||
|
query = IssueQuery.new(:name => '_')
|
||
|
query.filters = {"blocked" => {:operator => "!|c", :values => ['']}}
|
||
|
ids = find_issues_with_query(query).map(&:id)
|
||
|
assert_equal [], ids & [2]
|
||
|
assert_include 1, ids
|
||
|
end
|
||
|
def test_filter_on_relations_with_no_issues
|
||
|
IssueRelation.delete_all
|
||
|
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2))
|
||
- « Previous
- 1
- 2
- 3
- Next »