Permalink
Browse files

Refactor: Extract method for setting the flash on bulk issue saves.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3560 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information...
1 parent 3e2e5a0 commit c7c3c0cc7c7d20407ac5e4a2ecd5d84da01d3788 @edavis10 committed Mar 11, 2010
Showing with 14 additions and 14 deletions.
  1. +14 −14 app/controllers/issues_controller.rb
@@ -262,13 +262,7 @@ def bulk_edit
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 @@ def move
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 @@ def update_issue_from_params
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

0 comments on commit c7c3c0c

Please sign in to comment.