Commit f367717d authored by jplang's avatar jplang

Warn about subtasks before deleting a parent issue (#6562).

git-svn-id: https://svn.redmine.org/redmine/trunk@5495 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 49f3f21a
class ContextMenusController < ApplicationController
helper :watchers
helper :issues
def issues
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
......
......@@ -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
......
......@@ -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>
......@@ -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>
......@@ -960,3 +960,4 @@ bg:
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -973,3 +973,4 @@ bs:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -962,3 +962,4 @@ ca:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -963,3 +963,4 @@ cs:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -975,3 +975,4 @@ da:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -976,3 +976,4 @@ de:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -959,3 +959,4 @@ el:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -962,3 +962,4 @@ en-GB:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -906,6 +906,7 @@ en:
text_status_changed_by_changeset: "Applied in changeset %{value}."
text_time_logged_by_changeset: "Applied in changeset %{value}."
text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
text_issues_destroy_descendants_confirmation: "This will also delete %{count} subtask(s)."
text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
text_select_project_modules: 'Select modules to enable for this project:'
text_default_administrator_account_changed: Default administrator account changed
......
......@@ -996,3 +996,4 @@ es:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -963,3 +963,4 @@ eu:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -962,3 +962,4 @@ fa:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -980,3 +980,4 @@ fi:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -883,7 +883,8 @@ fr:
text_load_default_configuration: Charger le paramétrage par défaut
text_status_changed_by_changeset: "Appliqué par commit %{value}."
text_time_logged_by_changeset: "Appliqué par commit %{value}"
text_issues_destroy_confirmation: 'Êtes-vous sûr de vouloir supprimer le(s) demandes(s) selectionnée(s) ?'
text_issues_destroy_confirmation: 'Êtes-vous sûr de vouloir supprimer la ou les demandes(s) selectionnée(s) ?'
text_issues_destroy_descendants_confirmation: "Cela entrainera également la suppression de %{count} sous-tâche(s)."
text_select_project_modules: 'Sélectionner les modules à activer pour ce projet :'
text_default_administrator_account_changed: Compte administrateur par défaut changé
text_file_repository_writable: Répertoire de stockage des fichiers accessible en écriture
......
......@@ -971,3 +971,4 @@ gl:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -964,3 +964,4 @@ he:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -966,3 +966,4 @@ hr:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -978,3 +978,4 @@
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -967,3 +967,4 @@ id:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -960,3 +960,4 @@ it:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -982,3 +982,4 @@ ja:
field_is_private: プライベート
permission_set_issues_private: チケットをプライベートに設定
label_issues_visibility_public: プライベートチケット以外
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -1011,3 +1011,4 @@ ko:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -1019,3 +1019,4 @@ lt:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -954,3 +954,4 @@ lv:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -959,3 +959,4 @@ mk:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -960,3 +960,4 @@ mn:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -941,3 +941,4 @@ nl:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -946,3 +946,4 @@
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -976,3 +976,4 @@ pl:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -979,3 +979,4 @@ pt-BR:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -964,3 +964,4 @@ pt:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -952,3 +952,4 @@ ro:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -1072,3 +1072,4 @@ ru:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -954,3 +954,4 @@ sk:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -955,3 +955,4 @@ sl:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -959,3 +959,4 @@ sr-YU:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -960,3 +960,4 @@ sr:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -1000,3 +1000,4 @@ sv:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -956,3 +956,4 @@ th:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -978,3 +978,4 @@ tr:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -955,3 +955,4 @@ uk:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -1010,3 +1010,4 @@ vi:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -1041,3 +1041,4 @@
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -973,3 +973,4 @@ zh:
field_is_private: Private
permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).
......@@ -47,6 +47,25 @@ class IssuesHelperTest < HelperTestCase
def test_issue_heading
assert_equal "Bug #1", issue_heading(Issue.find(1))
end
def test_issues_destroy_confirmation_message_with_one_root_issue
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
end
def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
end
def test_issues_destroy_confirmation_message_with_one_parent_issue
Issue.find(2).update_attribute :parent_issue_id, 1
assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
issues_destroy_confirmation_message(Issue.find(1))
end
def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
Issue.find(2).update_attribute :parent_issue_id, 1
assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
end
context "IssuesHelper#show_detail" do
context "with no_html" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment