spree_backend 3.6.6 → 3.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +7 -7
  3. data/app/assets/javascripts/spree/backend/address_states.js +21 -21
  4. data/app/assets/javascripts/spree/backend/adjustments.js +25 -0
  5. data/app/assets/javascripts/spree/backend/admin.js +253 -244
  6. data/app/assets/javascripts/spree/backend/calculator.js +14 -13
  7. data/app/assets/javascripts/spree/backend/checkouts/edit.js +48 -52
  8. data/app/assets/javascripts/spree/backend/gateway.js +11 -10
  9. data/app/assets/javascripts/spree/backend/general_settings.js +18 -0
  10. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +6 -6
  11. data/app/assets/javascripts/spree/backend/line_items.js +72 -0
  12. data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +48 -47
  13. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +10 -10
  14. data/app/assets/javascripts/spree/backend/option_value_picker.js +13 -14
  15. data/app/assets/javascripts/spree/backend/orders/edit.js +3 -4
  16. data/app/assets/javascripts/spree/backend/payments/edit.js +230 -0
  17. data/app/assets/javascripts/spree/backend/payments/new.js +31 -31
  18. data/app/assets/javascripts/spree/backend/product_picker.js +15 -15
  19. data/app/assets/javascripts/spree/backend/progress.js +8 -0
  20. data/app/assets/javascripts/spree/backend/promotions.js +102 -107
  21. data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +5 -0
  22. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +32 -33
  23. data/app/assets/javascripts/spree/backend/shipments.js +246 -241
  24. data/app/assets/javascripts/spree/backend/spree-select2.js +3 -3
  25. data/app/assets/javascripts/spree/backend/states.js +8 -8
  26. data/app/assets/javascripts/spree/backend/stock_location.js +4 -3
  27. data/app/assets/javascripts/spree/backend/stock_management.js +13 -0
  28. data/app/assets/javascripts/spree/backend/stock_movement.js +35 -0
  29. data/app/assets/javascripts/spree/backend/stock_transfer.js +260 -0
  30. data/app/assets/javascripts/spree/backend/tag_picker.js +21 -21
  31. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +13 -13
  32. data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +8 -9
  33. data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +35 -0
  34. data/app/assets/javascripts/spree/backend/taxonomy.js +165 -0
  35. data/app/assets/javascripts/spree/backend/taxons.js +122 -0
  36. data/app/assets/javascripts/spree/backend/user_picker.js +11 -11
  37. data/app/assets/javascripts/spree/backend/users/edit.js +14 -15
  38. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +61 -0
  39. data/app/assets/javascripts/spree/backend/variant_management.js +14 -0
  40. data/app/assets/javascripts/spree/backend/zone.js +44 -0
  41. data/app/controllers/spree/admin/countries_controller.rb +3 -3
  42. data/app/controllers/spree/admin/customer_returns_controller.rb +1 -0
  43. data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
  44. data/app/controllers/spree/admin/orders_controller.rb +4 -4
  45. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -0
  46. data/app/controllers/spree/admin/payments_controller.rb +3 -2
  47. data/app/controllers/spree/admin/products_controller.rb +3 -1
  48. data/app/controllers/spree/admin/promotions_controller.rb +1 -0
  49. data/app/controllers/spree/admin/properties_controller.rb +1 -0
  50. data/app/controllers/spree/admin/reports_controller.rb +4 -4
  51. data/app/controllers/spree/admin/resource_controller.rb +3 -1
  52. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  53. data/app/controllers/spree/admin/return_index_controller.rb +1 -0
  54. data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -0
  55. data/app/controllers/spree/admin/store_credits_controller.rb +1 -2
  56. data/app/controllers/spree/admin/users_controller.rb +3 -1
  57. data/app/helpers/spree/admin/base_helper.rb +8 -5
  58. data/app/helpers/spree/admin/{general_settings_helper.rb → currency_helper.rb} +4 -3
  59. data/app/helpers/spree/admin/navigation_helper.rb +0 -8
  60. data/app/helpers/spree/admin/orders_helper.rb +2 -1
  61. data/app/models/spree/admin/resource.rb +1 -0
  62. data/app/views/spree/admin/orders/_line_items.html.erb +3 -1
  63. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
  64. data/app/views/spree/admin/orders/index.html.erb +15 -8
  65. data/app/views/spree/admin/products/index.html.erb +2 -2
  66. data/app/views/spree/admin/promotions/index.html.erb +4 -4
  67. data/app/views/spree/admin/properties/index.html.erb +2 -2
  68. data/app/views/spree/admin/return_index/customer_returns.html.erb +1 -1
  69. data/app/views/spree/admin/return_index/return_authorizations.html.erb +2 -2
  70. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
  71. data/app/views/spree/admin/store_credits/_form.html.erb +15 -6
  72. data/app/views/spree/admin/store_credits/edit.html.erb +1 -1
  73. data/app/views/spree/admin/store_credits/new.html.erb +1 -1
  74. data/app/views/spree/admin/users/_addresses_form.html.erb +1 -1
  75. data/app/views/spree/admin/users/index.html.erb +8 -8
  76. data/app/views/spree/admin/users/items.html.erb +3 -1
  77. data/app/views/spree/admin/variants/index.html.erb +2 -2
  78. data/lib/generators/spree/backend/copy_views/copy_views_generator.rb +1 -1
  79. data/lib/spree/backend/callbacks.rb +1 -0
  80. data/spree_backend.gemspec +2 -2
  81. data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +4358 -4358
  82. data/vendor/assets/javascripts/js.cookie.js +165 -0
  83. metadata +28 -28
  84. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
  85. data/app/assets/javascripts/spree/backend/general_settings.js.coffee +0 -15
  86. data/app/assets/javascripts/spree/backend/line_items.js.coffee +0 -64
  87. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -145
  88. data/app/assets/javascripts/spree/backend/progress.js.coffee +0 -6
  89. data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +0 -4
  90. data/app/assets/javascripts/spree/backend/stock_management.js.coffee +0 -9
  91. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +0 -19
  92. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -201
  93. data/app/assets/javascripts/spree/backend/taxon_tree_menu.js.coffee +0 -22
  94. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -153
  95. data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -82
  96. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -38
  97. data/app/assets/javascripts/spree/backend/variant_management.js.coffee +0 -10
  98. data/app/assets/javascripts/spree/backend/zone.js.coffee +0 -43
  99. data/vendor/assets/javascripts/jquery.cookie.js +0 -117
@@ -1,170 +1,165 @@
1
- var initProductActions = function () {
2
- /* globals Handlebars */
3
- 'use strict';
1
+ function initProductActions () {
2
+ 'use strict'
4
3
 
5
4
  // Add classes on promotion items for design
6
5
  $(document).on('mouseover mouseout', 'a.delete', function (event) {
7
6
  if (event.type === 'mouseover') {
8
- $(this).parent().addClass('action-remove');
7
+ $(this).parent().addClass('action-remove')
9
8
  } else {
10
- $(this).parent().removeClass('action-remove');
9
+ $(this).parent().removeClass('action-remove')
11
10
  }
12
- });
11
+ })
13
12
 
14
- $('#promotion-filters').find('.variant_autocomplete').variantAutocomplete();
13
+ $('#promotion-filters').find('.variant_autocomplete').variantAutocomplete()
15
14
 
16
15
  $('.calculator-fields').each(function () {
17
- var $fields_container = $(this);
18
- var $type_select = $fields_container.find('.type-select');
19
- var $settings = $fields_container.find('.settings');
20
- var $warning = $fields_container.find('.js-warning');
21
- var originalType = $type_select.val();
22
-
23
- $warning.hide();
24
- $type_select.change(function () {
16
+ var $fieldsContainer = $(this)
17
+ var $typeSelect = $fieldsContainer.find('.type-select')
18
+ var $settings = $fieldsContainer.find('.settings')
19
+ var $warning = $fieldsContainer.find('.js-warning')
20
+ var originalType = $typeSelect.val()
21
+
22
+ $warning.hide()
23
+ $typeSelect.change(function () {
25
24
  if ($(this).val() === originalType) {
26
- $warning.hide();
27
- $settings.show();
28
- $settings.find('input').removeProp('disabled');
25
+ $warning.hide()
26
+ $settings.show()
27
+ $settings.find('input').removeProp('disabled')
29
28
  } else {
30
- $warning.show();
31
- $settings.hide();
32
- $settings.find('input').prop('disabled', 'disabled');
29
+ $warning.show()
30
+ $settings.hide()
31
+ $settings.find('input').prop('disabled', 'disabled')
33
32
  }
34
- });
35
- });
33
+ })
34
+ })
36
35
 
37
36
  //
38
37
  // Option Value Promo Rule
39
38
  //
40
39
  if ($('#promo-rule-option-value-template').length) {
41
- var optionValueSelectNameTemplate = Handlebars.compile($('#promo-rule-option-value-option-values-select-name-template').html());
42
- var optionValueTemplate = Handlebars.compile($('#promo-rule-option-value-template').html());
40
+ var optionValueSelectNameTemplate = Handlebars.compile($('#promo-rule-option-value-option-values-select-name-template').html())
41
+ var optionValueTemplate = Handlebars.compile($('#promo-rule-option-value-template').html())
43
42
 
44
- var addOptionValue = function(product, values) {
43
+ var addOptionValue = function (product, values) {
45
44
  $('.js-promo-rule-option-values').append(optionValueTemplate({
46
- productSelect: {value: product},
47
- optionValuesSelect: {value: values}
48
- }));
49
- var optionValue = $('.js-promo-rule-option-values .promo-rule-option-value').last();
50
- optionValue.find('.js-promo-rule-option-value-product-select').productAutocomplete({multiple: false});
45
+ productSelect: { value: product },
46
+ optionValuesSelect: { value: values }
47
+ }))
48
+ var optionValue = $('.js-promo-rule-option-values .promo-rule-option-value').last()
49
+ optionValue.find('.js-promo-rule-option-value-product-select').productAutocomplete({ multiple: false })
51
50
  optionValue.find('.js-promo-rule-option-value-option-values-select').optionValueAutocomplete({
52
51
  productSelect: '.js-promo-rule-option-value-product-select'
53
- });
52
+ })
54
53
  if (product === null) {
55
- optionValue.find('.js-promo-rule-option-value-option-values-select').prop('disabled', true);
54
+ optionValue.find('.js-promo-rule-option-value-option-values-select').prop('disabled', true)
56
55
  }
57
- };
56
+ }
58
57
 
59
- var originalOptionValues = $('.js-original-promo-rule-option-values').data('original-option-values');
58
+ var originalOptionValues = $('.js-original-promo-rule-option-values').data('original-option-values')
60
59
  if (!$('.js-original-promo-rule-option-values').data('loaded')) {
61
60
  if ($.isEmptyObject(originalOptionValues)) {
62
- addOptionValue(null, null);
61
+ addOptionValue(null, null)
63
62
  } else {
64
- $.each(originalOptionValues, addOptionValue);
63
+ $.each(originalOptionValues, addOptionValue)
65
64
  }
66
65
  }
67
- $('.js-original-promo-rule-option-values').data('loaded', true);
66
+ $('.js-original-promo-rule-option-values').data('loaded', true)
68
67
 
69
68
  $(document).on('click', '.js-add-promo-rule-option-value', function (event) {
70
- event.preventDefault();
71
- addOptionValue(null, null);
72
- });
69
+ event.preventDefault()
70
+ addOptionValue(null, null)
71
+ })
73
72
 
74
73
  $(document).on('click', '.js-remove-promo-rule-option-value', function () {
75
- $(this).parents('.promo-rule-option-value').remove();
76
- });
74
+ $(this).parents('.promo-rule-option-value').remove()
75
+ })
77
76
 
78
77
  $(document).on('change', '.js-promo-rule-option-value-product-select', function () {
79
- var optionValueSelect = $(this).parents('.promo-rule-option-value').find('.js-promo-rule-option-value-option-values-select');
80
- optionValueSelect.attr('name', optionValueSelectNameTemplate({productId: $(this).val()}).trim());
81
- optionValueSelect.prop('disabled', $(this).val() === '').select2('val', '');
82
- });
78
+ var optionValueSelect = $(this).parents('.promo-rule-option-value').find('.js-promo-rule-option-value-option-values-select')
79
+ optionValueSelect.attr('name', optionValueSelectNameTemplate({ productId: $(this).val() }).trim())
80
+ optionValueSelect.prop('disabled', $(this).val() === '').select2('val', '')
81
+ })
83
82
  }
