Adds members of subprojects in assignee and author filters (#10126).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8747 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-02-01 20:07:01 +00:00
parent 0154d7477b
commit 2808adf99f
4 changed files with 38 additions and 7 deletions
+10
View File
@@ -33,6 +33,16 @@ class Principal < ActiveRecord::Base
}
}
# Principals that are members of a collection of projects
named_scope :member_of, lambda {|projects|
if projects.empty?
{:conditions => "1=0"}
else
ids = projects.map(&:id)
{:conditions => ["#{Principal.table_name}.status = 1 AND #{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids]}
end
}
before_create :set_default_empty_values
def name(formatter = nil)
+10 -7
View File
@@ -232,11 +232,18 @@ class Query < ActiveRecord::Base
principals = []
if project
principals += project.principals.sort
unless project.leaf?
subprojects = project.descendants.visible.all
if subprojects.any?
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => subprojects.collect{|s| [s.name, s.id.to_s] } }
principals += Principal.member_of(subprojects)
end
end
else
all_projects = Project.visible.all
if all_projects.any?
# members of visible projects
principals += Principal.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", all_projects.collect(&:id)]).sort
principals += Principal.member_of(all_projects)
# project filter
project_values = []
@@ -250,6 +257,8 @@ class Query < ActiveRecord::Base
@available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty?
end
end
principals.uniq!
principals.sort!
users = principals.select {|p| p.is_a?(User)}
assigned_to_values = []
@@ -282,12 +291,6 @@ class Query < ActiveRecord::Base
unless versions.empty?
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
end
unless project.leaf?
subprojects = project.descendants.visible.all
unless subprojects.empty?
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => subprojects.collect{|s| [s.name, s.id.to_s] } }
end
end
add_custom_fields_filters(project.all_issue_custom_fields)
else
# global filters for cross project issue list