summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-09-30 19:27:00 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-09-30 19:27:00 +0000
commite35640f3e82ce1cd34cf4272ee75910712f64279 (patch)
treedea65da3bf709fcb8e695859880214a5a769923c
parent285baaff9452a8b4b7dc4b63f3443380873021b9 (diff)
downloadredmine-e35640f3e82ce1cd34cf4272ee75910712f64279.tar.gz
redmine-e35640f3e82ce1cd34cf4272ee75910712f64279.zip
Allows user to clear dates and text fields when bulk editing issues (#2199).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12192 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/custom_fields_helper.rb18
-rw-r--r--app/views/issues/bulk_edit.html.erb18
-rw-r--r--test/functional/issues_controller_test.rb6
3 files changed, 39 insertions, 3 deletions
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 242bfefef..fd549f5ab 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)) +
+ '<br />'.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 6c532f42b..a8c04a9c4 100644
--- a/app/views/issues/bulk_edit.html.erb
+++ b/app/views/issues/bulk_edit.html.erb
@@ -130,6 +130,7 @@
<p>
<label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
<%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
+ <label class="inline"><%= check_box_tag 'issue[parent_issue_id]', 'none', (@issue_params[:parent_issue_id] == 'none'), :id => nil, :data => {:disables => '#issue_parent_issue_id'} %><%= l(:button_clear) %></label>
</p>
<%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %>
<% end %>
@@ -138,6 +139,7 @@
<p>
<label for='issue_start_date'><%= l(:field_start_date) %></label>
<%= text_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
+ <label class="inline"><%= check_box_tag 'issue[start_date]', 'none', (@issue_params[:start_date] == 'none'), :id => nil, :data => {:disables => '#issue_start_date'} %><%= l(:button_clear) %></label>
</p>
<% end %>
@@ -145,6 +147,7 @@
<p>
<label for='issue_due_date'><%= l(:field_due_date) %></label>
<%= text_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
+ <label class="inline"><%= check_box_tag 'issue[due_date]', 'none', (@issue_params[:due_date] == 'none'), :id => nil, :data => {:disables => '#issue_due_date'} %><%= l(:button_clear) %></label>
</p>
<% end %>
@@ -178,3 +181,18 @@
</p>
<% 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 ec10af116..34c99a568 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,