84
83
 
85
84
  //
86
85
  // Tiered Calculator
87
86
  //
88
87
  if ($('#tier-fields-template').length && $('#tier-input-name').length) {
89
- var tierFieldsTemplate = Handlebars.compile($('#tier-fields-template').html());
90
- var tierInputNameTemplate = Handlebars.compile($('#tier-input-name').html());
88
+ var tierFieldsTemplate = Handlebars.compile($('#tier-fields-template').html())
89
+ var tierInputNameTemplate = Handlebars.compile($('#tier-input-name').html())
91
90
 
92
- var originalTiers = $('.js-original-tiers').data('original-tiers');
93
- $.each(originalTiers, function(base, value) {
94
- var fieldName = tierInputNameTemplate({base: base}).trim();
91
+ var originalTiers = $('.js-original-tiers').data('original-tiers')
92
+ $.each(originalTiers, function (base, value) {
93
+ var fieldName = tierInputNameTemplate({ base: base }).trim()
95
94
  $('.js-tiers').append(tierFieldsTemplate({
96
- baseField: {value: base},
97
- valueField: {name: fieldName, value: value}
98
- }));
99
- });
100
-
101
- $(document).on('click', '.js-add-tier', function(event) {
102
- event.preventDefault();
103
- $('.js-tiers').append(tierFieldsTemplate({valueField: {name: null}}));
104
- });
105
-
106
- $(document).on('click', '.js-remove-tier', function(event) {
107
- $(this).parents('.tier').remove();
108
- });
109
-
110
- $(document).on('change', '.js-base-input', function(event) {
111
- var valueInput = $(this).parents('.tier').find('.js-value-input');
112
- valueInput.attr('name', tierInputNameTemplate({base: $(this).val()}).trim());
113
- });
95
+ baseField: { value: base },
96
+ valueField: { name: fieldName, value: value }
97
+ }))
98
+ })
99
+
100
+ $(document).on('click', '.js-add-tier', function (event) {
101
+ event.preventDefault()
102
+ $('.js-tiers').append(tierFieldsTemplate({ valueField: { name: null } }))
103
+ })
104
+
105
+ $(document).on('click', '.js-remove-tier', function (event) {
106
+ $(this).parents('.tier').remove()
107
+ })
108
+
109
+ $(document).on('change', '.js-base-input', function (event) {
110
+ var valueInput = $(this).parents('.tier').find('.js-value-input')
111
+ valueInput.attr('name', tierInputNameTemplate({ base: $(this).val() }).trim())
112
+ })
114
113
  }
115
114
 
116
115
  //
117
116
  // CreateLineItems Promotion Action
118
117
  //
119
118
  (function () {
120
- var hideOrShowItemTables = function () {
119
+ function hideOrShowItemTables () {
121
120
  $('.promotion_action table').each(function () {
122
121
  if ($(this).find('td').length === 0) {
123
- $(this).hide();
122
+ $(this).hide()
124
123
  } else {
125
- $(this).show();
124
+ $(this).show()
126
125
  }
127
- });
128
- };
129
- hideOrShowItemTables();
126
+ })
127
+ }
128
+ hideOrShowItemTables()
130
129
 
131
130
  // Remove line item
132
- var setupRemoveLineItems = function () {
131
+ function setupRemoveLineItems () {
133
132
  $('.remove_promotion_line_item').on('click', function () {
134
- var line_items_el = $($('.line_items_string')[0]);
135
- var finder = new RegExp($(this).data('variant-id') + "x\\d+");
136
- line_items_el.val(line_items_el.val().replace(finder, ''));
137
- $(this).parents('tr').remove();
138
- hideOrShowItemTables();
139
- });
140
- };
141
-
142
- setupRemoveLineItems();
133
+ var lineItemsEl = $($('.line_items_string')[0])
134
+ var finder = new RegExp($(this).data('variant-id') + 'x\\d+')
135
+ lineItemsEl.val(lineItemsEl.val().replace(finder, ''))
136
+ $(this).parents('tr').remove()
137
+ hideOrShowItemTables()
138
+ })
139
+ }
140
+
141
+ setupRemoveLineItems()
143
142
  // Add line item to list
144
143
  $('.promotion_action.create_line_items button.add').unbind('click').click(function () {
145
- var $container = $(this).parents('.promotion_action');
146
- var product_name = $container.find('input[name="add_product_name"]').val();
147
- var variant_id = $container.find('input[name="add_variant_id"]').val();
148
- var quantity = $container.find('input[name="add_quantity"]').val();
149
- if (variant_id) {
144
+ var $container = $(this).parents('.promotion_action')
145
+ var productName = $container.find('input[name="add_product_name"]').val()
146
+ var variantId = $container.find('input[name="add_variant_id"]').val()
147
+ var quantity = $container.find('input[name="add_quantity"]').val()
148
+ if (variantId) {
150
149
  // Add to the table
151
- var newRow = '<tr><td>' + product_name + '</td><td>' + quantity + '</td><td><img src="/assets/admin/icons/cross.png"/></td></tr>';
152
- $container.find('table').append(newRow);
150
+ var newRow = '<tr><td>' + productName + '</td><td>' + quantity + '</td><td><img src="/assets/admin/icons/cross.png"/></td></tr>'
151
+ $container.find('table').append(newRow)
153
152
  // Add to serialized string in hidden text field
154
- var $hiddenField = $container.find('.line_items_string');
155
- $hiddenField.val($hiddenField.val() + ',' + variant_id + 'x' + quantity);
156
- setupRemoveLineItems();
157
- hideOrShowItemTables();
153
+ var $hiddenField = $container.find('.line_items_string')
154
+ $hiddenField.val($hiddenField.val() + ',' + variantId + 'x' + quantity)
155
+ setupRemoveLineItems()
156
+ hideOrShowItemTables()
158
157
  }
159
- return false;
160
- });
161
-
162
- })();
163
-
164
- };
158
+ return false
159
+ })
160
+ })()
161
+ }
165
162
 
166
163
  $(document).ready(function () {
167
-
168
- initProductActions();
169
-
170
- });
164
+ initProductActions()
165
+ })
@@ -0,0 +1,5 @@
1
+ $(function () {
2
+ $(document).on('change', '.return-items-table .return-item-exchange-selection', function () {
3
+ $('.expedited-exchanges-warning').fadeIn()
4
+ })
5
+ })
@@ -1,41 +1,40 @@
1
- $(document).ready(function() {
2
- var formFields = $("[data-hook='admin_customer_return_form_fields'], \
3
- [data-hook='admin_return_authorization_form_fields']");
1
+ $(document).ready(function () {
2
+ var formFields = $("[data-hook='admin_customer_return_form_fields'], [data-hook='admin_return_authorization_form_fields']")
4
3
 
5
- if(formFields.length > 0) {
6
- function checkAddItemBox() {
7
- $(this).closest('tr').find('input.add-item').attr('checked', 'checked');
8
- updateSuggestedAmount();
9
- }
4
+ function checkAddItemBox () {
5
+ $(this).closest('tr').find('input.add-item').attr('checked', 'checked')
6
+ updateSuggestedAmount()
7
+ }
10
8
 
11
- function updateSuggestedAmount() {
12
- var totalPretaxRefund = 0;
13
- var checkedItems = formFields.find('input.add-item:checked');
14
- $.each(checkedItems, function(i, checkbox) {
15
- var returnItemRow = $(checkbox).parents('tr'), returnQuantity, amount, purchasedQuantity;
16
- returnQuantity = parseInt(returnItemRow.find('.refund-quantity-input').val(), 10);
17
- purchasedQuantity = parseInt(returnItemRow.find('.purchased-quantity').text(), 10);
18
- amount = (returnQuantity / purchasedQuantity) * parseFloat(returnItemRow.find('.charged-amount').data('chargedAmount'));
19
- returnItemRow.find('.refund-amount-input').val(amount.toFixed(2));
20
- totalPretaxRefund += amount;
21
- });
9
+ function updateSuggestedAmount () {
10
+ var totalPretaxRefund = 0
11
+ var checkedItems = formFields.find('input.add-item:checked')
12
+ $.each(checkedItems, function (i, checkbox) {
13
+ var returnItemRow = $(checkbox).parents('tr')
14
+ var returnQuantity = parseInt(returnItemRow.find('.refund-quantity-input').val(), 10)
15
+ var purchasedQuantity = parseInt(returnItemRow.find('.purchased-quantity').text(), 10)
16
+ var amount = (returnQuantity / purchasedQuantity) * parseFloat(returnItemRow.find('.charged-amount').data('chargedAmount'))
17
+ returnItemRow.find('.refund-amount-input').val(amount.toFixed(2))
18
+ totalPretaxRefund += amount
19
+ })
22
20
 
23
- var displayTotal = isNaN(totalPretaxRefund) ? '' : totalPretaxRefund.toFixed(2);
24
- formFields.find('span#total_pre_tax_refund').html(displayTotal);
25
- }
21
+ var displayTotal = isNaN(totalPretaxRefund) ? '' : totalPretaxRefund.toFixed(2)
22
+ formFields.find('span#total_pre_tax_refund').html(displayTotal)
23
+ }
26
24
 
27
- updateSuggestedAmount();
25
+ if (formFields.length > 0) {
26
+ updateSuggestedAmount()
28
27
 
29
- formFields.find('input#select-all').on('change', function(ev) {
30
- var checkBoxes = $(ev.currentTarget).parents('table:first').find('input.add-item');
31
- checkBoxes.prop('checked', this.checked);
32
- updateSuggestedAmount();
33
- });
28
+ formFields.find('input#select-all').on('change', function (ev) {
29
+ var checkBoxes = $(ev.currentTarget).parents('table:first').find('input.add-item')
30
+ checkBoxes.prop('checked', this.checked)
31
+ updateSuggestedAmount()
32
+ })
34
33
 
35
- formFields.find('input.add-item').on('change', updateSuggestedAmount);
36
- formFields.find('.refund-amount-input').on('keyup', updateSuggestedAmount);
37
- formFields.find('.refund-quantity-input').on('keyup mouseup', updateSuggestedAmount);
34
+ formFields.find('input.add-item').on('change', updateSuggestedAmount)
35
+ formFields.find('.refund-amount-input').on('keyup', updateSuggestedAmount)
36
+ formFields.find('.refund-quantity-input').on('keyup mouseup', updateSuggestedAmount)
38
37
 
39
- formFields.find('input, select').not('.add-item').on('change', checkAddItemBox);
38
+ formFields.find('input, select').not('.add-item').on('change', checkAddItemBox)
40
39
  }
41
- });
40
+ })
@@ -1,74 +1,77 @@
1
+ /* global shipments, variantStockTemplate, order_number */
1
2
  // Shipments AJAX API
2
3
  $(document).ready(function () {
3
- 'use strict';
4
+ 'use strict'
4
5
 
5
6
  // handle variant selection, show stock level.
6
- $('#add_variant_id').change(function(){
7
- var variant_id = $(this).val();
7
+ $('#add_variant_id').change(function () {
8
+ var variantId = $(this).val()
8
9
 
9
- var variant = _.find(window.variants, function(variant){
10
- return variant.id == variant_id
10
+ var variant = _.find(window.variants, function (variant) {
11
+ // eslint-disable-next-line eqeqeq
12
+ return variant.id == variantId
11
13
  })
12
- $('#stock_details').html(variantStockTemplate({variant: variant}));
13
- $('#stock_details').show();
14
+ $('#stock_details').html(variantStockTemplate({ variant: variant }))
15
+ $('#stock_details').show()
14
16
 
15
- $('button.add_variant').click(addVariantFromStockLocation);
16
- });
17
+ $('button.add_variant').click(addVariantFromStockLocation)
18
+ })
17
19
 
18
- //handle edit click
19
- $('a.edit-item').click(toggleItemEdit);
20
+ // handle edit click
21
+ $('a.edit-item').click(toggleItemEdit)
20
22
 
21
- //handle cancel click
22
- $('a.cancel-item').click(toggleItemEdit);
23
+ // handle cancel click
24
+ $('a.cancel-item').click(toggleItemEdit)
23
25
 
24
- //handle split click
25
- $('a.split-item').click(startItemSplit);
26
+ // handle split click
27
+ $('a.split-item').click(startItemSplit)
26
28
 
27
- //handle save click
28
- $('a.save-item').click(function(){
29
- var save = $(this);
30
- var shipment_number = save.data('shipment-number');
31
- var variant_id = save.data('variant-id');
29
+ // handle save click
30
+ $('a.save-item').click(function () {
31
+ var save = $(this)
32
+ var shipmentNumber = save.data('shipment-number')
33
+ var variantId = save.data('variant-id')
32
34
 
33
- var quantity = parseInt(save.parents('tr').find('input.line_item_quantity').val());
35
+ var quantity = parseInt(save.parents('tr').find('input.line_item_quantity').val())
34
36
 
35
- toggleItemEdit();
36
- adjustShipmentItems(shipment_number, variant_id, quantity);
37
- return false;
38
- });
37
+ toggleItemEdit()
38
+ adjustShipmentItems(shipmentNumber, variantId, quantity)
39
+ return false
40
+ })
39
41
 
40
- //handle delete click
41
- $('a.delete-item').click(function(event){
42
+ // handle delete click
43
+ $('a.delete-item').click(function (event) {
42
44
  if (confirm(Spree.translations.are_you_sure_delete)) {
43
- var del = $(this);
44
- var shipment_number = del.data('shipment-number');
45
- var variant_id = del.data('variant-id');
46
- var shipment = _.findWhere(shipments, {number: shipment_number + ''});
47
- var url = Spree.routes.shipments_api + "/" + shipment_number + '/remove';
45
+ var del = $(this)
46
+ var shipmentNumber = del.data('shipment-number')
47
+ var variantId = del.data('variant-id')
48
+ // eslint-disable-next-line
49
+ var shipment = _.findWhere(shipments, { number: shipmentNumber + '' })
50
+ var url = Spree.routes.shipments_api + '/' + shipmentNumber + '/remove'
48
51
 
49
- toggleItemEdit();
52
+ toggleItemEdit()
50
53
 
51
54
  $.ajax({
52
- type: "PUT",
55
+ type: 'PUT',
53
56
  url: Spree.url(url),
54
57
  data: {
55
- variant_id: variant_id,
58
+ variant_id: variantId,
56
59
  token: Spree.api_key
57
60
  }
58
- }).done(function( msg ) {
59
- window.location.reload();
60
- }).fail(function(msg) {
61
- alert(msg.responseJSON.message)
62
- });
61
+ }).done(function (msg) {
62
+ window.location.reload()
63
+ }).fail(function (msg) {
64
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
65
+ })
63
66
  }
64
- return false;
65
- });
67
+ return false
68
+ })
66
69
 
67
70
  // handle ship click
68
71
  $('[data-hook=admin_shipment_form] a.ship').on('click', function () {
69
- var link = $(this);
70
- var shipment_number = link.data('shipment-number');
71
- var url = Spree.url(Spree.routes.shipments_api + '/' + shipment_number + '/ship.json');
72
+ var link = $(this)
73
+ var shipmentNumber = link.data('shipment-number')
74
+ var url = Spree.url(Spree.routes.shipments_api + '/' + shipmentNumber + '/ship.json')
72
75
  $.ajax({
73
76
  type: 'PUT',
74
77
  url: url,
@@ -76,76 +79,76 @@ $(document).ready(function () {
76
79
  token: Spree.api_key
77
80
  }
78
81
  }).done(function () {
79
- window.location.reload();
82
+ window.location.reload()
80
83
  }).error(function (msg) {
81
- console.log(msg);
82
- });
83
- });
84
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
85
+ })
86
+ })
84
87
 
85
88
  // handle shipping method edit click
86
- $('a.edit-method').click(toggleMethodEdit);
87
- $('a.cancel-method').click(toggleMethodEdit);
89
+ $('a.edit-method').click(toggleMethodEdit)
90
+ $('a.cancel-method').click(toggleMethodEdit)
88
91
 
89
92
  // handle shipping method save
90
93
  $('[data-hook=admin_shipment_form] a.save-method').on('click', function (event) {
91
- event.preventDefault();
94
+ event.preventDefault()
92
95
 
93
- var link = $(this);
94
- var shipment_number = link.data('shipment-number');
95
- var selected_shipping_rate_id = link.parents('tbody').find("select#selected_shipping_rate_id[data-shipment-number='" + shipment_number + "']").val();
96
- var unlock = link.parents('tbody').find("input[name='open_adjustment'][data-shipment-number='" + shipment_number + "']:checked").val();
97
- var url = Spree.url(Spree.routes.shipments_api + '/' + shipment_number + '.json');
96
+ var link = $(this)
97
+ var shipmentNumber = link.data('shipment-number')
98
+ var selectedShippingRateId = link.parents('tbody').find("select#selected_shipping_rate_id[data-shipment-number='" + shipmentNumber + "']").val()
99
+ var unlock = link.parents('tbody').find("input[name='open_adjustment'][data-shipment-number='" + shipmentNumber + "']:checked").val()
100
+ var url = Spree.url(Spree.routes.shipments_api + '/' + shipmentNumber + '.json')
98
101
 
99
102
  $.ajax({
100
103
  type: 'PUT',
101
104
  url: url,
102
105
  data: {
103
106
  shipment: {
104
- selected_shipping_rate_id: selected_shipping_rate_id,
107
+ selected_shipping_rate_id: selectedShippingRateId,
105
108
  unlock: unlock
106
109
  },
107
110
  token: Spree.api_key
108
111
  }
109
112
  }).done(function () {
110
- window.location.reload();
113
+ window.location.reload()
111
114
  }).error(function (msg) {
112
- console.log(msg);
113
- });
114
- });
115
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
116
+ })
117
+ })
115
118
 
