diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-30 11:24:00 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-30 11:24:00 +0000 |
commit | bfdd9f7c295d539a9f8aeb22f965a620ea415224 (patch) | |
tree | 49e3795d74c6b92f5989b4ce986a3d4f102490f1 /app/helpers | |
parent | 1699e37a0cad57f20ca1c8395314901dc59010f3 (diff) | |
download | redmine-bfdd9f7c295d539a9f8aeb22f965a620ea415224.tar.gz redmine-bfdd9f7c295d539a9f8aeb22f965a620ea415224.zip |
The descendant count in the issues delete confirmation message is wrong if issues share some descendants.
git-svn-id: http://svn.redmine.org/redmine/trunk@13818 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/issues_helper.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 47f972552..44b8e1be4 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -180,20 +180,20 @@ module IssuesHelper s.html_safe end + # Returns the number of descendants for an array of issues + def issues_descendant_count(issues) + ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq + ids -= issues.map(&:id) + ids.size + 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} + + descendant_count = issues_descendant_count(issues) 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 + message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count) end message end |