@@ -218,24 +218,41 class IssuesController < ApplicationController | |||||
218 | end |
|
218 | end | |
219 | end |
|
219 | end | |
220 |
|
220 | |||
|
221 | edited_issues = Issue.where(:id => @issues.map(&:id)).to_a | |||
|
222 | ||||
221 | @allowed_projects = Issue.allowed_target_projects |
|
223 | @allowed_projects = Issue.allowed_target_projects | |
222 | if params[:issue] |
|
224 | if params[:issue] | |
223 | @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} |
|
225 | @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} | |
224 | if @target_project |
|
226 | if @target_project | |
225 | target_projects = [@target_project] |
|
227 | target_projects = [@target_project] | |
|
228 | edited_issues.each {|issue| issue.project = @target_project} | |||
226 | end |
|
229 | end | |
227 | end |
|
230 | end | |
228 | target_projects ||= @projects |
|
231 | target_projects ||= @projects | |
229 |
|
232 | |||
|
233 | @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&) | |||
|
234 | if params[:issue] | |||
|
235 | @target_tracker = @trackers.detect {|t| t.id.to_s == params[:issue][:tracker_id].to_s} | |||
|
236 | if @target_tracker | |||
|
237 | edited_issues.each {|issue| issue.tracker = @target_tracker} | |||
|
238 | end | |||
|
239 | end | |||
|
240 | ||||
230 | if @copy |
|
241 | if @copy | |
231 | # Copied issues will get their default statuses |
|
242 | # Copied issues will get their default statuses | |
232 | @available_statuses = [] |
|
243 | @available_statuses = [] | |
233 | else |
|
244 | else | |
234 |
@available_statuses = |
|
245 | @available_statuses = edited_issues.map(&:new_statuses_allowed_to).reduce(:&) | |
235 | end |
|
246 | end | |
236 | @custom_fields = @issues.map{|i|i.editable_custom_fields}.reduce(:&) |
|
247 | if params[:issue] | |
|
248 | @target_status = @available_statuses.detect {|t| t.id.to_s == params[:issue][:status_id].to_s} | |||
|
249 | if @target_status | |||
|
250 | edited_issues.each {|issue| issue.status = @target_status} | |||
|
251 | end | |||
|
252 | end | |||
|
253 | ||||
|
254 | @custom_fields = edited_issues.map{|i|i.editable_custom_fields}.reduce(:&) | |||
237 | @assignables = target_projects.map(&:assignable_users).reduce(:&) |
|
255 | @assignables = target_projects.map(&:assignable_users).reduce(:&) | |
238 | @trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&) |
|
|||
239 | @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) |
|
256 | @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) | |
240 | @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) |
|
257 | @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) | |
241 | if @copy |
|
258 | if @copy | |
@@ -243,7 +260,7 class IssuesController < ApplicationController | |||||
243 | @subtasks_present = @issues.detect {|i| !i.leaf?}.present? |
|
260 | @subtasks_present = @issues.detect {|i| !i.leaf?}.present? | |
244 | end |
|
261 | end | |
245 |
|
262 | |||
246 |
@safe_attributes = |
|
263 | @safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&) | |
247 |
|
264 | |||
248 | @issue_params = params[:issue] || {} |
|
265 | @issue_params = params[:issue] || {} | |
249 | @issue_params[:custom_field_values] ||= {} |
|
266 | @issue_params[:custom_field_values] ||= {} |
@@ -43,14 +43,16 | |||||
43 | <label for="issue_tracker_id"><%= l(:field_tracker) %></label> |
|
43 | <label for="issue_tracker_id"><%= l(:field_tracker) %></label> | |
44 | <%= select_tag('issue[tracker_id]', |
|
44 | <%= select_tag('issue[tracker_id]', | |
45 | content_tag('option', l(:label_no_change_option), :value => '') + |
|
45 | content_tag('option', l(:label_no_change_option), :value => '') + | |
46 |
options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id]) |
|
46 | options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id]), | |
|
47 | :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %> | |||
47 | </p> |
|
48 | </p> | |
48 | <% if @available_statuses.any? %> |
|
49 | <% if @available_statuses.any? %> | |
49 | <p> |
|
50 | <p> | |
50 | <label for='issue_status_id'><%= l(:field_status) %></label> |
|
51 | <label for='issue_status_id'><%= l(:field_status) %></label> | |
51 | <%= select_tag('issue[status_id]', |
|
52 | <%= select_tag('issue[status_id]', | |
52 | content_tag('option', l(:label_no_change_option), :value => '') + |
|
53 | content_tag('option', l(:label_no_change_option), :value => '') + | |
53 |
options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id]) |
|
54 | options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id]), | |
|
55 | :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %> | |||
54 | </p> |
|
56 | </p> | |
55 | <% end %> |
|
57 | <% end %> | |
56 |
|
58 |
@@ -3996,6 +3996,20 class IssuesControllerTest < Redmine::ControllerTest | |||||
3996 | assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]", 0 |
|
3996 | assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]", 0 | |
3997 | end |
|
3997 | end | |
3998 |
|
3998 | |||
|
3999 | def test_bulk_edit_should_propose_target_tracker_custom_fields | |||
|
4000 | IssueCustomField.delete_all | |||
|
4001 | field1 = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true) | |||
|
4002 | field2 = IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true) | |||
|
4003 | @request.session[:user_id] = 2 | |||
|
4004 | ||||
|
4005 | issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids | |||
|
4006 | get :bulk_edit, :ids => issue_ids, :issue => {:tracker_id => 2} | |||
|
4007 | assert_response :success | |||
|
4008 | ||||
|
4009 | assert_select 'input[name=?]', "issue[custom_field_values][#{field1.id}]", 0 | |||
|
4010 | assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]" | |||
|
4011 | end | |||
|
4012 | ||||
3999 | def test_bulk_update |
|
4013 | def test_bulk_update | |
4000 | @request.session[:user_id] = 2 |
|
4014 | @request.session[:user_id] = 2 | |
4001 | # update issues priority |
|
4015 | # update issues priority |
General Comments 0
You need to be logged in to leave comments.
Login now