Commit 3ba6169997171d3f6cae5dd09d3fdbd4b4233e54
1 parent
e663106a
Exists in
master
and in
22 other branches
Avoiding repetition of code
Created a method for button to remove qualifiers (ActionItem2374)
Showing
3 changed files
with
7 additions
and
5 deletions
Show diff stats
app/helpers/manage_products_helper.rb
@@ -241,6 +241,10 @@ module ManageProductsHelper | @@ -241,6 +241,10 @@ module ManageProductsHelper | ||
241 | end | 241 | end |
242 | end | 242 | end |
243 | 243 | ||
244 | + def remove_qualifier_button | ||
245 | + button_to_function(:delete, content_tag('span', _('Delete qualifier')), "jQuery(this).parents('tr').remove()") | ||
246 | + end | ||
247 | + | ||
244 | def select_unit(object) | 248 | def select_unit(object) |
245 | collection_select(object.class.name.downcase, :unit_id, environment.units, :id, :singular, {:include_blank => _('Select the unit')}) | 249 | collection_select(object.class.name.downcase, :unit_id, environment.units, :id, :singular, {:include_blank => _('Select the unit')}) |
246 | end | 250 | end |
app/views/manage_products/_certifiers_for_selection.rhtml
1 | -<%= select_certifiers(@qualifier) + | ||
2 | - button_to_function(:delete, content_tag('span', 'Delete qualifier'), "jQuery(this).parents('tr').remove()") %> | 1 | +<%= select_certifiers(@qualifier) + remove_qualifier_button %> |
3 | <% javascript_tag do %> | 2 | <% javascript_tag do %> |
4 | jQuery('#product-qualifiers-list *').removeClass('small-loading') | 3 | jQuery('#product-qualifiers-list *').removeClass('small-loading') |
5 | <% end %> | 4 | <% end %> |
app/views/manage_products/_edit_info.rhtml
@@ -39,8 +39,7 @@ | @@ -39,8 +39,7 @@ | ||
39 | <%= select_qualifiers(@product, qualifier.id) %> | 39 | <%= select_qualifiers(@product, qualifier.id) %> |
40 | </td> | 40 | </td> |
41 | <td id='certifier-area-<%= index %>'> | 41 | <td id='certifier-area-<%= index %>'> |
42 | - <%= select_certifiers(qualifier, @product) + | ||
43 | - button_to_function(:delete, content_tag('span', 'Delete qualifier'), "jQuery(this).parents('tr').remove()") %> | 42 | + <%= select_certifiers(qualifier, @product) + remove_qualifier_button %> |
44 | </td> | 43 | </td> |
45 | </tr> | 44 | </tr> |
46 | <% end %> | 45 | <% end %> |
@@ -48,7 +47,7 @@ | @@ -48,7 +47,7 @@ | ||
48 | <%= button_to_function( | 47 | <%= button_to_function( |
49 | :add, | 48 | :add, |
50 | _('Add new qualifier'), | 49 | _('Add new qualifier'), |
51 | - "new_qualifier_row('#product-qualifiers-list', '#{escape_javascript(select_qualifiers(@product))}', '#{escape_javascript(button_to_function(:delete, content_tag('span', 'Delete qualifier'), 'jQuery(this).parents(\'tr\').remove()'))}')" | 50 | + "new_qualifier_row('#product-qualifiers-list', '#{escape_javascript(select_qualifiers(@product))}', '#{escape_javascript(remove_qualifier_button)}')" |
52 | ) %> | 51 | ) %> |
53 | <%= hidden_field_tag "product[qualifiers_list][nil]" %> | 52 | <%= hidden_field_tag "product[qualifiers_list][nil]" %> |
54 | <% end %> | 53 | <% end %> |