##// END OF EJS Templates
Allows user to clear dates and text fields when bulk editing issues (#2199)....
Jean-Philippe Lang -
r11962:e35640f3e82c
parent child
Show More
@@ -105,13 +105,24 module CustomFieldsHelper
105
105
106 tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
106 tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"}
107
107
108 unset_tag = ''
109 unless custom_field.is_required?
110 unset_tag = content_tag('label',
111 check_box_tag(field_name, '__none__', (value == '__none__'), :id => nil, :data => {:disables => "##{field_id}"}) + l(:button_clear),
112 :class => 'inline'
113 )
114 end
115
108 field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
116 field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
109 case field_format.try(:edit_as)
117 case field_format.try(:edit_as)
110 when "date"
118 when "date"
111 text_field_tag(field_name, value, tag_options.merge(:size => 10)) +
119 text_field_tag(field_name, value, tag_options.merge(:size => 10)) +
112 calendar_for(field_id)
120 calendar_for(field_id) +
121 unset_tag
113 when "text"
122 when "text"
114 text_area_tag(field_name, value, tag_options.merge(:rows => 3))
123 text_area_tag(field_name, value, tag_options.merge(:rows => 3)) +
124 '<br />'.html_safe +
125 unset_tag
115 when "bool"
126 when "bool"
116 select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
127 select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
117 [l(:general_text_yes), '1'],
128 [l(:general_text_yes), '1'],
@@ -123,7 +134,8 module CustomFieldsHelper
123 options += custom_field.possible_values_options(projects)
134 options += custom_field.possible_values_options(projects)
124 select_tag(field_name, options_for_select(options, value), tag_options.merge(:multiple => custom_field.multiple?))
135 select_tag(field_name, options_for_select(options, value), tag_options.merge(:multiple => custom_field.multiple?))
125 else
136 else
126 text_field_tag(field_name, value, tag_options)
137 text_field_tag(field_name, value, tag_options) +
138 unset_tag
127 end
139 end
128 end
140 end
129
141
@@ -130,6 +130,7
130 <p>
130 <p>
131 <label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
131 <label for='issue_parent_issue_id'><%= l(:field_parent_issue) %></label>
132 <%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
132 <%= text_field_tag 'issue[parent_issue_id]', '', :size => 10, :value => @issue_params[:parent_issue_id] %>
133 <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>
133 </p>
134 </p>
134 <%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %>
135 <%= javascript_tag "observeAutocompleteField('issue_parent_issue_id', '#{escape_javascript auto_complete_issues_path(:project_id => @project)}')" %>
135 <% end %>
136 <% end %>
@@ -138,6 +139,7
138 <p>
139 <p>
139 <label for='issue_start_date'><%= l(:field_start_date) %></label>
140 <label for='issue_start_date'><%= l(:field_start_date) %></label>
140 <%= text_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
141 <%= text_field_tag 'issue[start_date]', '', :value => @issue_params[:start_date], :size => 10 %><%= calendar_for('issue_start_date') %>
142 <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>
141 </p>
143 </p>
142 <% end %>
144 <% end %>
143
145
@@ -145,6 +147,7
145 <p>
147 <p>
146 <label for='issue_due_date'><%= l(:field_due_date) %></label>
148 <label for='issue_due_date'><%= l(:field_due_date) %></label>
147 <%= text_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
149 <%= text_field_tag 'issue[due_date]', '', :value => @issue_params[:due_date], :size => 10 %><%= calendar_for('issue_due_date') %>
150 <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>
148 </p>
151 </p>
149 <% end %>
152 <% end %>
150
153
@@ -178,3 +181,18
178 </p>
181 </p>
179
182
180 <% end %>
183 <% end %>
184
185 <%= javascript_tag do %>
186 $(window).load(function(){
187 $(document).on('change', 'input[data-disables]', function(){
188 if ($(this).attr('checked')){
189 $($(this).data('disables')).attr('disabled', true).val('');
190 } else {
191 $($(this).data('disables')).attr('disabled', false);
192 }
193 });
194 });
195 $(document).ready(function(){
196 $('input[data-disables]').trigger('change');
197 });
198 <% end %>
@@ -3287,6 +3287,12 class IssuesControllerTest < ActionController::TestCase
3287 end
3287 end
3288 end
3288 end
3289
3289
3290 def test_bulk_edit_should_propose_to_clear_text_custom_fields
3291 @request.session[:user_id] = 2
3292 get :bulk_edit, :ids => [1, 3]
3293 assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', '__none__'
3294 end
3295
3290 def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
3296 def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
3291 WorkflowTransition.delete_all
3297 WorkflowTransition.delete_all
3292 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
3298 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
General Comments 0
You need to be logged in to leave comments. Login now