kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.7 KiB
86 lines
2.7 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
|
# ChiliProject is a project management system.
|
||
14 years ago
|
#
|
||
14 years ago
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
||
14 years ago
|
#
|
||
14 years ago
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
14 years ago
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
12 years ago
|
class Issues::MovesController < ApplicationController
|
||
14 years ago
|
default_search_scope :issues
|
||
14 years ago
|
before_filter :find_issues, :check_project_uniqueness
|
||
14 years ago
|
before_filter :authorize
|
||
14 years ago
|
|
||
14 years ago
|
def new
|
||
|
prepare_for_issue_move
|
||
|
render :layout => false if request.xhr?
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
prepare_for_issue_move
|
||
|
|
||
|
if request.post?
|
||
|
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
|
||
|
unsaved_issue_ids = []
|
||
|
moved_issues = []
|
||
|
@issues.each do |issue|
|
||
|
issue.reload
|
||
14 years ago
|
issue.init_journal(User.current, @notes || "")
|
||
14 years ago
|
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
|
||
|
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
|
||
|
moved_issues << r
|
||
|
else
|
||
|
unsaved_issue_ids << issue.id
|
||
|
end
|
||
|
end
|
||
|
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
|
||
|
|
||
|
if params[:follow]
|
||
|
if @issues.size == 1 && moved_issues.size == 1
|
||
12 years ago
|
redirect_to issue_path(moved_issues.first)
|
||
14 years ago
|
else
|
||
12 years ago
|
redirect_to project_issues_path(@target_project || @project)
|
||
14 years ago
|
end
|
||
|
else
|
||
12 years ago
|
redirect_to project_issues_path(@project)
|
||
14 years ago
|
end
|
||
|
return
|
||
|
end
|
||
|
end
|
||
|
|
||
13 years ago
|
def default_breadcrumb
|
||
|
l(:label_move_issue)
|
||
|
end
|
||
|
|
||
14 years ago
|
private
|
||
|
|
||
|
def prepare_for_issue_move
|
||
|
@issues.sort!
|
||
|
@copy = params[:copy_options] && params[:copy_options][:copy]
|
||
|
@allowed_projects = Issue.allowed_target_projects_on_move
|
||
12 years ago
|
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id].to_s} if params[:new_project_id]
|
||
14 years ago
|
@target_project ||= @project
|
||
14 years ago
|
@trackers = @target_project.trackers
|
||
|
@available_statuses = Workflow.available_statuses(@project)
|
||
14 years ago
|
@notes = params[:notes]
|
||
|
@notes ||= ''
|
||
14 years ago
|
end
|
||
|
|
||
|
def extract_changed_attributes_for_move(params)
|
||
|
changed_attributes = {}
|
||
14 years ago
|
[:assigned_to_id, :status_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
|
||
14 years ago
|
unless params[valid_attribute].blank?
|
||
|
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
|
||
|
end
|
||
|
end
|
||
|
changed_attributes
|
||
|
end
|
||
|
|
||
|
end
|