Adds a setting to allow subtasks to belong to other projects (#5487).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10587 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -65,7 +65,7 @@ module IssuesHelper
|
||||
s = ''
|
||||
ancestors = issue.root? ? [] : issue.ancestors.visible.all
|
||||
ancestors.each do |ancestor|
|
||||
s << '<div>' + content_tag('p', link_to_issue(ancestor))
|
||||
s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
|
||||
end
|
||||
s << '<div>'
|
||||
subject = h(issue.subject)
|
||||
@@ -82,7 +82,7 @@ module IssuesHelper
|
||||
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|
|
||||
s << content_tag('tr',
|
||||
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
|
||||
content_tag('td', link_to_issue(child, :truncate => 60), :class => 'subject') +
|
||||
content_tag('td', link_to_issue(child, :truncate => 60, :project => (issue.project_id != child.project_id)), :class => 'subject') +
|
||||
content_tag('td', h(child.status)) +
|
||||
content_tag('td', link_to_user(child.assigned_to)) +
|
||||
content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
|
||||
|
||||
@@ -91,4 +91,16 @@ module SettingsHelper
|
||||
l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
|
||||
:class => notifiable.parent.present? ? "parent" : '').html_safe
|
||||
end
|
||||
|
||||
def cross_project_subtasks_options
|
||||
options = [
|
||||
[:label_disabled, ''],
|
||||
[:label_cross_project_system, 'system'],
|
||||
[:label_cross_project_tree, 'tree'],
|
||||
[:label_cross_project_hierarchy, 'hierarchy'],
|
||||
[:label_cross_project_descendants, 'descendants']
|
||||
]
|
||||
|
||||
options.map {|label, value| [l(label), value.to_s]}
|
||||
end
|
||||
end
|
||||
|
||||
+26
-5
@@ -285,7 +285,8 @@ class Issue < ActiveRecord::Base
|
||||
if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
|
||||
self.fixed_version = nil
|
||||
end
|
||||
if parent && parent.project_id != project_id
|
||||
# Clear the parent task if it's no longer valid
|
||||
unless valid_parent_project?
|
||||
self.parent_issue_id = nil
|
||||
end
|
||||
@custom_field_values = nil
|
||||
@@ -550,8 +551,8 @@ class Issue < ActiveRecord::Base
|
||||
|
||||
# Checks parent issue assignment
|
||||
if @parent_issue
|
||||
if @parent_issue.project_id != project_id
|
||||
errors.add :parent_issue_id, :not_same_project
|
||||
if !valid_parent_project?(@parent_issue)
|
||||
errors.add :parent_issue_id, :invalid
|
||||
elsif !new_record?
|
||||
# moving an existing issue
|
||||
if @parent_issue.root_id != root_id
|
||||
@@ -559,7 +560,7 @@ class Issue < ActiveRecord::Base
|
||||
elsif move_possible?(@parent_issue)
|
||||
# move accepted inside tree
|
||||
else
|
||||
errors.add :parent_issue_id, :not_a_valid_parent
|
||||
errors.add :parent_issue_id, :invalid
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -963,6 +964,25 @@ class Issue < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Returns true if issue's project is a valid
|
||||
# parent issue project
|
||||
def valid_parent_project?(issue=parent)
|
||||
return true if issue.nil? || issue.project_id == project_id
|
||||
|
||||
case Setting.cross_project_subtasks
|
||||
when 'system'
|
||||
true
|
||||
when 'tree'
|
||||
issue.project.root == project.root
|
||||
when 'hierarchy'
|
||||
issue.project.is_or_is_ancestor_of?(project) || issue.project.is_descendant_of?(project)
|
||||
when 'descendants'
|
||||
issue.project.is_or_is_ancestor_of?(project)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# Extracted from the ReportsController.
|
||||
def self.by_tracker(project)
|
||||
count_and_group_by(:project => project,
|
||||
@@ -1042,8 +1062,9 @@ class Issue < ActiveRecord::Base
|
||||
relations_to.clear
|
||||
end
|
||||
|
||||
# Move subtasks
|
||||
# Move subtasks that were in the same project
|
||||
children.each do |child|
|
||||
next unless child.project_id == project_id_was
|
||||
# Change project and keep project
|
||||
child.send :project=, project, true
|
||||
unless child.save
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div class="splitcontentright">
|
||||
<% if @issue.safe_attribute? 'parent_issue_id' %>
|
||||
<p id="parent_issue"><%= f.text_field :parent_issue_id, :size => 10, :required => @issue.required_attribute?('parent_issue_id') %></p>
|
||||
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @issue.project)}')" %>
|
||||
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path}')" %>
|
||||
<% end %>
|
||||
|
||||
<% if @issue.safe_attribute? 'start_date' %>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<div class="box tabular settings">
|
||||
<p><%= setting_check_box :cross_project_issue_relations %></p>
|
||||
|
||||
<p><%= setting_select :cross_project_subtasks, cross_project_subtasks_options %></p>
|
||||
|
||||
<p><%= setting_check_box :issue_group_assignment %></p>
|
||||
|
||||
<p><%= setting_check_box :default_issue_start_date_to_creation_date %></p>
|
||||
|
||||
Reference in New Issue
Block a user