Patch #7447 » move-copy-1.1.0.patch
redmine-1.1.0-move-copy/app/controllers/issue_moves_controller.rb 2011-01-25 18:41:29.448112200 -0700 | ||
---|---|---|
3 | 3 |
before_filter :find_issues, :check_project_uniqueness |
4 | 4 |
before_filter :authorize |
5 | 5 |
|
6 |
helper :issue_relations |
|
7 |
include IssueRelationsHelper |
|
8 |
|
|
6 | 9 |
def new |
7 | 10 |
prepare_for_issue_move |
8 | 11 |
render :layout => false if request.xhr? |
... | ... | |
13 | 16 |
|
14 | 17 |
if request.post? |
15 | 18 |
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id]) |
19 |
relation_type = params[:relation_type].blank? ? nil : params[:relation_type] |
|
16 | 20 |
unsaved_issue_ids = [] |
17 | 21 |
moved_issues = [] |
18 | 22 |
@issues.each do |issue| |
... | ... | |
20 | 24 |
issue.init_journal(User.current) |
21 | 25 |
issue.current_journal.notes = @notes if @notes.present? |
22 | 26 |
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy }) |
23 |
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)}) |
|
27 |
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :relation_type => relation_type, :attributes => extract_changed_attributes_for_move(params)})
|
|
24 | 28 |
moved_issues << r |
25 | 29 |
else |
26 | 30 |
unsaved_issue_ids << issue.id |
... | ... | |
51 | 55 |
@target_project ||= @project |
52 | 56 |
@trackers = @target_project.trackers |
53 | 57 |
@available_statuses = Workflow.available_statuses(@project) |
58 |
@fixed_versions = @target_project.shared_versions.open |
|
59 |
@categories = @target_project.issue_categories |
|
54 | 60 |
@notes = params[:notes] |
55 | 61 |
@notes ||= '' |
56 | 62 |
end |
57 | 63 |
|
58 | 64 |
def extract_changed_attributes_for_move(params) |
59 | 65 |
changed_attributes = {} |
60 |
[:assigned_to_id, :status_id, :start_date, :due_date, :priority_id].each do |valid_attribute| |
|
66 |
[:assigned_to_id, :status_id, :fixed_version_id, :category_id, :start_date, :due_date, :priority_id].each do |valid_attribute|
|
|
61 | 67 |
unless params[valid_attribute].blank? |
62 | 68 |
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute]) |
63 | 69 |
end |
redmine-1.1.0-move-copy/app/models/issue.rb 2011-01-25 18:41:29.463737100 -0700 | ||
---|---|---|
177 | 177 |
end |
178 | 178 |
end |
179 | 179 |
end |
180 |
if options[:relation_type] |
|
181 |
relation = IssueRelation.new( |
|
182 |
:relation_type => options[:relation_type], |
|
183 |
:issue_from => self, |
|
184 |
:issue_to => issue) |
|
185 |
unless relation.save |
|
186 |
issue.destroy |
|
187 |
return false |
|
188 |
end |
|
189 |
end |
|
180 | 190 |
else |
181 | 191 |
return false |
182 | 192 |
end |
redmine-1.1.0-move-copy/app/views/issue_moves/new.rhtml 2011-01-25 19:25:13.243819800 -0700 | ||
---|---|---|
10 | 10 |
<%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join %> |
11 | 11 |
|
12 | 12 |
<div class="box tabular"> |
13 |
<fieldset class="attributes"> |
|
14 |
<legend><%= l(:label_change_properties) %></legend> |
|
15 | 13 |
|
16 |
<div class="splitcontentleft"> |
|
17 |
<p><label for="new_project_id"><%=l(:field_project)%>:</label> |
|
14 |
<fieldset> |
|
15 |
|
|
16 |
<p><label for="new_project_id"><%=l(:field_project)%></label> |
|
18 | 17 |
<%= select_tag "new_project_id", |
19 | 18 |
project_tree_options_for_select(@allowed_projects, :selected => @target_project), |
20 | 19 |
:onchange => remote_function(:url => { :action => 'new' }, |
... | ... | |
22 | 21 |
:update => 'content', |
23 | 22 |
:with => "Form.serialize('move_form')") %></p> |
24 | 23 |
|
25 |
<p><label for="new_tracker_id"><%=l(:field_tracker)%>:</label> |
|
26 |
<%= select_tag "new_tracker_id", "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@trackers, "id", "name") %></p> |
|
24 |
<% if @copy && (@project == @target_project || Setting.cross_project_issue_relations?) %> |
|
25 |
<p> |
|
26 |
<label for="relation_type"><%= l(:label_relation_new) %></label> |
|
27 |
<%= select_tag('relation_type', content_tag('option', l(:label_none), :value => '') + |
|
28 |
options_for_select(collection_for_relation_type_select)) %> |
|
29 |
</p> |
|
30 |
<% end %> |
|
31 |
|
|
32 |
</fieldset> |
|
33 |
|
|
34 |
<fieldset class="attributes"> |
|
35 |
<legend><%= l(:label_change_properties) %></legend> |
|
36 |
|
|
37 |
<div class="splitcontentleft"> |
|
38 |
|
|
39 |
<p><label for="new_tracker_id"><%=l(:field_tracker)%></label> |
|
40 |
<%= select_tag "new_tracker_id", content_tag('option', l(:label_no_change_option), :value => '') + |
|
41 |
options_from_collection_for_select(@trackers, "id", "name") %></p> |
|
27 | 42 |
|
28 | 43 |
<p> |
29 | 44 |
<label><%= l(:field_status) %></label> |
30 |
<%= select_tag('status_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(@available_statuses, :id, :name)) %> |
|
45 |
<%= select_tag('status_id', content_tag('option', l(:label_no_change_option), :value => '') + |
|
46 |
options_from_collection_for_select(@available_statuses, :id, :name)) %> |
|
31 | 47 |
</p> |
32 | 48 |
|
33 | 49 |
<p> |
34 | 50 |
<label><%= l(:field_priority) %></label> |
35 |
<%= select_tag('priority_id', "<option value=\"\">#{l(:label_no_change_option)}</option>" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %> |
|
51 |
<%= select_tag('priority_id', content_tag('option', l(:label_no_change_option), :value => '') + |
|
52 |
options_from_collection_for_select(IssuePriority.all, :id, :name)) %> |
|
36 | 53 |
</p> |
37 | 54 |
|
38 | 55 |
<p> |
... | ... | |
41 | 58 |
content_tag('option', l(:label_nobody), :value => 'none') + |
42 | 59 |
options_from_collection_for_select(@target_project.assignable_users, :id, :name)) %> |
43 | 60 |
</p> |
61 |
|
|
62 |
<% if !@categories.empty? %> |
|
63 |
<p> |
|
64 |
<label><%= l(:field_category) %></label> |
|
65 |
<%= select_tag('category_id', content_tag('option', l(:label_no_change_option), :value => '') + |
|
66 |
content_tag('option', l(:label_none), :value => 'none') + |
|
67 |
options_from_collection_for_select(@categories, :id, :name)) %> |
|
68 |
</p> |
|
69 |
<% end %> |
|
70 |
|
|
71 |
<% if !@fixed_versions.empty? %> |
|
72 |
<p> |
|
73 |
<label><%=l(:field_fixed_version) %></label> |
|
74 |
<%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') + |
|
75 |
content_tag('option', l(:label_none), :value => 'none') + |
|
76 |
options_from_collection_for_select(@fixed_versions, :id, :name)) %> |
|
77 |
</p> |
|
78 |
<% end %> |
|
79 |
|
|
44 | 80 |
</div> |
45 | 81 |
|
46 | 82 |
<div class="splitcontentright"> |
83 |
|
|
47 | 84 |
<p> |
48 | 85 |
<label><%= l(:field_start_date) %></label> |
49 | 86 |
<%= text_field_tag 'start_date', '', :size => 10 %><%= calendar_for('start_date') %> |
- « Previous
- 1
- 2
- Next »