Patch #7447 » move-copy-1.0.4.patch
| redmine-1.0.4-enhanced-move-copy/app/controllers/issue_moves_controller.rb 2011-01-25 10:30:38.585414500 -0700 | ||
|---|---|---|
|
before_filter :find_issues
|
||
|
before_filter :authorize
|
||
|
|
||
|
helper :issue_relations
|
||
|
include IssueRelationsHelper
|
||
|
|
||
|
def new
|
||
|
prepare_for_issue_move
|
||
|
render :layout => false if request.xhr?
|
||
| ... | ... | |
|
|
||
|
if request.post?
|
||
|
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
|
||
|
relation_type = params[:relation_type].blank? ? nil : params[:relation_type]
|
||
|
unsaved_issue_ids = []
|
||
|
moved_issues = []
|
||
|
@issues.each do |issue|
|
||
| ... | ... | |
|
issue.init_journal(User.current)
|
||
|
issue.current_journal.notes = @notes if @notes.present?
|
||
|
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)})
|
||
|
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :relation_type => relation_type, :attributes => extract_changed_attributes_for_move(params)})
|
||
|
moved_issues << r
|
||
|
else
|
||
|
unsaved_issue_ids << issue.id
|
||
| ... | ... | |
|
@target_project ||= @project
|
||
|
@trackers = @target_project.trackers
|
||
|
@available_statuses = Workflow.available_statuses(@project)
|
||
|
@fixed_versions = @target_project.shared_versions.open
|
||
|
@categories = @target_project.issue_categories
|
||
|
@notes = params[:notes]
|
||
|
@notes ||= ''
|
||
|
end
|
||
|
|
||
|
def extract_changed_attributes_for_move(params)
|
||
|
changed_attributes = {}
|
||
|
[:assigned_to_id, :status_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
|
||
|
[:assigned_to_id, :status_id, :fixed_version_id, :category_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
|
||
|
unless params[valid_attribute].blank?
|
||
|
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
|
||
|
end
|
||
| redmine-1.0.4-enhanced-move-copy/app/models/issue.rb 2011-01-25 10:36:45.758484200 -0700 | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
end
|
||
|
if options[:relation_type]
|
||
|
relation = IssueRelation.new(
|
||
|
:relation_type => options[:relation_type],
|
||
|
:issue_from => self,
|
||
|
:issue_to => issue)
|
||
|
unless relation.save
|
||
|
issue.destroy
|
||
|
return false
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
return false
|
||
|
end
|
||
| redmine-1.0.4-enhanced-move-copy/app/views/issue_moves/new.rhtml 2011-01-25 10:29:49.163223200 -0700 | ||
|---|---|---|
|
<%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join %>
|
||
|
|
||
|
<div class="box tabular">
|
||
|
<p><label for="new_project_id"><%=l(:field_project)%>:</label>
|
||
|
|
||
|
<fieldset>
|
||
|
|
||
|
<p><label for="new_project_id"><%=l(:field_project)%></label>
|
||
|
<%= select_tag "new_project_id",
|
||
|
project_tree_options_for_select(@allowed_projects, :selected => @target_project),
|
||
|
:onchange => remote_function(:url => { :action => 'new' },
|
||
| ... | ... | |
|
:update => 'content',
|
||
|
:with => "Form.serialize('move_form')") %></p>
|
||
|
|
||
|
<p><label for="new_tracker_id"><%=l(:field_tracker)%>:</label>
|
||
|
<p><label for="new_tracker_id"><%=l(:field_tracker)%></label>
|
||
|
<%= select_tag "new_tracker_id", "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@trackers, "id", "name") %></p>
|
||
|
|
||
|
<% if @copy && (@project == @target_project || Setting.cross_project_issue_relations?) %>
|
||
|
<p>
|
||
|
<label for="relation_type"><%= l(:label_relation_new) %></label>
|
||
|
<%= select_tag('relation_type', "<option value=\"\">#{l(:label_none)}</option>" + options_for_select(collection_for_relation_type_select)) %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
|
||
|
</fieldset>
|
||
|
|
||
|
<fieldset><legend><%= l(:label_attribute_plural) %></legend>
|
||
|
|
||
|
<div class="splitcontentleft">
|
||
|
|
||
|
<p>
|
||
|
<label><%= l(:field_assigned_to) %></label>
|
||
|
<%= select_tag('assigned_to_id', content_tag('option', l(:label_no_change_option), :value => '') +
|
||
| ... | ... | |
|
options_from_collection_for_select(@target_project.assignable_users, :id, :name)) %>
|
||
|
</p>
|
||
|
|
||
|
<% if !@categories.empty? %>
|
||
|
<p>
|
||
|
<label><%= l(:field_category) %></label>
|
||
|
<%= select_tag('category_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@categories, :id, :name)) %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
|
||
|
<% if !@fixed_versions.empty? %>
|
||
|
<p>
|
||
|
<label><%=l(:field_fixed_version) %></label>
|
||
|
<%= select_tag('fixed_version_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@fixed_versions, :id, :name)) %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="splitcontentright">
|
||
|
|
||
|
<p>
|
||
|
<label><%= l(:field_status) %></label>
|
||
|
<%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %>
|
||
| ... | ... | |
|
<%= text_field_tag 'due_date', '', :size => 10 %><%= calendar_for('due_date') %>
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
</fieldset>
|
||
|
|
||
|
<fieldset><legend><%= l(:field_notes) %></legend>
|
||
|
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
|
||
|
<%= wikitoolbar_for 'notes' %>
|
||