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
This commit is contained in:
Jean-Philippe Lang 2011-04-17 15:17:18 +00:00
parent a96f7053fc
commit f89d04074e
49 changed files with 85 additions and 3 deletions

View File

@ -1,5 +1,6 @@
class ContextMenusController < ApplicationController class ContextMenusController < ApplicationController
helper :watchers helper :watchers
helper :issues
def issues def issues
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)

View File

@ -109,6 +109,24 @@ module IssuesHelper
s s
end 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 def sidebar_queries
unless @sidebar_queries unless @sidebar_queries
# User can see public queries and his own queries # User can see public queries and his own queries

View File

@ -115,7 +115,7 @@
<li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)), <li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
:class => 'icon-move', :disabled => !@can[:move] %></li> :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}, <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 }) %> <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
</ul> </ul>

View File

@ -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_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_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_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> </div>

View File

@ -960,3 +960,4 @@ bg:
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -973,3 +973,4 @@ bs:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -962,3 +962,4 @@ ca:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -963,3 +963,4 @@ cs:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -975,3 +975,4 @@ da:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -976,3 +976,4 @@ de:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -959,3 +959,4 @@ el:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -962,3 +962,4 @@ en-GB:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -906,6 +906,7 @@ en:
text_status_changed_by_changeset: "Applied in changeset %{value}." text_status_changed_by_changeset: "Applied in changeset %{value}."
text_time_logged_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_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_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_select_project_modules: 'Select modules to enable for this project:'
text_default_administrator_account_changed: Default administrator account changed text_default_administrator_account_changed: Default administrator account changed

View File

@ -996,3 +996,4 @@ es:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -963,3 +963,4 @@ eu:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -962,3 +962,4 @@ fa:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -980,3 +980,4 @@ fi:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -883,7 +883,8 @@ fr:
text_load_default_configuration: Charger le paramétrage par défaut text_load_default_configuration: Charger le paramétrage par défaut
text_status_changed_by_changeset: "Appliqué par commit %{value}." text_status_changed_by_changeset: "Appliqué par commit %{value}."
text_time_logged_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_select_project_modules: 'Sélectionner les modules à activer pour ce projet :'
text_default_administrator_account_changed: Compte administrateur par défaut changé text_default_administrator_account_changed: Compte administrateur par défaut changé
text_file_repository_writable: Répertoire de stockage des fichiers accessible en écriture text_file_repository_writable: Répertoire de stockage des fichiers accessible en écriture

View File

@ -971,3 +971,4 @@ gl:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -964,3 +964,4 @@ he:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -966,3 +966,4 @@ hr:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -978,3 +978,4 @@
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -967,3 +967,4 @@ id:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -960,3 +960,4 @@ it:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -982,3 +982,4 @@ ja:
field_is_private: プライベート field_is_private: プライベート
permission_set_issues_private: チケットをプライベートに設定 permission_set_issues_private: チケットをプライベートに設定
label_issues_visibility_public: プライベートチケット以外 label_issues_visibility_public: プライベートチケット以外
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -1011,3 +1011,4 @@ ko:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -1019,3 +1019,4 @@ lt:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -954,3 +954,4 @@ lv:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -959,3 +959,4 @@ mk:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -960,3 +960,4 @@ mn:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -941,3 +941,4 @@ nl:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -946,3 +946,4 @@
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -976,3 +976,4 @@ pl:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -979,3 +979,4 @@ pt-BR:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -964,3 +964,4 @@ pt:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -952,3 +952,4 @@ ro:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -1072,3 +1072,4 @@ ru:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -954,3 +954,4 @@ sk:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -955,3 +955,4 @@ sl:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -959,3 +959,4 @@ sr-YU:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -960,3 +960,4 @@ sr:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -1000,3 +1000,4 @@ sv:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -956,3 +956,4 @@ th:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -978,3 +978,4 @@ tr:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -955,3 +955,4 @@ uk:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -1010,3 +1010,4 @@ vi:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -1041,3 +1041,4 @@
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -973,3 +973,4 @@ zh:
field_is_private: Private field_is_private: Private
permission_set_issues_private: Set issues public or private permission_set_issues_private: Set issues public or private
label_issues_visibility_public: All non private issues label_issues_visibility_public: All non private issues
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s).

View File

@ -48,6 +48,25 @@ class IssuesHelperTest < HelperTestCase
assert_equal "Bug #1", issue_heading(Issue.find(1)) assert_equal "Bug #1", issue_heading(Issue.find(1))
end 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 "IssuesHelper#show_detail" do
context "with no_html" do context "with no_html" do
should 'show a changing attribute' do should 'show a changing attribute' do