@@ -420,7 +420,16 private | |||||
420 | def parse_params_for_bulk_issue_attributes(params) |
|
420 | def parse_params_for_bulk_issue_attributes(params) | |
421 | attributes = (params[:issue] || {}).reject {|k,v| v.blank?} |
|
421 | attributes = (params[:issue] || {}).reject {|k,v| v.blank?} | |
422 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} |
|
422 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} | |
423 | attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values] |
|
423 | if custom = attributes[:custom_field_values] | |
|
424 | custom.reject! {|k,v| v.blank?} | |||
|
425 | custom.keys.each do |k| | |||
|
426 | if custom[k].is_a?(Array) | |||
|
427 | custom[k] << '' if custom[k].delete('__none__') | |||
|
428 | else | |||
|
429 | custom[k] = '' if custom[k] == '__none__' | |||
|
430 | end | |||
|
431 | end | |||
|
432 | end | |||
424 | attributes |
|
433 | attributes | |
425 | end |
|
434 | end | |
426 | end |
|
435 | end |
@@ -100,6 +100,7 module CustomFieldsHelper | |||||
100 | when "list" |
|
100 | when "list" | |
101 | options = [] |
|
101 | options = [] | |
102 | options << [l(:label_no_change_option), ''] unless custom_field.multiple? |
|
102 | options << [l(:label_no_change_option), ''] unless custom_field.multiple? | |
|
103 | options << [l(:label_none), '__none__'] unless custom_field.is_required? | |||
103 | options += custom_field.possible_values_options(projects) |
|
104 | options += custom_field.possible_values_options(projects) | |
104 | select_tag(field_name, options_for_select(options), |
|
105 | select_tag(field_name, options_for_select(options), | |
105 | :id => field_id, :multiple => custom_field.multiple?) |
|
106 | :id => field_id, :multiple => custom_field.multiple?) |
@@ -2665,7 +2665,7 class IssuesControllerTest < ActionController::TestCase | |||||
2665 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, |
|
2665 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, | |
2666 | :children => { |
|
2666 | :children => { | |
2667 | :only => {:tag => 'option'}, |
|
2667 | :only => {:tag => 'option'}, | |
2668 |
:count => Project.find(1).users.count + |
|
2668 | :count => Project.find(1).users.count + 2 # "no change" + "none" options | |
2669 | } |
|
2669 | } | |
2670 | end |
|
2670 | end | |
2671 |
|
2671 | |||
@@ -2681,7 +2681,7 class IssuesControllerTest < ActionController::TestCase | |||||
2681 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, |
|
2681 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, | |
2682 | :children => { |
|
2682 | :children => { | |
2683 | :only => {:tag => 'option'}, |
|
2683 | :only => {:tag => 'option'}, | |
2684 |
:count => Project.find(1).shared_versions.count + |
|
2684 | :count => Project.find(1).shared_versions.count + 2 # "no change" + "none" options | |
2685 | } |
|
2685 | } | |
2686 | end |
|
2686 | end | |
2687 |
|
2687 | |||
@@ -2698,7 +2698,7 class IssuesControllerTest < ActionController::TestCase | |||||
2698 | :attributes => {:name => "issue[custom_field_values][1][]"}, |
|
2698 | :attributes => {:name => "issue[custom_field_values][1][]"}, | |
2699 | :children => { |
|
2699 | :children => { | |
2700 | :only => {:tag => 'option'}, |
|
2700 | :only => {:tag => 'option'}, | |
2701 | :count => 3 |
|
2701 | :count => field.possible_values.size + 1 # "none" options | |
2702 | } |
|
2702 | } | |
2703 | end |
|
2703 | end | |
2704 |
|
2704 | |||
@@ -2924,6 +2924,17 class IssuesControllerTest < ActionController::TestCase | |||||
2924 | assert_equal '777', journal.details.first.value |
|
2924 | assert_equal '777', journal.details.first.value | |
2925 | end |
|
2925 | end | |
2926 |
|
2926 | |||
|
2927 | def test_bulk_update_custom_field_to_blank | |||
|
2928 | @request.session[:user_id] = 2 | |||
|
2929 | post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing custom field', | |||
|
2930 | :issue => {:priority_id => '', | |||
|
2931 | :assigned_to_id => '', | |||
|
2932 | :custom_field_values => {'1' => '__none__'}} | |||
|
2933 | assert_response 302 | |||
|
2934 | assert_equal '', Issue.find(1).custom_field_value(1) | |||
|
2935 | assert_equal '', Issue.find(3).custom_field_value(1) | |||
|
2936 | end | |||
|
2937 | ||||
2927 | def test_bulk_update_multi_custom_field |
|
2938 | def test_bulk_update_multi_custom_field | |
2928 | field = CustomField.find(1) |
|
2939 | field = CustomField.find(1) | |
2929 | field.update_attribute :multiple, true |
|
2940 | field.update_attribute :multiple, true | |
@@ -2942,6 +2953,20 class IssuesControllerTest < ActionController::TestCase | |||||
2942 | assert_nil Issue.find(2).custom_field_value(1) |
|
2953 | assert_nil Issue.find(2).custom_field_value(1) | |
2943 | end |
|
2954 | end | |
2944 |
|
2955 | |||
|
2956 | def test_bulk_update_multi_custom_field_to_blank | |||
|
2957 | field = CustomField.find(1) | |||
|
2958 | field.update_attribute :multiple, true | |||
|
2959 | ||||
|
2960 | @request.session[:user_id] = 2 | |||
|
2961 | post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing multi custom field', | |||
|
2962 | :issue => {:priority_id => '', | |||
|
2963 | :assigned_to_id => '', | |||
|
2964 | :custom_field_values => {'1' => ['__none__']}} | |||
|
2965 | assert_response 302 | |||
|
2966 | assert_equal [''], Issue.find(1).custom_field_value(1) | |||
|
2967 | assert_equal [''], Issue.find(3).custom_field_value(1) | |||
|
2968 | end | |||
|
2969 | ||||
2945 | def test_bulk_update_unassign |
|
2970 | def test_bulk_update_unassign | |
2946 | assert_not_nil Issue.find(2).assigned_to |
|
2971 | assert_not_nil Issue.find(2).assigned_to | |
2947 | @request.session[:user_id] = 2 |
|
2972 | @request.session[:user_id] = 2 |
General Comments 0
You need to be logged in to leave comments.
Login now