Feature #23215 » filter_after_target_version_status_and_due_date_r15732.patch
app/helpers/queries_helper.rb | ||
---|---|---|
30 | 30 |
group = query.is_a?(IssueQuery) ? :label_relations : nil |
31 | 31 |
elsif field =~ /^(.+)\./ |
32 | 32 |
# association filters |
33 |
group = "field_#{$1}" |
|
33 |
group = "field_#{$1}".to_sym
|
|
34 | 34 |
elsif %w(member_of_group assigned_to_role).include?(field) |
35 | 35 |
group = :field_assigned_to |
36 |
elsif %w(fixed_version_effective_date fixed_version_status).include?(field) |
|
37 |
group = :field_fixed_version |
|
36 | 38 |
elsif field_options[:type] == :date_past || field_options[:type] == :date |
37 | 39 |
group = :label_date |
38 | 40 |
end |
... | ... | |
43 | 45 |
end |
44 | 46 |
end |
45 | 47 |
# Don't group dates if there's only one (eg. time entries filters) |
46 |
if grouped[:label_date].try(:size) == 1
|
|
48 |
if grouped[:label_date].try(:size) == 1 |
|
47 | 49 |
ungrouped << grouped.delete(:label_date).first |
48 | 50 |
end |
49 | 51 |
s = options_for_select([[]] + ungrouped) |
... | ... | |
167 | 169 |
column_value(column, issue, value) |
168 | 170 |
end |
169 | 171 |
end |
170 |
|
|
172 | ||
171 | 173 |
def column_value(column, issue, value) |
172 | 174 |
case column.name |
173 | 175 |
when :id |
app/models/issue_query.rb | ||
---|---|---|
153 | 153 |
:type => :list_optional, |
154 | 154 |
:values => Version.sort_by_status(versions).collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s, l("version_status_#{s.status}")] } |
155 | 155 | |
156 |
add_available_filter "fixed_version_effective_date", |
|
157 |
:type => :date, |
|
158 |
:name => l(:label_attribute_of_fixed_version, :name => l(:field_effective_date)) |
|
159 | ||
160 |
add_available_filter "fixed_version_status", |
|
161 |
:type => :list, |
|
162 |
:name => l(:label_attribute_of_fixed_version, :name => l(:field_status)), |
|
163 |
:values => Version::VERSION_STATUSES.map{|t| [t, t] } |
|
164 | ||
156 | 165 |
add_available_filter "category_id", |
157 | 166 |
:type => :list_optional, |
158 | 167 |
:values => categories.collect{|s| [s.name, s.id.to_s] } |
... | ... | |
417 | 426 |
end |
418 | 427 |
end |
419 | 428 | |
429 |
def sql_for_fixed_version_status_field(field, operator, value) |
|
430 |
where = sql_for_field(field, operator, value, Version.table_name, "status") |
|
431 |
version_ids = versions(:conditions => [where]).map(&:id) |
|
432 |
sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id") |
|
433 |
end |
|
434 | ||
435 |
def sql_for_fixed_version_effective_date_field(field, operator, value) |
|
436 |
where = sql_for_field(field, operator, value, Version.table_name, "effective_date") |
|
437 |
version_ids = versions(:conditions => [where]).map(&:id) |
|
438 |
sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id") |
|
439 |
end |
|
440 | ||
420 | 441 |
def sql_for_is_private_field(field, operator, value) |
421 | 442 |
op = (operator == "=" ? 'IN' : 'NOT IN') |
422 | 443 |
va = value.map {|v| v == '0' ? self.class.connection.quoted_false : self.class.connection.quoted_true}.uniq.join(',') |
test/unit/query_test.rb | ||
---|---|---|
811 | 811 |
assert_equal [2], find_issues_with_query(query).map(&:fixed_version_id).uniq.sort |
812 | 812 |
end |
813 | 813 | |
814 |
def test_filter_on_fixed_version_effective_date |
|
815 |
query = IssueQuery.new(:name => '_') |
|
816 |
filter_name = "fixed_version_effective_date" |
|
817 |
assert_include filter_name, query.available_filters.keys |
|
818 |
query.filters = {filter_name => {:operator => '=', :values => [20.day.from_now.to_date.to_s(:db)]}} |
|
819 |
assert_equal [2], find_issues_with_query(query).map(&:fixed_version_id).uniq.sort |
|
820 | ||
821 |
query = IssueQuery.new(:name => '_') |
|
822 |
query.filters = {filter_name => {:operator => '>=', :values => [21.day.from_now.to_date.to_s(:db)]}} |
|
823 |
assert_equal [], find_issues_with_query(query).map(&:fixed_version_id).uniq.sort |
|
824 |
end |
|
825 | ||
826 |
def test_filter_on_fixed_version_status |
|
827 |
query = IssueQuery.new(:name => '_') |
|
828 |
filter_name = "fixed_version_status" |
|
829 |
assert_include filter_name, query.available_filters.keys |
|
830 |
query.filters = {filter_name => {:operator => '=', :values => ['closed']}} |
|
831 |
assert_equal [1], find_issues_with_query(query).map(&:fixed_version_id).uniq.sort |
|
832 |
end |
|
833 | ||
814 | 834 |
def test_filter_on_relations_with_a_specific_issue |
815 | 835 |
IssueRelation.delete_all |
816 | 836 |
IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(2)) |
... | ... | |
943 | 963 |
def test_filter_on_parent |
944 | 964 |
Issue.delete_all |
945 | 965 |
parent = Issue.generate_with_descendants! |
946 |
|
|
966 | ||
947 | 967 | |
948 | 968 |
query = IssueQuery.new(:name => '_') |
949 | 969 |
query.filters = {"parent_id" => {:operator => '=', :values => [parent.id.to_s]}} |
... | ... | |
973 | 993 |
parent = Issue.generate_with_descendants! |
974 | 994 |
child, leaf = parent.children.sort_by(&:id) |
975 | 995 |
grandchild = child.children.first |
976 |
|
|
996 | ||
977 | 997 | |
978 | 998 |
query = IssueQuery.new(:name => '_') |
979 | 999 |
query.filters = {"child_id" => {:operator => '=', :values => [grandchild.id.to_s]}} |