mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-30 12:19:38 +00:00
Bulk edit form not show fields based on target tracker and status (#23755).
git-svn-id: http://svn.redmine.org/redmine/trunk@15815 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fa3a167cdf
commit
dcf2e15b06
@ -218,24 +218,41 @@ class IssuesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
edited_issues = Issue.where(:id => @issues.map(&:id)).to_a
|
||||
|
||||
@allowed_projects = Issue.allowed_target_projects
|
||||
if params[:issue]
|
||||
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
|
||||
if @target_project
|
||||
target_projects = [@target_project]
|
||||
edited_issues.each {|issue| issue.project = @target_project}
|
||||
end
|
||||
end
|
||||
target_projects ||= @projects
|
||||
|
||||
@trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
|
||||
if params[:issue]
|
||||
@target_tracker = @trackers.detect {|t| t.id.to_s == params[:issue][:tracker_id].to_s}
|
||||
if @target_tracker
|
||||
edited_issues.each {|issue| issue.tracker = @target_tracker}
|
||||
end
|
||||
end
|
||||
|
||||
if @copy
|
||||
# Copied issues will get their default statuses
|
||||
@available_statuses = []
|
||||
else
|
||||
@available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||
@available_statuses = edited_issues.map(&:new_statuses_allowed_to).reduce(:&)
|
||||
end
|
||||
@custom_fields = @issues.map{|i|i.editable_custom_fields}.reduce(:&)
|
||||
if params[:issue]
|
||||
@target_status = @available_statuses.detect {|t| t.id.to_s == params[:issue][:status_id].to_s}
|
||||
if @target_status
|
||||
edited_issues.each {|issue| issue.status = @target_status}
|
||||
end
|
||||
end
|
||||
|
||||
@custom_fields = edited_issues.map{|i|i.editable_custom_fields}.reduce(:&)
|
||||
@assignables = target_projects.map(&:assignable_users).reduce(:&)
|
||||
@trackers = target_projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
|
||||
@versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
|
||||
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
|
||||
if @copy
|
||||
@ -243,7 +260,7 @@ class IssuesController < ApplicationController
|
||||
@subtasks_present = @issues.detect {|i| !i.leaf?}.present?
|
||||
end
|
||||
|
||||
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
||||
@safe_attributes = edited_issues.map(&:safe_attribute_names).reduce(:&)
|
||||
|
||||
@issue_params = params[:issue] || {}
|
||||
@issue_params[:custom_field_values] ||= {}
|
||||
|
||||
@ -43,14 +43,16 @@
|
||||
<label for="issue_tracker_id"><%= l(:field_tracker) %></label>
|
||||
<%= select_tag('issue[tracker_id]',
|
||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
||||
options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id])) %>
|
||||
options_from_collection_for_select(@trackers, :id, :name, @issue_params[:tracker_id]),
|
||||
:onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
|
||||
</p>
|
||||
<% if @available_statuses.any? %>
|
||||
<p>
|
||||
<label for='issue_status_id'><%= l(:field_status) %></label>
|
||||
<%= select_tag('issue[status_id]',
|
||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
||||
options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id])) %>
|
||||
options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id]),
|
||||
:onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
@ -3996,6 +3996,20 @@ class IssuesControllerTest < Redmine::ControllerTest
|
||||
assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]", 0
|
||||
end
|
||||
|
||||
def test_bulk_edit_should_propose_target_tracker_custom_fields
|
||||
IssueCustomField.delete_all
|
||||
field1 = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true)
|
||||
field2 = IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true)
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids
|
||||
get :bulk_edit, :ids => issue_ids, :issue => {:tracker_id => 2}
|
||||
assert_response :success
|
||||
|
||||
assert_select 'input[name=?]', "issue[custom_field_values][#{field1.id}]", 0
|
||||
assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]"
|
||||
end
|
||||
|
||||
def test_bulk_update
|
||||
@request.session[:user_id] = 2
|
||||
# update issues priority
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user