]> source.dussan.org Git - redmine.git/commitdiff
Refactor: Extract method for setting the flash on bulk issue saves.
authorEric Davis <edavis@littlestreamsoftware.com>
Thu, 11 Mar 2010 16:34:08 +0000 (16:34 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Thu, 11 Mar 2010 16:34:08 +0000 (16:34 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3560 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb

index df8e32a282bafc27355671fa5029ffe2f2993bb7..cd61fdc37926b8a4075595e5883480efa3e424da 100644 (file)
@@ -262,13 +262,7 @@ class IssuesController < ApplicationController
           unsaved_issue_ids << issue.id
         end
       end
-      if unsaved_issue_ids.empty?
-        flash[:notice] = l(:notice_successful_update) unless @issues.empty?
-      else
-        flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
-                                                         :total => @issues.size,
-                                                         :ids => '#' + unsaved_issue_ids.join(', #'))
-      end
+      set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
       redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
       return
     end
@@ -309,13 +303,8 @@ class IssuesController < ApplicationController
           unsaved_issue_ids << issue.id
         end
       end
-      if unsaved_issue_ids.empty?
-        flash[:notice] = l(:notice_successful_update) unless @issues.empty?
-      else
-        flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
-                                                         :total => @issues.size,
-                                                         :ids => '#' + unsaved_issue_ids.join(', #'))
-      end
+      set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
+
       if params[:follow]
         if @issues.size == 1 && moved_issues.size == 1
           redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
@@ -568,4 +557,15 @@ private
     end
 
   end
+
+  def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
+    if unsaved_issue_ids.empty?
+      flash[:notice] = l(:notice_successful_update) unless issues.empty?
+    else
+      flash[:error] = l(:notice_failed_to_save_issues,
+                        :count => unsaved_issue_ids.size,
+                        :total => issues.size,
+                        :ids => '#' + unsaved_issue_ids.join(', #'))
+    end
+  end
 end