116
- var toggleTrackingEdit = function(event) {
117
- event.preventDefault();
119
+ function toggleTrackingEdit (event) {
120
+ event.preventDefault()
118
121
 
119
- var link = $(this);
120
- link.parents('tbody').find('tr.edit-tracking').toggle();
121
- link.parents('tbody').find('tr.show-tracking').toggle();
122
+ var link = $(this)
123
+ link.parents('tbody').find('tr.edit-tracking').toggle()
124
+ link.parents('tbody').find('tr.show-tracking').toggle()
122
125
  }
123
126
 
124
127
  // handle tracking edit click
125
- $('a.edit-tracking').click(toggleTrackingEdit);
126
- $('a.cancel-tracking').click(toggleTrackingEdit);
128
+ $('a.edit-tracking').click(toggleTrackingEdit)
129
+ $('a.cancel-tracking').click(toggleTrackingEdit)
127
130
 
128
- var createTrackingValueContent = function (data) {
129
- var selected_shipping_method = data.shipping_methods.filter(function (method) {
130
- return method.id === data.selected_shipping_rate.shipping_method_id;
131
- })[0];
131
+ function createTrackingValueContent (data) {
132
+ var selectedShippingMethod = data.shipping_methods.filter(function (method) {
133
+ return method.id === data.selected_shipping_rate.shipping_method_id
134
+ })[0]
132
135
 
133
- if (selected_shipping_method && selected_shipping_method.tracking_url) {
134
- var shipmentTrackingUrl = selected_shipping_method.tracking_url.replace(/:tracking/, data.tracking);
135
- return '<a target="_blank" href="' + shipmentTrackingUrl + '">' + data.tracking + '<a>';
136
+ if (selectedShippingMethod && selectedShippingMethod.tracking_url) {
137
+ var shipmentTrackingUrl = selectedShippingMethod.tracking_url.replace(/:tracking/, data.tracking)
138
+ return '<a target="_blank" href="' + shipmentTrackingUrl + '">' + data.tracking + '<a>'
136
139
  }
137
140
 
138
- return data.tracking;
141
+ return data.tracking
139
142
  }
140
143
 
141
144
  // handle tracking save
142
145
  $('[data-hook=admin_shipment_form] a.save-tracking').on('click', function (event) {
143
- event.preventDefault();
146
+ event.preventDefault()
144
147
 
145
- var link = $(this);
146
- var shipment_number = link.data('shipment-number');
147
- var tracking = link.parents('tbody').find('input#tracking').val();
148
- var url = Spree.url(Spree.routes.shipments_api + '/' + shipment_number + '.json');
148
+ var link = $(this)
149
+ var shipmentNumber = link.data('shipment-number')
150
+ var tracking = link.parents('tbody').find('input#tracking').val()
151
+ var url = Spree.url(Spree.routes.shipments_api + '/' + shipmentNumber + '.json')
149
152
 
150
153
  $.ajax({
151
154
  type: 'PUT',
@@ -157,216 +160,218 @@ $(document).ready(function () {
157
160
  token: Spree.api_key
158
161
  }
159
162
  }).done(function (data) {
160
- link.parents('tbody').find('tr.edit-tracking').toggle();
163
+ link.parents('tbody').find('tr.edit-tracking').toggle()
161
164
 
162
- var show = link.parents('tbody').find('tr.show-tracking');
163
- show.toggle();
165
+ var show = link.parents('tbody').find('tr.show-tracking')
166
+ show.toggle()
164
167
 
165
168
  if (data.tracking) {
166
- show.find('.tracking-value').html($("<strong>").html(Spree.translations.tracking + ": ")).append(createTrackingValueContent(data));
169
+ show.find('.tracking-value').html($('<strong>').html(Spree.translations.tracking + ': ')).append(createTrackingValueContent(data))
167
170
  } else {
168
- show.find('.tracking-value').html(Spree.translations.no_tracking_present);
171
+ show.find('.tracking-value').html(Spree.translations.no_tracking_present)
169
172
  }
170
- });
171
- });
172
- });
173
-
174
- adjustShipmentItems = function(shipment_number, variant_id, quantity){
175
- var shipment = _.findWhere(shipments, {number: shipment_number + ''});
176
- var inventory_units = _.where(shipment.inventory_units, {variant_id: variant_id});
177
-
178
- var url = Spree.routes.shipments_api + "/" + shipment_number;
179
-
180
- var previous_quantity = inventory_units.reduce(function(accumulator, current_unit, _index, _array) {
181
- return accumulator + current_unit.quantity;
182
- }, 0);
183
-
184
- if(previous_quantity<quantity){
185
- url += "/add"
186
- new_quantity = (quantity - previous_quantity);
187
- }else if(previous_quantity>quantity){
188
- url += "/remove"
189
- new_quantity = (previous_quantity - quantity);
190
- }
191
- url += '.json';
173
+ })
174
+ })
175
+ })
176
+
177
+ function adjustShipmentItems (shipmentNumber, variantId, quantity) {
178
+ var shipment = _.findWhere(shipments, { number: shipmentNumber + '' })
179
+ var inventoryUnits = _.where(shipment.inventory_units, { variant_id: variantId })
180
+ var url = Spree.routes.shipments_api + '/' + shipmentNumber
181
+ var previousQuantity = inventoryUnits.reduce(function (accumulator, currentUnit, _index, _array) {
182
+ return accumulator + currentUnit.quantity
183
+ }, 0)
184
+ var newQuantity = 0
185
+
186
+ if (previousQuantity < quantity) {
187
+ url += '/add'
188
+ newQuantity = (quantity - previousQuantity)
189
+ } else if (previousQuantity > quantity) {
190
+ url += '/remove'
191
+ newQuantity = (previousQuantity - quantity)
192
+ }
193
+ url += '.json'
192
194
 
193
- if(new_quantity!=0){
194
- $.ajax({
195
- type: "PUT",
196
- url: Spree.url(url),
197
- data: {
198
- variant_id: variant_id,
199
- quantity: new_quantity,
200
- token: Spree.api_key
201
- }
202
- }).done(function( msg ) {
203
- window.location.reload();
204
- }).fail(function(msg) {
205
- alert(msg.responseJSON.message)
206
- });
207
- }
195
+ if (newQuantity !== 0) {
196
+ $.ajax({
197
+ type: 'PUT',
198
+ url: Spree.url(url),
199
+ data: {
200
+ variant_id: variantId,
201
+ quantity: newQuantity,
202
+ token: Spree.api_key
203
+ }
204
+ }).done(function (msg) {
205
+ window.location.reload()
206
+ }).fail(function (msg) {
207
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
208
+ })
209
+ }
208
210
  }
