Sha256: 69229b34887d21652fe9906eae4659993a1146378fa9198efa42c66ebe199cb8

Contents?: true

Size: 1.29 KB

Versions: 53

Compression:

Stored size: 1.29 KB

Contents

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);
  }
});

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
solidus_backend-2.10.5 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.10.3 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.10.2 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.6 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.8.6 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.10.1 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.5 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.10.0 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.4 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.6.6 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.7.4 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.8.5 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.3 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.2 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.10.0.beta1 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.7.3 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.6.5 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.5.2 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.1 app/assets/javascripts/spree/backend/returns/return_item_selection.js
solidus_backend-2.9.0 app/assets/javascripts/spree/backend/returns/return_item_selection.js