git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2316 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.9.0
@@ -232,6 +232,7 @@ class IssuesController < ApplicationController | |||
assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id]) | |||
category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id]) | |||
fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id]) | |||
custom_field_values = params[:custom_field_values] ? params[:custom_field_values].reject {|k,v| v.blank?} : nil | |||
unsaved_issue_ids = [] | |||
@issues.each do |issue| | |||
@@ -243,6 +244,7 @@ class IssuesController < ApplicationController | |||
issue.start_date = params[:start_date] unless params[:start_date].blank? | |||
issue.due_date = params[:due_date] unless params[:due_date].blank? | |||
issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank? | |||
issue.custom_field_values = custom_field_values if custom_field_values && !custom_field_values.empty? | |||
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) | |||
# Don't save any change to the issue if the user is not authorized to apply the requested status | |||
if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save | |||
@@ -264,6 +266,7 @@ class IssuesController < ApplicationController | |||
# Find potential statuses the user could be allowed to switch issues to | |||
@available_statuses = Workflow.find(:all, :include => :new_status, | |||
:conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort | |||
@custom_fields = @project.issue_custom_fields.select {|f| f.field_format == 'list'} | |||
end | |||
def move |
@@ -38,6 +38,13 @@ | |||
<label><%= l(:field_done_ratio) %>: | |||
<%= select_tag 'done_ratio', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></label> | |||
</p> | |||
<% @custom_fields.each do |custom_field| %> | |||
<p><label><%= h(custom_field.name) %></label> | |||
<%= select_tag "custom_field_values[#{custom_field.id}]", options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values) %></label> | |||
</p> | |||
<% end %> | |||
<%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %> | |||
</fieldset> | |||
@@ -629,11 +629,36 @@ class IssuesControllerTest < Test::Unit::TestCase | |||
def test_bulk_edit | |||
@request.session[:user_id] = 2 | |||
# update issues priority | |||
post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' | |||
post :bulk_edit, :ids => [1, 2], :priority_id => 7, | |||
:assigned_to_id => '', | |||
:custom_field_values => {'2' => ''}, | |||
:notes => 'Bulk editing' | |||
assert_response 302 | |||
# check that the issues were updated | |||
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} | |||
assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes | |||
issue = Issue.find(1) | |||
journal = issue.journals.find(:first, :order => 'created_on DESC') | |||
assert_equal '125', issue.custom_value_for(2).value | |||
assert_equal 'Bulk editing', journal.notes | |||
assert_equal 1, journal.details.size | |||
end | |||
def test_bulk_edit_custom_field | |||
@request.session[:user_id] = 2 | |||
# update issues priority | |||
post :bulk_edit, :ids => [1, 2], :priority_id => '', | |||
:assigned_to_id => '', | |||
:custom_field_values => {'2' => '777'}, | |||
:notes => 'Bulk editing custom field' | |||
assert_response 302 | |||
issue = Issue.find(1) | |||
journal = issue.journals.find(:first, :order => 'created_on DESC') | |||
assert_equal '777', issue.custom_value_for(2).value | |||
assert_equal 1, journal.details.size | |||
assert_equal '125', journal.details.first.old_value | |||
assert_equal '777', journal.details.first.value | |||
end | |||
def test_bulk_unassign |