209
211
 
210
- toggleMethodEdit = function(){
211
- var link = $(this);
212
- link.parents('tbody').find('tr.edit-method').toggle();
213
- link.parents('tbody').find('tr.show-method').toggle();
212
+ function toggleMethodEdit () {
213
+ var link = $(this)
214
+ link.parents('tbody').find('tr.edit-method').toggle()
215
+ link.parents('tbody').find('tr.show-method').toggle()
214
216
 
215
- return false;
217
+ return false
216
218
  }
217
219
 
218
- toggleItemEdit = function(){
219
- var link = $(this);
220
- link.parent().find('a.edit-item').toggle();
221
- link.parent().find('a.cancel-item').toggle();
222
- link.parent().find('a.split-item').toggle();
223
- link.parent().find('a.save-item').toggle();
224
- link.parent().find('a.delete-item').toggle();
225
- link.parents('tr').find('td.item-qty-show').toggle();
226
- link.parents('tr').find('td.item-qty-edit').toggle();
227
-
228
- return false;
220
+ function toggleItemEdit () {
221
+ var link = $(this)
222
+ var linkParent = link.parent()
223
+ linkParent.find('a.edit-item').toggle()
224
+ linkParent.find('a.cancel-item').toggle()
225
+ linkParent.find('a.split-item').toggle()
226
+ linkParent.find('a.save-item').toggle()
227
+ linkParent.find('a.delete-item').toggle()
228
+ link.parents('tr').find('td.item-qty-show').toggle()
229
+ link.parents('tr').find('td.item-qty-edit').toggle()
230
+
231
+ return false
229
232
  }
230
233
 
231
- startItemSplit = function(event){
232
- event.preventDefault();
233
- $('.cancel-split').each(function(){
234
+ function startItemSplit (event) {
235
+ event.preventDefault()
236
+ $('.cancel-split').each(function () {
234
237
  $(this).click()
235
238
  })
236
- var link = $(this);
237
- link.parent().find('a.edit-item').toggle();
238
- link.parent().find('a.split-item').toggle();
239
- link.parent().find('a.delete-item').toggle();
240
- var variant_id = link.data('variant-id');
239
+ var link = $(this)
240
+ link.parent().find('a.edit-item').toggle()
241
+ link.parent().find('a.split-item').toggle()
242
+ link.parent().find('a.delete-item').toggle()
243
+ var variantId = link.data('variant-id')
241
244
 
242
- var variant = {};
245
+ var variant = {}
243
246
  $.ajax({
244
- type: "GET",
247
+ type: 'GET',
245
248
  async: false,
246
249
  url: Spree.url(Spree.routes.variants_api),
247
250
  data: {
248
251
  q: {
249
- "id_eq": variant_id
252
+ 'id_eq': variantId
250
253
  },
251
254
  token: Spree.api_key
252
255
  }
253
- }).success(function( data ) {
254
- variant = data['variants'][0];
255
- }).error(function( msg ) {
256
- console.log(msg);
257
- });
258
-
259
- var max_quantity = link.closest('tr').data('item-quantity');
260
- var split_item_template = Handlebars.compile($('#variant_split_template').text());
261
- link.closest('tr').after(split_item_template({ variant: variant, shipments: shipments, max_quantity: max_quantity }));
262
- $('a.cancel-split').click(cancelItemSplit);
263
- $('a.save-split').click(completeItemSplit);
264
-
265
- $('#item_stock_location').select2({ width: 'resolve', placeholder: Spree.translations.item_stock_placeholder });
256
+ }).success(function (data) {
257
+ variant = data['variants'][0]
258
+ }).error(function (msg) {
259
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
260
+ })
261
+
262
+ var maxQuantity = link.closest('tr').data('item-quantity')
263
+ var splitItemTemplate = Handlebars.compile($('#variant_split_template').text())
264
+ link.closest('tr').after(splitItemTemplate({ variant: variant, shipments: shipments, max_quantity: maxQuantity }))
265
+ $('a.cancel-split').click(cancelItemSplit)
266
+ $('a.save-split').click(completeItemSplit)
267
+
268
+ $('#item_stock_location').select2({ width: 'resolve', placeholder: Spree.translations.item_stock_placeholder })
266
269
  }
267
270
 
268
- completeItemSplit = function(event) {
269
- event.preventDefault();
271
+ function completeItemSplit (event) {
272
+ event.preventDefault()
270
273
 
271
- if($('#item_stock_location').val() === ""){
272
- alert('Please select the split destination.');
273
- return false;
274
+ if ($('#item_stock_location').val() === '') {
275
+ alert('Please select the split destination.')
276
+ return false
274
277
  }
275
278
 
276
- var link = $(this);
277
- var stock_item_row = link.closest('tr');
278
- var variant_id = stock_item_row.data('variant-id');
279
- var quantity = stock_item_row.find('#item_quantity').val();
280
-
281
- var stock_location_id = stock_item_row.find('#item_stock_location').val();
282
- var original_shipment_number = link.closest('tbody').data('shipment-number');
279
+ var link = $(this)
280
+ var stockItemRow = link.closest('tr')
281
+ var variantId = stockItemRow.data('variant-id')
282
+ var quantity = stockItemRow.find('#item_quantity').val()
283
283
 
284
- var selected_shipment = stock_item_row.find($('#item_stock_location').select2('data').element);
285
- var target_shipment_number = selected_shipment.data('shipment-number');
286
- var new_shipment = selected_shipment.data('new-shipment');
284
+ var stockLocationId = stockItemRow.find('#item_stock_location').val()
285
+ var originalShipmentNumber = link.closest('tbody').data('shipment-number')
287
286
 
288
- if (stock_location_id != 'new_shipment') {
289
- if (new_shipment != undefined) {
290
- // TRANSFER TO A NEW LOCATION
287
+ var selectedShipment = stockItemRow.find($('#item_stock_location').select2('data').element)
288
+ var targetShipmentNumber = selectedShipment.data('shipment-number')
289
+ var newShipment = selectedShipment.data('new-shipment')
290
+ // eslint-disable-next-line
291
+ if (stockLocationId !== 'new_shipment') {
292
+ var splitItems = function (opts) {
291
293
  $.ajax({
292
- type: "POST",
294
+ type: 'POST',
293
295
  async: false,
294
- url: Spree.url(Spree.routes.shipments_api + "/transfer_to_location"),
296
+ url: opts.url,
297
+ data: opts.data
298
+ }).error(function (msg) {
299
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
300
+ }).done(function () {
301
+ window.location.reload()
302
+ })
303
+ }
304
+
305
+ if (newShipment !== undefined) {
306
+ // TRANSFER TO A NEW LOCATION
307
+ splitItems({
308
+ url: Spree.url(Spree.routes.shipments_api + '/transfer_to_location'),
295
309
  data: {
296
- original_shipment_number: original_shipment_number,
297
- variant_id: variant_id,
298
- quantity: quantity,
299
- stock_location_id: stock_location_id,
300
- token: Spree.api_key
310
+ original_shipment_number: originalShipmentNumber,
311
+ variant_id: variantId,
312
+ quantity: quantity,
313
+ stock_location_id: stockLocationId,
314
+ token: Spree.api_key
301
315
  }
302
- }).error(function(msg) {
303
- alert(msg.responseJSON.exception);
304
- }).done(function(msg) {
305
- window.location.reload();
306
- });
316
+ })
307
317
  } else {
308
- // TRANSFER TO AN EXISTING SHIPMENT
309
- $.ajax({
310
- type: "POST",
311
- async: false,
312
- url: Spree.url(Spree.routes.shipments_api + "/transfer_to_shipment"),
313
- data: {
314
- original_shipment_number: original_shipment_number,
315
- target_shipment_number: target_shipment_number,
316
- variant_id: variant_id,
317
- quantity: quantity,
318
- token: Spree.api_key
319
- }
320
- }).error(function(msg) {
321
- alert(msg.responseJSON.exception);
322
- }).done(function(msg) {
323
- window.location.reload();
324
- });
318
+ // TRANSFER TO AN EXISTING SHIPMENT
319
+ splitItems({
320
+ url: Spree.url(Spree.routes.shipments_api + '/transfer_to_shipment'),
321
+ data: {
322
+ original_shipment_number: originalShipmentNumber,
323
+ target_shipment_number: targetShipmentNumber,
324
+ variant_id: variantId,
325
+ quantity: quantity,
326
+ token: Spree.api_key
327
+ }
328
+ })
325
329
  }
326
330
  }
327
331
  }
328
332
 
329
- cancelItemSplit = function(event) {
330
- event.preventDefault();
331
- var link = $(this);
332
- var prev_row = link.closest('tr').prev();
333
- link.closest('tr').remove();
334
- prev_row.find('a.edit-item').toggle();
335
- prev_row.find('a.split-item').toggle();
336
- prev_row.find('a.delete-item').toggle();
333
+ function cancelItemSplit (event) {
334
+ event.preventDefault()
335
+ var link = $(this)
336
+ var prevRow = link.closest('tr').prev()
337
+ link.closest('tr').remove()
338
+ prevRow.find('a.edit-item').toggle()
339
+ prevRow.find('a.split-item').toggle()
340
+ prevRow.find('a.delete-item').toggle()
337
341
  }
338
342
 
339
- addVariantFromStockLocation = function(event) {
340
- event.preventDefault();
343
+ function addVariantFromStockLocation (event) {
344
+ event.preventDefault()
341
345
 
342
- $('#stock_details').hide();
346
+ $('#stock_details').hide()
343
347
 
344
- var variant_id = $('input.variant_autocomplete').val();
345
- var stock_location_id = $(this).data('stock-location-id');
346
- var quantity = $("input.quantity[data-stock-location-id='" + stock_location_id + "']").val();
348
+ var variantId = $('input.variant_autocomplete').val()
349
+ var stockLocationId = $(this).data('stock-location-id')
350
+ var quantity = $("input.quantity[data-stock-location-id='" + stockLocationId + "']").val()
347
351
 
348
- var shipment = _.find(shipments, function(shipment){
349
- return shipment.stock_location_id == stock_location_id && (shipment.state == 'ready' || shipment.state == 'pending');
350
- });
352
+ var shipment = _.find(shipments, function (shipment) {
353
+ return shipment.stock_location_id === stockLocationId && (shipment.state === 'ready' || shipment.state === 'pending')
354
+ })
351
355
 
352
- if(shipment==undefined){
356
+ if (shipment === undefined) {
353
357
  $.ajax({
354
- type: "POST",
355
- url: Spree.url(Spree.routes.shipments_api + "?shipment[order_id]=" + order_number),
358
+ type: 'POST',
359
+ // eslint-disable-next-line camelcase
360
+ url: Spree.url(Spree.routes.shipments_api + '?shipment[order_id]=' + order_number),
356
361
  data: {
357
- variant_id: variant_id,
362
+ variant_id: variantId,
358
363
  quantity: quantity,
359
- stock_location_id: stock_location_id,
364
+ stock_location_id: stockLocationId,
360
365
  token: Spree.api_key
361
366
  }
362
- }).done(function( msg ) {
363
- window.location.reload();
364
- }).error(function( msg ) {
365
- console.log(msg);
366
- });
367
- }else{
368
- //add to existing shipment
369
- adjustShipmentItems(shipment.number, variant_id, quantity);
367
+ }).done(function (msg) {
368
+ window.location.reload()
369
+ }).error(function (msg) {
370
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
371
+ })
372
+ } else {
373
+ // add to existing shipment
374
+ adjustShipmentItems(shipment.number, variantId, quantity)
370
375
  }
371
376
  return 1
372
377
  }