summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-04-17 15:17:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-04-17 15:17:18 +0000
commitf89d04074e56ea64845a681b83896b0bea163363 (patch)
tree8905f78979f949be602e41d44670f189e6495204 /app
parenta96f7053fc89d38ac4b5734e4515b4ae7550f4d1 (diff)
downloadredmine-f89d04074e56ea64845a681b83896b0bea163363.tar.gz
redmine-f89d04074e56ea64845a681b83896b0bea163363.zip
Warn about subtasks before deleting a parent issue (#6562).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5495 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/context_menus_controller.rb1
-rw-r--r--app/helpers/issues_helper.rb18
-rw-r--r--app/views/context_menus/issues.html.erb2
-rw-r--r--app/views/issues/_action_menu.rhtml2
4 files changed, 21 insertions, 2 deletions
diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb
index f2ff7020e..4d69f4f04 100644
--- a/app/controllers/context_menus_controller.rb
+++ b/app/controllers/context_menus_controller.rb
@@ -1,5 +1,6 @@
class ContextMenusController < ApplicationController
helper :watchers
+ helper :issues
def issues
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 86f11c706..078fca656 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -109,6 +109,24 @@ module IssuesHelper
s
end
+ def issues_destroy_confirmation_message(issues)
+ issues = [issues] unless issues.is_a?(Array)
+ message = l(:text_issues_destroy_confirmation)
+ descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
+ if descendant_count > 0
+ issues.each do |issue|
+ next if issue.root?
+ issues.each do |other_issue|
+ descendant_count -= 1 if issue.is_descendant_of?(other_issue)
+ end
+ end
+ if descendant_count > 0
+ message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
+ end
+ end
+ message
+ end
+
def sidebar_queries
unless @sidebar_queries
# User can see public queries and his own queries
diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb
index f0fa350ac..7b67c65c7 100644
--- a/app/views/context_menus/issues.html.erb
+++ b/app/views/context_menus/issues.html.erb
@@ -115,7 +115,7 @@
<li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
:class => 'icon-move', :disabled => !@can[:move] %></li>
<li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id), :back_url => @back},
- :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
+ :method => :post, :confirm => issues_destroy_confirmation_message(@issues), :class => 'icon-del', :disabled => !@can[:delete] %></li>
<%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
</ul>
diff --git a/app/views/issues/_action_menu.rhtml b/app/views/issues/_action_menu.rhtml
index 67eec6c78..02357751f 100644
--- a/app/views/issues/_action_menu.rhtml
+++ b/app/views/issues/_action_menu.rhtml
@@ -5,5 +5,5 @@
<%= link_to_if_authorized l(:button_duplicate), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-duplicate' %>
<%= link_to_if_authorized l(:button_copy), {:controller => 'issue_moves', :action => 'new', :id => @issue, :copy_options => {:copy => 't'}}, :class => 'icon icon-copy' %>
<%= link_to_if_authorized l(:button_move), {:controller => 'issue_moves', :action => 'new', :id => @issue}, :class => 'icon icon-move' %>
-<%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => (@issue.leaf? ? l(:text_are_you_sure) : l(:text_are_you_sure_with_children)), :method => :post, :class => 'icon icon-del' %>
+<%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => issues_destroy_confirmation_message(@issue), :method => :post, :class => 'icon icon-del' %>
</div>