Refactor: extract method from #move and #perform_move.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3932 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-08-10 15:11:11 +00:00
parent 424b482579
commit 52c624aabd
1 changed files with 13 additions and 14 deletions

View File

@ -251,25 +251,14 @@ class IssuesController < ApplicationController
end end
def move def move
@issues.sort! prepare_for_issue_move
@copy = params[:copy_options] && params[:copy_options][:copy]
@allowed_projects = Issue.allowed_target_projects_on_move
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
@target_project ||= @project
@trackers = @target_project.trackers
@available_statuses = Workflow.available_statuses(@project)
render :layout => false if request.xhr? render :layout => false if request.xhr?
end end
# TODO: more descriptive name? move to separate controller like IssueMovesController? # TODO: more descriptive name? move to separate controller like IssueMovesController?
def perform_move def perform_move
@issues.sort! prepare_for_issue_move
@copy = params[:copy_options] && params[:copy_options][:copy]
@allowed_projects = Issue.allowed_target_projects_on_move
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
@target_project ||= @project
@trackers = @target_project.trackers
@available_statuses = Workflow.available_statuses(@project)
if request.post? if request.post?
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id]) new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
unsaved_issue_ids = [] unsaved_issue_ids = []
@ -473,6 +462,16 @@ private
@allowed_statuses = @issue.new_statuses_allowed_to(User.current, true) @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
end end
def prepare_for_issue_move
@issues.sort!
@copy = params[:copy_options] && params[:copy_options][:copy]
@allowed_projects = Issue.allowed_target_projects_on_move
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
@target_project ||= @project
@trackers = @target_project.trackers
@available_statuses = Workflow.available_statuses(@project)
end
def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids) def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids)
if unsaved_issue_ids.empty? if unsaved_issue_ids.empty?
flash[:notice] = l(:notice_successful_update) unless issues.empty? flash[:notice] = l(:notice_successful_update) unless issues.empty?