diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 242bfef..fd549f5 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -105,13 +105,24 @@ module CustomFieldsHelper
tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
+ unset_tag = ''
+ unless custom_field.is_required?
+ unset_tag = content_tag('label',
+ check_box_tag(field_name, '__none__', (value == '__none__'), :id => nil, :data => {:disables => "##{field_id}"}) + l(:button_clear),
+ :class => 'inline'
+ )
+ end
+
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as)
when "date"
text_field_tag(field_name, value, tag_options.merge(:size => 10)) +
- calendar_for(field_id)
+ calendar_for(field_id) +
+ unset_tag
when "text"
- text_area_tag(field_name, value, tag_options.merge(:rows => 3))
+ text_area_tag(field_name, value, tag_options.merge(:rows => 3)) +
+ '
'.html_safe +
+ unset_tag
when "bool"
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
[l(:general_text_yes), '1'],
@@ -123,7 +134,8 @@ module CustomFieldsHelper
options += custom_field.possible_values_options(projects)
select_tag(field_name, options_for_select(options, value), tag_options.merge(:multiple => custom_field.multiple?))
else
- text_field_tag(field_name, value, tag_options)
+ text_field_tag(field_name, value, tag_options) +
+ unset_tag
end
end
diff --git a/app/views/issues/bulk_edit.html.erb b/app/views/issues/bulk_edit.html.erb
index 6c532f4..a8c04a9 100644
--- a/app/views/issues/bulk_edit.html.erb
+++ b/app/views/issues/bulk_edit.html.erb
@@ -130,6 +130,7 @@
<%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %> +
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %> <% end %> @@ -138,6 +139,7 @@<%= text_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %> +
<% end %> @@ -145,6 +147,7 @@<%= text_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %> +
<% end %> @@ -178,3 +181,18 @@ <% end %> + +<%= javascript_tag do %> +$(window).load(function(){ + $(document).on('change', 'input[data-disables]', function(){ + if ($(this).attr('checked')){ + $($(this).data('disables')).attr('disabled', true).val(''); + } else { + $($(this).data('disables')).attr('disabled', false); + } + }); +}); +$(document).ready(function(){ + $('input[data-disables]').trigger('change'); +}); +<% end %> diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index ec10af1..34c99a5 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -3287,6 +3287,12 @@ class IssuesControllerTest < ActionController::TestCase end end + def test_bulk_edit_should_propose_to_clear_text_custom_fields + @request.session[:user_id] = 2 + get :bulk_edit, :ids => [1, 3] + assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', '__none__' + end + def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues WorkflowTransition.delete_all WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,