spree_backend 2.3.13 → 2.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend/address_states.js +1 -3
  3. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +1 -2
  4. data/app/assets/javascripts/spree/backend/admin.js.erb +11 -1
  5. data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -20
  6. data/app/assets/javascripts/spree/backend/line_items.js.coffee +2 -5
  7. data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js.erb +50 -0
  8. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +2 -4
  9. data/app/assets/javascripts/spree/backend/orders/edit_form.js +2 -3
  10. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +5 -5
  11. data/app/assets/javascripts/spree/backend/product_picker.js +2 -4
  12. data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +4 -0
  13. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +35 -0
  14. data/app/assets/javascripts/spree/backend/shipments.js.erb +39 -52
  15. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +1 -2
  16. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +1 -2
  17. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +8 -6
  18. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +5 -24
  19. data/app/assets/javascripts/spree/backend/taxons.js.coffee +2 -4
  20. data/app/assets/javascripts/spree/backend/user_picker.js +2 -3
  21. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +2 -2
  22. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +0 -5
  23. data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +5 -2
  24. data/app/assets/stylesheets/spree/backend/sections/_adjustments_table.scss +8 -0
  25. data/app/assets/stylesheets/spree/backend/sections/_products.scss +4 -0
  26. data/app/assets/stylesheets/spree/backend/sections/_return_authorizations.scss +24 -0
  27. data/app/assets/stylesheets/spree/backend/sections/_taxons.scss +1 -7
  28. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +8 -0
  29. data/app/assets/stylesheets/spree/backend/spree_admin.scss +2 -0
  30. data/app/assets/stylesheets/spree/backend.css +1 -1
  31. data/app/controllers/spree/admin/adjustments_controller.rb +1 -7
  32. data/app/controllers/spree/admin/base_controller.rb +8 -2
  33. data/app/controllers/spree/admin/customer_returns_controller.rb +67 -0
  34. data/app/controllers/spree/admin/general_settings_controller.rb +1 -1
  35. data/app/controllers/spree/admin/images_controller.rb +1 -1
  36. data/app/controllers/spree/admin/log_entries_controller.rb +2 -2
  37. data/app/controllers/spree/admin/option_types_controller.rb +1 -1
  38. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
  39. data/app/controllers/spree/admin/orders_controller.rb +21 -10
  40. data/app/controllers/spree/admin/payment_methods_controller.rb +3 -3
  41. data/app/controllers/spree/admin/payments_controller.rb +6 -12
  42. data/app/controllers/spree/admin/product_properties_controller.rb +2 -2
  43. data/app/controllers/spree/admin/products_controller.rb +1 -1
  44. data/app/controllers/spree/admin/promotion_actions_controller.rb +2 -2
  45. data/app/controllers/spree/admin/promotion_categories_controller.rb +6 -0
  46. data/app/controllers/spree/admin/promotion_rules_controller.rb +2 -2
  47. data/app/controllers/spree/admin/promotions_controller.rb +2 -1
  48. data/app/controllers/spree/admin/refund_reasons_controller.rb +6 -0
  49. data/app/controllers/spree/admin/refunds_controller.rb +31 -0
  50. data/app/controllers/spree/admin/reimbursement_types_controller.rb +6 -0
  51. data/app/controllers/spree/admin/reimbursements_controller.rb +44 -0
  52. data/app/controllers/spree/admin/resource_controller.rb +2 -2
  53. data/app/controllers/spree/admin/return_authorization_reasons_controller.rb +6 -0
  54. data/app/controllers/spree/admin/return_authorizations_controller.rb +35 -5
  55. data/app/controllers/spree/admin/return_items_controller.rb +9 -0
  56. data/app/controllers/spree/admin/search_controller.rb +1 -1
  57. data/app/controllers/spree/admin/shipping_methods_controller.rb +3 -3
  58. data/app/controllers/spree/admin/states_controller.rb +1 -1
  59. data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
  60. data/app/controllers/spree/admin/stock_locations_controller.rb +1 -1
  61. data/app/controllers/spree/admin/stock_transfers_controller.rb +2 -2
  62. data/app/controllers/spree/admin/tax_rates_controller.rb +1 -1
  63. data/app/controllers/spree/admin/users_controller.rb +4 -4
  64. data/app/controllers/spree/admin/variants_controller.rb +2 -2
  65. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  66. data/app/helpers/spree/admin/customer_returns_helper.rb +9 -0
  67. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  68. data/app/helpers/spree/admin/reimbursement_type_helper.rb +9 -0
  69. data/app/helpers/spree/admin/reimbursements_helper.rb +14 -0
  70. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +7 -3
  71. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +36 -0
  72. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +50 -0
  73. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +43 -0
  74. data/app/views/spree/admin/customer_returns/edit.html.erb +65 -0
  75. data/app/views/spree/admin/customer_returns/index.html.erb +60 -0
  76. data/app/views/spree/admin/customer_returns/new.html.erb +60 -0
  77. data/app/views/spree/admin/general_settings/edit.html.erb +6 -0
  78. data/app/views/spree/admin/images/_form.html.erb +6 -6
  79. data/app/views/spree/admin/log_entries/_credit_card.html.erb +4 -0
  80. data/app/views/spree/admin/log_entries/index.html.erb +2 -5
  81. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +5 -7
  82. data/app/views/spree/admin/option_types/edit.html.erb +9 -2
  83. data/app/views/spree/admin/orders/_add_line_item.html.erb +18 -0
  84. data/app/views/spree/admin/orders/_form.html.erb +7 -7
  85. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +40 -0
  86. data/app/views/spree/admin/orders/_shipment.html.erb +1 -1
  87. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +5 -4
  88. data/app/views/spree/admin/orders/cart.html.erb +39 -0
  89. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  90. data/app/views/spree/admin/orders/edit.html.erb +2 -2
  91. data/app/views/spree/admin/orders/index.html.erb +8 -14
  92. data/app/views/spree/admin/payment_methods/_form.html.erb +7 -7
  93. data/app/views/spree/admin/payments/_list.html.erb +11 -3
  94. data/app/views/spree/admin/payments/index.html.erb +13 -1
  95. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +4 -6
  96. data/app/views/spree/admin/products/_form.html.erb +20 -6
  97. data/app/views/spree/admin/products/new.html.erb +3 -3
  98. data/app/views/spree/admin/products/stock.html.erb +1 -1
  99. data/app/views/spree/admin/promotion_categories/_form.html.erb +10 -0
  100. data/app/views/spree/admin/promotion_categories/edit.html.erb +17 -0
  101. data/app/views/spree/admin/promotion_categories/index.html.erb +34 -0
  102. data/app/views/spree/admin/promotion_categories/new.html.erb +16 -0
  103. data/app/views/spree/admin/promotion_rules/create.js.erb +2 -0
  104. data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
  105. data/app/views/spree/admin/promotions/_form.html.erb +5 -0
  106. data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +7 -7
  107. data/app/views/spree/admin/promotions/index.html.erb +16 -6
  108. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +4 -2
  109. data/app/views/spree/admin/promotions/rules/_one_use_per_user.html.erb +0 -0
  110. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +9 -0
  111. data/app/views/spree/admin/prototypes/_form.html.erb +2 -2
  112. data/app/views/spree/admin/refund_reasons/edit.html.erb +4 -0
  113. data/app/views/spree/admin/refund_reasons/index.html.erb +5 -0
  114. data/app/views/spree/admin/refund_reasons/new.html.erb +4 -0
  115. data/app/views/spree/admin/refunds/edit.html.erb +31 -0
  116. data/app/views/spree/admin/refunds/new.html.erb +43 -0
  117. data/app/views/spree/admin/reimbursement_types/index.html.erb +33 -0
  118. data/app/views/spree/admin/reimbursements/edit.html.erb +108 -0
  119. data/app/views/spree/admin/reimbursements/index.html.erb +34 -0
  120. data/app/views/spree/admin/reimbursements/show.html.erb +94 -0
  121. data/app/views/spree/admin/return_authorization_reasons/edit.html.erb +4 -0
  122. data/app/views/spree/admin/return_authorization_reasons/index.html.erb +5 -0
  123. data/app/views/spree/admin/return_authorization_reasons/new.html.erb +4 -0
  124. data/app/views/spree/admin/return_authorizations/_form.html.erb +62 -50
  125. data/app/views/spree/admin/return_authorizations/edit.html.erb +6 -8
  126. data/app/views/spree/admin/return_authorizations/index.html.erb +3 -4
  127. data/app/views/spree/admin/return_authorizations/new.html.erb +1 -1
  128. data/app/views/spree/admin/shared/_configuration_menu.html.erb +5 -2
  129. data/app/views/spree/admin/shared/_destroy.js.erb +1 -1
  130. data/app/views/spree/admin/shared/_head.html.erb +1 -2
  131. data/app/views/spree/admin/shared/_order_submenu.html.erb +17 -3
  132. data/app/views/spree/admin/shared/_order_summary.html.erb +7 -0
  133. data/app/views/spree/admin/shared/_product_tabs.html.erb +1 -0
  134. data/app/views/spree/admin/shared/_refunds.html.erb +32 -0
  135. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +12 -12
  136. data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
  137. data/app/views/spree/admin/shared/named_types/_edit.html.erb +17 -0
  138. data/app/views/spree/admin/shared/named_types/_form.html.erb +16 -0
  139. data/app/views/spree/admin/shared/named_types/_index.html.erb +52 -0
  140. data/app/views/spree/admin/shared/named_types/_new.html.erb +16 -0
  141. data/app/views/spree/admin/shipping_categories/_form.html.erb +1 -1
  142. data/app/views/spree/admin/shipping_methods/_form.html.erb +8 -0
  143. data/app/views/spree/admin/stock_locations/_form.html.erb +77 -59
  144. data/app/views/spree/admin/stock_transfers/new.html.erb +2 -2
  145. data/app/views/spree/admin/tax_categories/_form.html.erb +9 -2
  146. data/app/views/spree/admin/tax_categories/index.html.erb +4 -1
  147. data/app/views/spree/admin/taxons/index.html.erb +4 -0
  148. data/app/views/spree/admin/trackers/_form.html.erb +4 -4
  149. data/app/views/spree/admin/users/_form.html.erb +1 -1
  150. data/app/views/spree/admin/users/index.html.erb +1 -1
  151. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +49 -0
  152. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -1
  153. data/app/views/spree/admin/variants/_split.js.erb +1 -1
  154. data/app/views/spree/admin/zones/_form.html.erb +1 -1
  155. data/config/initializers/assets.rb +1 -1
  156. data/config/routes.rb +22 -1
  157. metadata +62 -32
  158. data/app/controllers/spree/admin/inventory_units_controller.rb +0 -6
  159. data/app/controllers/spree/admin/line_items_controller.rb +0 -49
  160. data/app/controllers/spree/admin/overview_controller.rb +0 -11
  161. data/app/views/spree/admin/inventory_units/adjust.html.erb +0 -31
  162. data/app/views/spree/test_mailer/test_email.text.erb +0 -4
  163. data/config/locales/en.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e8b3afbab00ffe19dcef09a49f211f8fcee580c
