diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-07-13 18:26:44 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-07-13 18:26:44 +0000 |
commit | 539166597f9998d93733b346e8cbcbf102496770 (patch) | |
tree | 8aaa7ae6f3574e2adb437ff37a4de4d58bce695c /app/models/time_entry_query.rb | |
parent | 0e514b3144bfd8124947534afb886e9f197275a7 (diff) | |
download | redmine-539166597f9998d93733b346e8cbcbf102496770.tar.gz redmine-539166597f9998d93733b346e8cbcbf102496770.zip |
Adds a version filter on time entries (#13558).
git-svn-id: http://svn.redmine.org/redmine/trunk@15646 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry_query.rb')
-rw-r--r-- | app/models/time_entry_query.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb index bb042ff16..dde34264a 100644 --- a/app/models/time_entry_query.rb +++ b/app/models/time_entry_query.rb @@ -41,6 +41,7 @@ class TimeEntryQuery < Query add_available_filter "spent_on", :type => :date_past principals = [] + versions = [] if project principals += project.principals.visible.sort unless project.leaf? @@ -52,6 +53,7 @@ class TimeEntryQuery < Query principals += Principal.member_of(subprojects).visible end end + versions = project.shared_versions.to_a else if all_projects.any? # members of visible projects @@ -69,6 +71,10 @@ class TimeEntryQuery < Query end add_available_filter("issue_id", :type => :tree, :label => :label_issue) + add_available_filter("issue.fixed_version_id", + :type => :list, + :name => l("label_attribute_of_issue", :name => l(:field_fixed_version)), + :values => Version.sort_by_status(versions).collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s, l("version_status_#{s.status}")] }) principals.uniq! principals.sort! @@ -136,6 +142,24 @@ class TimeEntryQuery < Query end end + def sql_for_issue_fixed_version_id_field(field, operator, value) + issue_ids = Issue.where(:fixed_version_id => value.first.to_i).pluck(:id) + case operator + when "=" + if issue_ids.any? + "#{TimeEntry.table_name}.issue_id IN (#{issue_ids.join(',')})" + else + "1=0" + end + when "!" + if issue_ids.any? + "#{TimeEntry.table_name}.issue_id NOT IN (#{issue_ids.join(',')})" + else + "1=1" + end + end + end + def sql_for_activity_id_field(field, operator, value) condition_on_id = sql_for_field(field, operator, value, Enumeration.table_name, 'id') condition_on_parent_id = sql_for_field(field, operator, value, Enumeration.table_name, 'parent_id') |