@@ -691,9 +691,9 class Query < ActiveRecord::Base | |||||
691 | if field =~ /cf_(\d+)$/ |
|
691 | if field =~ /cf_(\d+)$/ | |
692 | # custom field |
|
692 | # custom field | |
693 | filters_clauses << sql_for_custom_field(field, operator, v, $1) |
|
693 | filters_clauses << sql_for_custom_field(field, operator, v, $1) | |
694 | elsif respond_to?("sql_for_#{field}_field") |
|
694 | elsif respond_to?(method = "sql_for_#{field.gsub('.','_')}_field") | |
695 | # specific statement |
|
695 | # specific statement | |
696 |
filters_clauses << send( |
|
696 | filters_clauses << send(method, field, operator, v) | |
697 | else |
|
697 | else | |
698 | # regular field |
|
698 | # regular field | |
699 | filters_clauses << '(' + sql_for_field(field, operator, v, queried_table_name, field) + ')' |
|
699 | filters_clauses << '(' + sql_for_field(field, operator, v, queried_table_name, field) + ')' |
@@ -41,6 +41,7 class TimeEntryQuery < Query | |||||
41 | add_available_filter "spent_on", :type => :date_past |
|
41 | add_available_filter "spent_on", :type => :date_past | |
42 |
|
42 | |||
43 | principals = [] |
|
43 | principals = [] | |
|
44 | versions = [] | |||
44 | if project |
|
45 | if project | |
45 | principals += project.principals.visible.sort |
|
46 | principals += project.principals.visible.sort | |
46 | unless project.leaf? |
|
47 | unless project.leaf? | |
@@ -52,6 +53,7 class TimeEntryQuery < Query | |||||
52 | principals += Principal.member_of(subprojects).visible |
|
53 | principals += Principal.member_of(subprojects).visible | |
53 | end |
|
54 | end | |
54 | end |
|
55 | end | |
|
56 | versions = project.shared_versions.to_a | |||
55 | else |
|
57 | else | |
56 | if all_projects.any? |
|
58 | if all_projects.any? | |
57 | # members of visible projects |
|
59 | # members of visible projects | |
@@ -69,6 +71,10 class TimeEntryQuery < Query | |||||
69 | end |
|
71 | end | |
70 |
|
72 | |||
71 | add_available_filter("issue_id", :type => :tree, :label => :label_issue) |
|
73 | add_available_filter("issue_id", :type => :tree, :label => :label_issue) | |
|
74 | add_available_filter("issue.fixed_version_id", | |||
|
75 | :type => :list, | |||
|
76 | :name => l("label_attribute_of_issue", :name => l(:field_fixed_version)), | |||
|
77 | :values => Version.sort_by_status(versions).collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s, l("version_status_#{s.status}")] }) | |||
72 |
|
78 | |||
73 | principals.uniq! |
|
79 | principals.uniq! | |
74 | principals.sort! |
|
80 | principals.sort! | |
@@ -136,6 +142,24 class TimeEntryQuery < Query | |||||
136 | end |
|
142 | end | |
137 | end |
|
143 | end | |
138 |
|
144 | |||
|
145 | def sql_for_issue_fixed_version_id_field(field, operator, value) | |||
|
146 | issue_ids = Issue.where(:fixed_version_id => value.first.to_i).pluck(:id) | |||
|
147 | case operator | |||
|
148 | when "=" | |||
|
149 | if issue_ids.any? | |||
|
150 | "#{TimeEntry.table_name}.issue_id IN (#{issue_ids.join(',')})" | |||
|
151 | else | |||
|
152 | "1=0" | |||
|
153 | end | |||
|
154 | when "!" | |||
|
155 | if issue_ids.any? | |||
|
156 | "#{TimeEntry.table_name}.issue_id NOT IN (#{issue_ids.join(',')})" | |||
|
157 | else | |||
|
158 | "1=1" | |||
|
159 | end | |||
|
160 | end | |||
|
161 | end | |||
|
162 | ||||
139 | def sql_for_activity_id_field(field, operator, value) |
|
163 | def sql_for_activity_id_field(field, operator, value) | |
140 | condition_on_id = sql_for_field(field, operator, value, Enumeration.table_name, 'id') |
|
164 | condition_on_id = sql_for_field(field, operator, value, Enumeration.table_name, 'id') | |
141 | condition_on_parent_id = sql_for_field(field, operator, value, Enumeration.table_name, 'parent_id') |
|
165 | condition_on_parent_id = sql_for_field(field, operator, value, Enumeration.table_name, 'parent_id') |
@@ -639,6 +639,27 class TimelogControllerTest < ActionController::TestCase | |||||
639 | end |
|
639 | end | |
640 | end |
|
640 | end | |
641 |
|
641 | |||
|
642 | def test_index_at_project_level_with_issue_id_short_filter | |||
|
643 | issue = Issue.generate!(:project_id => 1) | |||
|
644 | TimeEntry.generate!(:issue => issue, :hours => 4) | |||
|
645 | TimeEntry.generate!(:issue => issue, :hours => 3) | |||
|
646 | @request.session[:user_id] = 2 | |||
|
647 | ||||
|
648 | get :index, :project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1 | |||
|
649 | assert_select '.total-hours', :text => 'Total time: 7.00 hours' | |||
|
650 | end | |||
|
651 | ||||
|
652 | def test_index_at_project_level_with_issue_fixed_version_id_short_filter | |||
|
653 | version = Version.generate!(:project_id => 1) | |||
|
654 | issue = Issue.generate!(:project_id => 1, :fixed_version => version) | |||
|
655 | TimeEntry.generate!(:issue => issue, :hours => 2) | |||
|
656 | TimeEntry.generate!(:issue => issue, :hours => 3) | |||
|
657 | @request.session[:user_id] = 2 | |||
|
658 | ||||
|
659 | get :index, :project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1 | |||
|
660 | assert_select '.total-hours', :text => 'Total time: 5.00 hours' | |||
|
661 | end | |||
|
662 | ||||
642 | def test_index_at_project_level_with_date_range |
|
663 | def test_index_at_project_level_with_date_range | |
643 | get :index, :project_id => 'ecookbook', |
|
664 | get :index, :project_id => 'ecookbook', | |
644 | :f => ['spent_on'], |
|
665 | :f => ['spent_on'], |
General Comments 0
You need to be logged in to leave comments.
Login now