4
- data.tar.gz: f1d987f5916288b615fbeba2c34d424cde5e9863
3
+ metadata.gz: 0220e72e24f0fd5829e9a2be90630eeaf2b9e779
4
+ data.tar.gz: c2086648a7074b09bfac87626d946b5c4de5ec7d
5
5
  SHA512:
6
- metadata.gz: ce2ee322aa3dcd44ce7ab37d41d974dee58083b237e232f1a5e58f017e6c076f31278f4e246dd413197ce28c69e7c4e71a6e580dd983c91e7df3226bddd30f2b
7
- data.tar.gz: 8d344c7b53402e629187bf3ba9ee61c037665381210c1be885744d10cfc568fe0d9f34b1d9f02b64da035349661ded9cf58dd3c7f9fea481d4c830d2bafd2c8a
6
+ metadata.gz: 63f76b4dd18c00535e94297f58b76857443695cade165edc515a17051676be59bbdfa9427826e5b9e95acb5aa44a8b44d1bf5a024fc079f24b5bce8ebede717e
7
+ data.tar.gz: e4d6fd9b4c73c83f32bdeb219a348b2a9182273ebd3c3262fa321b44fe4475f5d008e0749fee17a606794c01df2cf381d5bcb1c7b340e9191ef70678d816f70e
@@ -1,4 +1,4 @@
1
- var update_state = function (region, done) {
1
+ var update_state = function (region) {
2
2
  'use strict';
3
3
 
4
4
  var country = $('span#' + region + 'country .select2').select2('val');
@@ -27,7 +27,5 @@ var update_state = function (region, done) {
27
27
  state_input.prop('disabled', false).show();
28
28
  state_select.select2('destroy').hide();
29
29
  }
30
-
31
- if(done) done();
32
30
  });
