summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-28 21:57:03 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-02-28 21:57:03 +0000
commitb6bd5c7f12afab446bca83d2eea277f1969637da (patch)
tree370dd76f23cf8979fc4a02f21a8be948491a9ddc /app/models
parent1ddb59df2afb4539e6484e7c339683d18fc0ac94 (diff)
downloadredmine-b6bd5c7f12afab446bca83d2eea277f1969637da.tar.gz
redmine-b6bd5c7f12afab446bca83d2eea277f1969637da.zip
Include subprojects on the issue list, calendar and gantt by default.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1178 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue.rb6
-rw-r--r--app/models/query.rb20
2 files changed, 17 insertions, 9 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 6b9b3bd1c..9d7f6eaaf 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -231,4 +231,10 @@ class Issue < ActiveRecord::Base
def soonest_start
@soonest_start ||= relations_to.collect{|relation| relation.successor_soonest_start}.compact.min
end
+
+ def self.visible_by(usr)
+ with_scope(:find => { :conditions => Project.visible_by(usr) }) do
+ yield
+ end
+ end
end
diff --git a/app/models/query.rb b/app/models/query.rb
index a4103c08a..73828f739 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -83,7 +83,7 @@ class Query < ActiveRecord::Base
@@operators_by_filter_type = { :list => [ "=", "!" ],
:list_status => [ "o", "=", "!", "c", "*" ],
:list_optional => [ "=", "!", "!*", "*" ],
- :list_one_or_more => [ "*", "=" ],
+ :list_subprojects => [ "*", "!*", "=" ],
:date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ],
:date_past => [ ">t-", "<t-", "t-", "t", "w" ],
:string => [ "=", "~", "!", "!~" ],
@@ -163,7 +163,7 @@ class Query < ActiveRecord::Base
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
unless @project.active_children.empty?
- @available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
+ @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
end
@project.all_custom_fields.select(&:is_filter?).each do |field|
case field.field_format
@@ -259,16 +259,18 @@ class Query < ActiveRecord::Base
def statement
# project/subprojects clause
clause = ''
- if project && has_filter?("subproject_id")
- subproject_ids = []
- if operator_for("subproject_id") == "="
- subproject_ids = values_for("subproject_id").each(&:to_i)
+ if project && !@project.active_children.empty?
+ ids = [project.id]
+ if has_filter?("subproject_id") && operator_for("subproject_id") == "="
+ # include the selected subprojects
+ ids += values_for("subproject_id").each(&:to_i)
else
- subproject_ids = project.active_children.collect{|p| p.id}
+ # include all the subprojects unless 'none' is selected
+ ids += project.active_children.collect{|p| p.id} unless has_filter?("subproject_id") && operator_for("subproject_id") == "!*"
end
- clause << "#{Issue.table_name}.project_id IN (%d,%s)" % [project.id, subproject_ids.join(",")] if project
+ clause << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
elsif project
- clause << "#{Issue.table_name}.project_id=%d" % project.id
+ clause << "#{Issue.table_name}.project_id = %d" % project.id
else
clause << Project.visible_by(User.current)
end