Commit 3ba6169997171d3f6cae5dd09d3fdbd4b4233e54
1 parent
e663106a
Exists in
master
and in
29 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 | 241 | end |
242 | 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 | 248 | def select_unit(object) |
245 | 249 | collection_select(object.class.name.downcase, :unit_id, environment.units, :id, :singular, {:include_blank => _('Select the unit')}) |
246 | 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 | 2 | <% javascript_tag do %> |
4 | 3 | jQuery('#product-qualifiers-list *').removeClass('small-loading') |
5 | 4 | <% end %> | ... | ... |
app/views/manage_products/_edit_info.rhtml
... | ... | @@ -39,8 +39,7 @@ |
39 | 39 | <%= select_qualifiers(@product, qualifier.id) %> |
40 | 40 | </td> |
41 | 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 | 43 | </td> |
45 | 44 | </tr> |
46 | 45 | <% end %> |
... | ... | @@ -48,7 +47,7 @@ |
48 | 47 | <%= button_to_function( |
49 | 48 | :add, |
50 | 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 | 52 | <%= hidden_field_tag "product[qualifiers_list][nil]" %> |
54 | 53 | <% end %> | ... | ... |