diff --git a/backend/app/assets/javascripts/spree/backend.js b/backend/app/assets/javascripts/spree/backend.js index 1f1fe5e3051..d27a2bcede8 100644 --- a/backend/app/assets/javascripts/spree/backend.js +++ b/backend/app/assets/javascripts/spree/backend.js @@ -49,7 +49,6 @@ //= require spree/backend/progress //= require spree/backend/promotions //= require spree/backend/promotions/activation -//= require spree/backend/returns/return_item_selection //= require spree/backend/routes //= require spree/backend/shipments //= require spree/backend/spree-select2 diff --git a/backend/app/assets/javascripts/spree/backend/components/selectable_table.js b/backend/app/assets/javascripts/spree/backend/components/selectable_table.js index dca2a01c603..f1d2ace5051 100644 --- a/backend/app/assets/javascripts/spree/backend/components/selectable_table.js +++ b/backend/app/assets/javascripts/spree/backend/components/selectable_table.js @@ -6,5 +6,11 @@ Spree.ready(function() { }) new Spree.Views.Tables.SelectableTable({el: this, model: selectableTableModel}); + + if($(this).hasClass('return-items-table')) { + var tfoot = document.createElement('tfoot') + new Spree.Views.Tables.SelectableTable.SumItemAmount({ el: tfoot, model: selectableTableModel, table: this}); + $(this).append(tfoot); + } }) }); diff --git a/backend/app/assets/javascripts/spree/backend/returns/return_item_selection.js b/backend/app/assets/javascripts/spree/backend/returns/return_item_selection.js deleted file mode 100644 index 6e4d7ee8a6b..00000000000 --- a/backend/app/assets/javascripts/spree/backend/returns/return_item_selection.js +++ /dev/null @@ -1,35 +0,0 @@ -Spree.ready(function() { - function checkAddItemBox() { - $(this).closest('tr').find('input.add-item').attr('checked', 'checked'); - updateSuggestedAmount(); - } - - function updateSuggestedAmount() { - var totalPretaxRefund = 0; - var checkedItems = formFields.find('input.add-item:checked'); - $.each(checkedItems, function(i, checkbox) { - totalPretaxRefund += parseFloat($(checkbox).parents('tr').find('.refund-amount-input').val()); - }); - - var displayTotal = isNaN(totalPretaxRefund) ? '' : totalPretaxRefund.toFixed(2); - formFields.find('span#total_pre_tax_refund').html(displayTotal); - } - - var formFields = $("[data-hook='admin_customer_return_form_fields'], \ - [data-hook='admin_return_authorization_form_fields']"); - - if(formFields.length > 0) { - updateSuggestedAmount(); - - formFields.find('input#select-all').on('change', function(ev) { - var checkBoxes = $(ev.currentTarget).parents('table:first').find('input.add-item'); - checkBoxes.prop('checked', this.checked); - updateSuggestedAmount(); - }); - - formFields.find('input.add-item').on('change', updateSuggestedAmount); - formFields.find('.refund-amount-input').on('keyup', updateSuggestedAmount); - - formFields.find('input, select').not('.add-item').on('change', checkAddItemBox); - } -}); diff --git a/backend/app/assets/javascripts/spree/backend/templates/index.js b/backend/app/assets/javascripts/spree/backend/templates/index.js index b5a77abfcc6..39d4a178d98 100644 --- a/backend/app/assets/javascripts/spree/backend/templates/index.js +++ b/backend/app/assets/javascripts/spree/backend/templates/index.js @@ -1,5 +1,6 @@ //= require spree/backend/templates/_image //= require spree/backend/templates/tables/selectable_label +//= require spree/backend/templates/tables/return_item_sum_amount //= require spree/backend/templates/orders/customer_details/autocomplete //= require spree/backend/templates/orders/details_adjustment_row //= require spree/backend/templates/orders/line_item diff --git a/backend/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs b/backend/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs new file mode 100644 index 00000000000..7680008cfc2 --- /dev/null +++ b/backend/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs @@ -0,0 +1,7 @@ +
- <%= check_box_tag 'select-all' %> | <%= Spree::Product.model_name.human %> | <%= Spree::Variant.human_attribute_name(:sku) %> | @@ -25,7 +24,7 @@ <%= item_fields.hidden_field :return_authorization_id %> <%= item_fields.hidden_field :amount %> - <%= item_fields.check_box :returned, {checked: false, class: 'add-item', "data-price" => return_item.amount}, '1', '0' %> + <%= item_fields.check_box :returned, {checked: false, class: 'selectable add-item', "data-price" => return_item.amount}, '1', '0' %>
<%= return_item.inventory_unit.variant.name %>
diff --git a/backend/app/views/spree/admin/return_authorizations/_form.html.erb b/backend/app/views/spree/admin/return_authorizations/_form.html.erb
index ebd040f2528..dca7ab2ba7a 100644
--- a/backend/app/views/spree/admin/return_authorizations/_form.html.erb
+++ b/backend/app/views/spree/admin/return_authorizations/_form.html.erb
@@ -1,13 +1,10 @@
<% allow_return_item_changes = !@return_authorization.customer_returned_items? %>
-
|
---|