33
31
  };
@@ -6,7 +6,6 @@ $(@).ready( ->
6
6
  url: Spree.url(Spree.routes.apply_coupon_code(order_number))
7
7
  data:
8
8
  coupon_code: $("#coupon_code").val()
9
- token: Spree.api_key
10
9
  success: ->
11
10
  window.location.reload();
12
11
  error: (msg) ->
@@ -14,4 +13,4 @@ $(@).ready( ->
14
13
  show_flash 'error', msg.responseJSON["error"]
15
14
  else
16
15
  show_flash 'error', "There was a problem adding this coupon code."
17
- )
16
+ )
@@ -47,7 +47,7 @@ jQuery(function($) {
47
47
  setTimeout('$(".flash").fadeOut()', 5000);
48
48
 
49
49
  // Highlight hovered table column
50
- $('table tbody tr td.actions a').hover(function(){
50
+ $('table tbody tr td.actions').find('a, button').hover(function(){
51
51
  var tr = $(this).closest('tr');
52
52
  var klass = 'highlight action-' + $(this).data('action')
53
53
  tr.addClass(klass)
@@ -271,4 +271,14 @@ $(document).ready(function(){
271
271
  $('a.dismiss').click(function() {
272
272
  $(this).parent().fadeOut();
273
273
  });
274
+
275
+ window.Spree.advanceOrder = function() {
276
+ $.ajax({
277
+ type: "PUT",
278
+ async: false,
279
+ url: Spree.url(Spree.routes.checkouts_api + "/" + order_number + "/advance")
280
+ }).done(function() {
281
+ window.location.reload();
282
+ });
283
+ }
274
284
  });
@@ -19,10 +19,7 @@ $(document).ready(function() {
19
19
  url: Spree.routes.user_search,
20
20
  datatype: 'json',
21
21
  data: function(term, page) {
22
- return {
23
- q: term,
24
- token: Spree.api_key
25
- }
22
+ return { q: term }
26
23
  },
27
24
  results: function(data, page) {
28
25
  return { results: data }
@@ -37,22 +34,6 @@ $(document).ready(function() {
37
34
  $('#guest_checkout_false').prop("checked", true);
38
35
  $('#guest_checkout_false').prop("disabled", false);
39
36
 
40
- var billAddress = customer.bill_address;
41
- if(billAddress) {
42
- $('#order_bill_address_attributes_firstname').val(billAddress.firstname);
43
- $('#order_bill_address_attributes_lastname').val(billAddress.lastname);
44
- $('#order_bill_address_attributes_address1').val(billAddress.address1);
45
- $('#order_bill_address_attributes_address2').val(billAddress.address2);
46
- $('#order_bill_address_attributes_city').val(billAddress.city);
47
- $('#order_bill_address_attributes_zipcode').val(billAddress.zipcode);
48
- $('#order_bill_address_attributes_phone').val(billAddress.phone);
49
-
50
- $('#order_bill_address_attributes_country_id').select2("val", billAddress.country_id).promise().done(function () {
51
- update_state('b', function () {
52
- $('#order_bill_address_attributes_state_id').select2("val", billAddress.state_id);
53
- });
54
- });
55
- }
56
37
  return customer.email;
57
38
  }
58
39
  })
@@ -46,19 +46,16 @@ adjustLineItem = (line_item_id, quantity) ->
46
46
  data:
47
47
  line_item:
48
48
  quantity: quantity
49
- token: Spree.api_key
50
49
  ).done (msg) ->
51
- advanceOrder()
50
+ window.Spree.advanceOrder()
52
51
 
53
52
  deleteLineItem = (line_item_id) ->
54
53
  url = lineItemURL(line_item_id)
55
54
  $.ajax(
56
55
  type: "DELETE"
57
56
  url: Spree.url(url)
58
- data:
59
- token: Spree.api_key
60
57
  ).done (msg) ->
61
58
  $('#line-item-' + line_item_id).remove()
62
59
  if $('.line-items tr.line-item').length == 0
63
60
  $('.line-items').remove()
64
- advanceOrder()
61
+ window.Spree.advanceOrder()
@@ -0,0 +1,50 @@
1
+ // This file contains the code for interacting with line items in the manual cart
2
+ $(document).ready(function () {
3
+ 'use strict';
4
+
5
+ // handle variant selection, show stock level.
6
+ $('#add_line_item_variant_id').change(function(){
7
+ var variant_id = $(this).val();
8
+
9
+ var variant = _.find(window.variants, function(variant){
10
+ return variant.id == variant_id
11
+ })
12
+ $('#stock_details').html(variantLineItemTemplate({variant: variant}));
13
+ $('#stock_details').show();
14
+
15
+ $('button.add_variant').click(addVariant);
16
+
17
+ // Add some tips
18
+ $('.with-tip').powerTip({
19
+ smartPlacement: true,
20
+ fadeInTime: 50,
21
+ fadeOutTime: 50,
22
+ intentPollInterval: 300
23
+ });
24
+
25
+ });
26
+ });
27
+
28
+ addVariant = function() {
29
+ $('#stock_details').hide();
30
+
31
+ var variant_id = $('input.variant_autocomplete').val();
32
+ var quantity = $("input.quantity[data-variant-id='" + variant_id + "']").val();
33
+
34
+ adjustLineItems(order_number, variant_id, quantity);
35
+ return 1
36
+ }
37
+
38
+ adjustLineItems = function(order_number, variant_id, quantity){
39
+ var url = Spree.routes.orders_api + "/" + order_number + '/line_items';
40
+
41
+ $.ajax({
42
+ type: "POST",
43
+ url: Spree.url(url),
44
+ data: { line_item: {variant_id: variant_id, quantity: quantity }}
45
+ }).done(function( msg ) {
46
+ window.Spree.advanceOrder();
47
+ window.location.reload();
48
+ });
49
+
50
+ }
@@ -7,8 +7,7 @@ $(document).ready(function () {
7
7
  multiple: true,
8
8
  initSelection: function (element, callback) {
9
9
  var url = Spree.url(Spree.routes.option_type_search, {
10
- ids: element.val(),
11
- token: Spree.api_key
10
+ ids: element.val()
12
11
  });
13
12
  return $.getJSON(url, null, function (data) {
14
13
  return callback(data);
@@ -22,8 +21,7 @@ $(document).ready(function () {
22
21
  return {
23
22
  q: {
24
23
  name_cont: term
25
- },
26
- token: Spree.api_key
24
+ }
27
25
  };
28
26
  },
29
27
  results: function (data) {
@@ -9,8 +9,7 @@ $(document).ready(function () {
9
9
 
10
10
  $.post('/admin/orders/' + $('input#order_number').val() + '/line_items/' + $(id).val(), {
11
11
  _method: 'put',
12
- 'line_item[quantity]': $(this).val(),
13
- token: Spree.api_key
12
+ 'line_item[quantity]': $(this).val()
14
13
  },
15
14
 
16
15
  function (resp) {
@@ -18,4 +17,4 @@ $(document).ready(function () {
18
17
  });
19
18
  });
20
19
  });
21
- });
20
+ });
@@ -3,13 +3,13 @@ jQuery ($) ->
3
3
  order_id = $('#payments').data('order-id')
4
4
  class Payment
5
5
  constructor: (id) ->
6
- @url = Spree.url("#{Spree.routes.payments_api(order_id)}/#{id}.json" + '?token=' + Spree.api_key)
6
+ @url = Spree.url("#{Spree.routes.payments_api(order_id)}/#{id}.json")
7
7
  @json = $.getJSON @url.toString(), (data) =>
8
8
  @data = data
9
9
 
10
- if_editable: (callback) ->
10
+ if_pending: (callback) ->
11
11
  @json.done (data) ->
12
- callback() if data.state in ['checkout', 'pending']
12
+ callback() if data.state is 'pending'
13
13
 
14
14
  update: (attributes, success) ->
15
15
  jqXHR = $.ajax
@@ -142,8 +142,8 @@ jQuery ($) ->
142
142
  separator = Spree.translations.currency_separator
143
143
  amount.replace(///[^\d#{separator}]///g, '')
144
144
 
145
- # Attach ShowPaymentView to each editable payment in the table
145
+ # Attach ShowPaymentView to each pending payment in the table
146
146
  $('.admin tr[data-hook=payments_row]').each ->
147
147
  $el = $(@)
148
148
  payment = new Payment($el.prop('id').match(/\d+$/))
149
- payment.if_editable -> new ShowPaymentView($el, payment)
149
+ payment.if_pending -> new ShowPaymentView($el, payment)
@@ -6,8 +6,7 @@ $.fn.productAutocomplete = function () {
6
6
  multiple: true,
7
7
  initSelection: function (element, callback) {
8
8
  $.get(Spree.routes.product_search, {
9
- ids: element.val().split(','),
10
- token: Spree.api_key
9
+ ids: element.val().split(',')
11
10
  }, function (data) {
12
11
  callback(data.products);
13
12
  });
@@ -21,8 +20,7 @@ $.fn.productAutocomplete = function () {
21
20
  name_cont: term,
22
21
  sku_cont: term
23
22
  },
24
- m: 'OR',
25
- token: Spree.api_key
23
+ m: 'OR'
26
24
  };
27
25
  },
28
26
  results: function (data, page) {
@@ -0,0 +1,4 @@
1
+ $ ->
2
+ $(document).on("change", ".return-items-table .return-item-exchange-selection", ->
3
+ $(".expedited-exchanges-warning").fadeIn()
4
+ )
@@ -0,0 +1,35 @@
1
+ $(document).ready(function() {
2
+ var formFields = $("[data-hook='admin_customer_return_form_fields'], \
3
+ [data-hook='admin_return_authorization_form_fields']");
4
+
5
+ if(formFields.length > 0) {
6
+ function checkAddItemBox() {
7
+ $(this).closest('tr').find('input.add-item').attr('checked', 'checked');
8
+ updateSuggestedAmount();
9
+ }
10
+
11
+ function updateSuggestedAmount() {
12
+ var totalPretaxRefund = 0;
13
+ var checkedItems = formFields.find('input.add-item:checked');
14
+ $.each(checkedItems, function(i, checkbox) {
15
+ totalPretaxRefund += parseFloat($(checkbox).parents('tr').find('.refund-amount-input').val());
16
+ });
17
+
18
+ var displayTotal = isNaN(totalPretaxRefund) ? '' : totalPretaxRefund.toFixed(2);
19
+ formFields.find('span#total_pre_tax_refund').html(displayTotal);
20
+ }
21
+
22
+ updateSuggestedAmount();
23
+
24
+ formFields.find('input#select-all').on('change', function(ev) {
25
+ var checkBoxes = $(ev.currentTarget).parents('table:first').find('input.add-item');
26
+ checkBoxes.prop('checked', this.checked);
27
+ updateSuggestedAmount();
28
+ });
29
+
30
+ formFields.find('input.add-item').on('change', updateSuggestedAmount);
31
+ formFields.find('.refund-amount-input').on('keyup', updateSuggestedAmount);
32
+
33
+ formFields.find('input, select').not('.add-item').on('change', checkAddItemBox);
34
+ }
35
+ });
@@ -66,10 +66,7 @@ $(document).ready(function () {
66
66
  var url = Spree.url(Spree.routes.shipments_api + '/' + shipment_number + '/ship.json');
67
67
  $.ajax({
68
68
  type: 'PUT',
69
- url: url,
70
- data: {
71
- token: Spree.api_key
72
- }
69
+ url: url
73
70
  }).done(function () {
74
71
  window.location.reload();
75
72
  }).error(function (msg) {
@@ -98,8 +95,7 @@ $(document).ready(function () {
98
95
  shipment: {
99
96
  selected_shipping_rate_id: selected_shipping_rate_id,
100
97
  unlock: unlock
101
- },
102
- token: Spree.api_key
98
+ }
103
99
  }
104
100
  }).done(function () {
105
101
  window.location.reload();
@@ -135,8 +131,7 @@ $(document).ready(function () {
135
131
  data: {
136
132
  shipment: {
137
133
  tracking: tracking
138
- },
139
- token: Spree.api_key
134
+ }
140
135
  }
141
136
  }).done(function (data) {
142
137
  link.parents('tbody').find('tr.edit-tracking').toggle();
@@ -168,11 +163,7 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
168
163
  $.ajax({
169
164
  type: "PUT",
170
165
  url: Spree.url(url),
171
- data: {
172
- variant_id: variant_id,
173
- quantity: new_quantity,
174
- token: Spree.api_key
175
- }
166
+ data: { variant_id: variant_id, quantity: new_quantity }
176
167
  }).done(function( msg ) {
177
168
  window.location.reload();
178
169
  });
@@ -216,8 +207,7 @@ startItemSplit = function(event){
216
207
  data: {
217
208
  q: {
218
209
  "id_eq": variant_id
219
- },
220
- token: Spree.api_key
210
+ }
221
211
  }
222
212
  }).success(function( data ) {
223
213
  variant = data['variants'][0];
@@ -243,8 +233,13 @@ startItemSplit = function(event){
243
233
 
244
234
  completeItemSplit = function(event) {
245
235
  event.preventDefault();
236
+
237
+ if($('#item_stock_location').val() === ""){
238
+ alert('Please select the split destination.');
239
+ return false;
240
+ }
241
+
246
242
  var link = $(this);
247
- var order_number = link.closest('tbody').data('order-number');
248
243
  var stock_item_row = link.closest('tr');
249
244
  var variant_id = stock_item_row.data('variant-id');
250
245
  var quantity = stock_item_row.find('#item_quantity').val();
@@ -257,47 +252,44 @@ completeItemSplit = function(event) {
257
252
  var new_shipment = selected_shipment.data('new-shipment');
258
253
 
259
254
  if (stock_location_id != 'new_shipment') {
260
- // first remove item(s) from original shipment
261
- $.ajax({
262
- type: "PUT",
263
- async: false,
264
- url: Spree.url(Spree.routes.shipments_api + "/" + original_shipment_number + "/remove.json"),
265
- data: { variant_id: variant_id, quantity: quantity }
266
- });
267
-
268
255
  if (new_shipment != undefined) {
256
+ // TRANSFER TO A NEW LOCATION
269
257
  $.ajax({
270
258
  type: "POST",
271
259
  async: false,
272
- url: Spree.url(Spree.routes.shipments_api + "?shipment[order_id]=" + order_number),
273
- data: { variant_id: variant_id, quantity: quantity, stock_location_id: stock_location_id, token: Spree.api_key }
260
+ url: Spree.url(Spree.routes.shipments_api + "/transfer_to_location"),
261
+ data: {
262
+ original_shipment_number: original_shipment_number,
263
+ variant_id: variant_id,
264
+ quantity: quantity,
265
+ stock_location_id: stock_location_id
266
+ }
267
+ }).error(function(msg) {
268
+ alert(msg.responseJSON['message']);
274
269
  }).done(function(msg) {
275
- advanceOrder();
270
+ window.Spree.advanceOrder();
276
271
  });
277
272
  } else {
278
- $.ajax({
279
- type: "PUT",
280
- async: false,
281
- url: Spree.url(Spree.routes.shipments_api + "/" + target_shipment_number + "/add.json"),
282
- data: { variant_id: variant_id, quantity: quantity, token: Spree.api_key }
283
- }).done(function(msg) {
284
- advanceOrder();
285
- });
273
+ // TRANSFER TO AN EXISTING SHIPMENT
274
+ $.ajax({
275
+ type: "POST",
276
+ async: false,
277
+ url: Spree.url(Spree.routes.shipments_api + "/transfer_to_shipment"),
278
+ data: {
279
+ original_shipment_number: original_shipment_number,
280
+ target_shipment_number: target_shipment_number,
281
+ variant_id: variant_id,
282
+ quantity: quantity
283
+ }
284
+ }).error(function(msg) {
285
+ alert(msg.responseJSON['message']);
286
+ }).done(function(msg) {
287
+ window.Spree.advanceOrder();
288
+ });
286
289
  }
287
290
  }
288
291
  }
289
292
 
290
- advanceOrder = function() {
291
- $.ajax({
292
- type: "PUT",
293
- async: false,
294
- url: Spree.url(Spree.routes.checkouts_api + "/" + order_number + "/advance"),
295
- data: { token: Spree.api_key }
296
- }).done(function() {
297
- window.location.reload();
298
- });
299
- }
300
-
301
293
  cancelItemSplit = function(event) {
302
294
  event.preventDefault();
303
295
  var link = $(this);
@@ -325,12 +317,7 @@ addVariantFromStockLocation = function(event) {
325
317
  $.ajax({
326
318
  type: "POST",
327
319
  url: Spree.url(Spree.routes.shipments_api + "?shipment[order_id]=" + order_number),
328
- data: {
329
- variant_id: variant_id,
330
- quantity: quantity,
331
- stock_location_id: stock_location_id,
332
- token: Spree.api_key
333
- }
320
+ data: { variant_id: variant_id, quantity: quantity, stock_location_id: stock_location_id }
334
321
  }).done(function( msg ) {
335
322
  window.location.reload();
336
323
  }).error(function( msg ) {
@@ -9,11 +9,10 @@ jQuery ->
9
9
  variant_product_name_cont: term
10
10
  per_page: 50
11
11
  page: page
12
- token: Spree.api_key
13
12
  results: (data, page) ->
14
13
  more = (page * 50) < data.count
15
14
  return { results: data.stock_items, more: more }
16
15
  formatResult: (stock_item) ->
17
16
  variantTemplate({ variant: stock_item.variant })
18
17
  formatSelection: (stock_item) ->
19
- "#{stock_item.variant.name} (#{stock_item.variant.options_text})"
18
+ "#{stock_item.variant.name} (#{stock_item.variant.options_text})"
@@ -30,7 +30,7 @@ $ ->
30
30
 
31
31
  $('#transfer_receive_stock').change (event) => @receive_stock_change(event)
32
32
 
33
- $.getJSON Spree.url(Spree.routes.stock_locations_api) + '?token=' + Spree.api_key, (data) =>
33
+ $.getJSON Spree.url(Spree.routes.stock_locations_api), (data) =>
34
34
  @locations = (location for location in data.stock_locations)
35
35
  @force_receive_stock() if @locations.length < 2
36
36
 
@@ -107,7 +107,6 @@ $ ->
107
107
  query_object = {}
108
108
  query_object[query] = term
109
109
  q: query_object
110
- token: Spree.api_key
111
110
 
112
111
  results: (data, page) ->
113
112
  result = data["variants"] || data["stock_items"]
@@ -1,14 +1,13 @@
1
- $(document).ready(function () {
2
- 'use strict';
1
+ 'use strict';
3
2
 
3
+ var set_taxon_select = function(){
4
4
  if ($('#product_taxon_ids').length > 0) {
5
5
  $('#product_taxon_ids').select2({
6
6
  placeholder: Spree.translations.taxon_placeholder,
7
7
  multiple: true,
8
8
  initSelection: function (element, callback) {
9
9
  var url = Spree.url(Spree.routes.taxons_search, {
10
- ids: element.val(),
11
- token: Spree.api_key
10
+ ids: element.val()
12
11
  });
13
12
  return $.getJSON(url, null, function (data) {
14
13
  return callback(data['taxons']);
@@ -24,8 +23,7 @@ $(document).ready(function () {
24
23
  without_children: true,
25
24
  q: {
26
25
  name_cont: term
27
- },
28
- token: Spree.api_key
26
+ }
29
27
  };
30
28
  },
31
29
  results: function (data, page) {
@@ -44,4 +42,8 @@ $(document).ready(function () {
44
42
  }
45
43
  });
46
44
  }
45
+ }
46
+
47
+ $(document).ready(function () {
48
+ set_taxon_select()
47
49
  });
@@ -14,12 +14,7 @@ handle_move = (e, data) ->
14
14
  type: "POST",
15
15
  dataType: "json",
16
16
  url: url.toString(),
17
- data: {
18
- _method: "put",
19
- "taxon[parent_id]": new_parent.prop("id"),
20
- "taxon[child_index]": position,
21
- token: Spree.api_key
22
- },
17
+ data: ({_method: "put", "taxon[parent_id]": new_parent.prop("id"), "taxon[child_index]": position }),
23
18
  error: handle_ajax_error
24
19
 
25
20
  true
@@ -35,12 +30,7 @@ handle_create = (e, data) ->
35
30
  type: "POST",
36
31
  dataType: "json",
37
32
  url: base_url.toString(),
38
- data: {
39
- "taxon[name]": name,
40
- "taxon[parent_id]": new_parent.prop("id"),
41
- "taxon[child_index]": position,
42
- token: Spree.api_key
43
- },
33
+ data: ({"taxon[name]": name, "taxon[parent_id]": new_parent.prop("id"), "taxon[child_index]": position }),
44
34
  error: handle_ajax_error,
45
35
  success: (data,result) ->
46
36
  node.prop('id', data.id)
@@ -57,11 +47,7 @@ handle_rename = (e, data) ->
57
47
  type: "POST",
58
48
  dataType: "json",
59
49
  url: url.toString(),
60
- data: {
61
- _method: "put",
62
- "taxon[name]": name,
63
- token: Spree.api_key
64
- },
50
+ data: {_method: "put", "taxon[name]": name },
65
51
  error: handle_ajax_error
66
52
 
67
53
  handle_delete = (e, data) ->
@@ -75,10 +61,7 @@ handle_delete = (e, data) ->
75
61
  type: "POST",
76
62
  dataType: "json",
77
63
  url: delete_url.toString(),
78
- data: {
79
- _method: "delete",
80
- token: Spree.api_key
81
- },
64
+ data: {_method: "delete"},
82
65
  error: handle_ajax_error
83
66
  else
84
67
  $.jstree.rollback(last_rollback)
@@ -92,8 +75,6 @@ root.setup_taxonomy_tree = (taxonomy_id) ->
92
75
 
93
76
  $.ajax
94
77
  url: Spree.url(base_url.path().replace("/taxons", "/jstree")).toString(),
95
- data:
96
- token: Spree.api_key
97
78
  success: (taxonomy) ->
98
79
  last_rollback = null
99
80
 
@@ -102,7 +83,7 @@ root.setup_taxonomy_tree = (taxonomy_id) ->
102
83
  data: taxonomy,
103
84
  ajax:
104
85
  url: (e) ->
105
- Spree.url(base_url.path() + '/' + e.prop('id') + '/jstree' + '?token=' + Spree.api_key).toString()
86
+ Spree.url(base_url.path() + '/' + e.prop('id') + '/jstree').toString()
106
87
  themes:
107
88
  theme: "apple",
108
89
  url: Spree.url(Spree.routes.jstree_theme_path)
@@ -6,7 +6,6 @@ $(document).ready ->
6
6
  url: Spree.routes.classifications_api,
7
7
  method: 'PUT',
8
8
  data:
9
- token: Spree.api_key,
10
9
  product_id: ui.item.data('product-id'),
11
10
  taxon_id: $('#taxon_id').val(),
12
11
  position: ui.item.index()
@@ -21,7 +20,6 @@ $(document).ready ->
21
20
  data: (term, page) ->
22
21
  per_page: 50,
23
22
  page: page,
24
- token: Spree.api_key,
25
23
  q:
26
24
  name_cont: term
27
25
  results: (data, page) ->
@@ -38,8 +36,7 @@ $(document).ready ->
38
36
  $.ajax
39
37
  url: Spree.routes.taxon_products_api,
40
38
  data:
41
- id: e.val,
42
- token: Spree.api_key
39
+ id: e.val
43
40
  success: (data) ->
44
41
  el.empty();
45
42
  if data.products.length == 0
@@ -51,3 +48,4 @@ $(document).ready ->
51
48
  product.image = product.master.images[0].small_url
52
49
  el.append(productTemplate({ product: product }))
53
50
  $('#sorting_explanation').show()
51
+
@@ -16,8 +16,7 @@ $.fn.userAutocomplete = function () {
16
16
  datatype: 'json',
17
17
  data: function (term) {
18
18
  return {
19
- q: term,
20
- token: Spree.api_key
19
+ q: term
21
20
  };
22
21
  },
23
22
  results: function (data) {
@@ -37,4 +36,4 @@ $.fn.userAutocomplete = function () {
37
36
 
38
37
  $(document).ready(function () {
39
38
  $('.user_picker').userAutocomplete();
40
- });
39
+ });
@@ -3,6 +3,7 @@ $(document).ready ->
3
3
  if $("#variant_autocomplete_template").length > 0
4
4
  window.variantTemplate = Handlebars.compile($("#variant_autocomplete_template").text())
5
5
  window.variantStockTemplate = Handlebars.compile($("#variant_autocomplete_stock_template").text())
6
+ window.variantLineItemTemplate = Handlebars.compile($("#variant_line_items_autocomplete_stock_template").text())
6
7
  return
7
8
 
8
9
  formatVariantResult = (variant) ->
@@ -22,7 +23,6 @@ $.fn.variantAutocomplete = ->
22
23
  data: (term, page) ->
23
24
  q:
24
25
  product_name_or_sku_cont: term
25
- token: Spree.api_key
26
26
 
27
27
  results: (data, page) ->
28
28
  window.variants = data["variants"]
@@ -33,4 +33,4 @@ $.fn.variantAutocomplete = ->
33
33
  if !!variant.options_text
34
34
  variant.name + " (#{variant.options_text})"
35
35
  else
36
- variant.name
36
+ variant.name