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
This commit is contained in:
parent
285baaff94
commit
e35640f3e8
|
@ -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
|
||||
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue