spree_backend 3.7.14.1 → 4.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/app/assets/javascripts/spree/backend.js +2 -1
  4. data/app/assets/javascripts/spree/backend/admin.js +75 -66
  5. data/app/assets/javascripts/spree/backend/calculator.js +3 -3
  6. data/app/assets/javascripts/spree/backend/gateway.js +1 -1
  7. data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +23 -24
  8. data/app/assets/javascripts/spree/backend/promotions.js +4 -4
  9. data/app/assets/javascripts/spree/backend/shipments.js +32 -33
  10. data/app/assets/javascripts/spree/backend/taxonomy.js +75 -72
  11. data/app/assets/stylesheets/spree/backend/components/_badges.scss +46 -0
  12. data/app/assets/stylesheets/spree/backend/components/_buttons.scss +7 -23
  13. data/app/assets/stylesheets/spree/backend/components/_filters.scss +16 -6
  14. data/app/assets/stylesheets/spree/backend/components/_main.scss +4 -6
  15. data/app/assets/stylesheets/spree/backend/components/_navbar.scss +21 -0
  16. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +2 -10
  17. data/app/assets/stylesheets/spree/backend/components/_page_header.scss +0 -23
  18. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +25 -69
  19. data/app/assets/stylesheets/spree/backend/components/_tables.scss +53 -12
  20. data/app/assets/stylesheets/spree/backend/components/_taxon_products_view.scss +2 -2
  21. data/app/assets/stylesheets/spree/backend/global/_variables.scss +10 -13
  22. data/app/assets/stylesheets/spree/backend/plugins/_jquery_ui.scss +33 -20
  23. data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +23 -18
  24. data/app/assets/stylesheets/spree/backend/shared/_base.scss +0 -8
  25. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +5 -38
  26. data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +3 -6
  27. data/app/controllers/spree/admin/customer_returns_controller.rb +2 -2
  28. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  29. data/app/controllers/spree/admin/orders_controller.rb +2 -2
  30. data/app/controllers/spree/admin/payment_methods_controller.rb +1 -1
  31. data/app/controllers/spree/admin/products_controller.rb +2 -2
  32. data/app/controllers/spree/admin/reimbursement_types_controller.rb +1 -1
  33. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  34. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  35. data/app/controllers/spree/admin/stores_controller.rb +5 -0
  36. data/app/controllers/spree/admin/taxons_controller.rb +1 -1
  37. data/app/controllers/spree/admin/users_controller.rb +2 -2
  38. data/app/helpers/spree/admin/base_helper.rb +9 -4
  39. data/app/helpers/spree/admin/customer_returns_helper.rb +1 -1
  40. data/app/helpers/spree/admin/navigation_helper.rb +41 -25
  41. data/app/helpers/spree/admin/orders_helper.rb +2 -2
  42. data/app/views/kaminari/{_first_page.html.erb → twitter-bootstrap-4/_first_page.html.erb} +5 -3
  43. data/app/views/kaminari/{_gap.html.erb → twitter-bootstrap-4/_gap.html.erb} +5 -1
  44. data/app/views/kaminari/{_last_page.html.erb → twitter-bootstrap-4/_last_page.html.erb} +5 -3
  45. data/app/views/kaminari/{_next_page.html.erb → twitter-bootstrap-4/_next_page.html.erb} +5 -7
  46. data/app/views/kaminari/{_page.html.erb → twitter-bootstrap-4/_page.html.erb} +8 -2
  47. data/app/views/kaminari/{_paginator.html.erb → twitter-bootstrap-4/_paginator.html.erb} +3 -1
  48. data/app/views/kaminari/{_prev_page.html.erb → twitter-bootstrap-4/_prev_page.html.erb} +5 -7
  49. data/app/views/spree/admin/adjustments/_adjustment.html.erb +14 -4
  50. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +6 -6
  51. data/app/views/spree/admin/adjustments/index.html.erb +7 -5
  52. data/app/views/spree/admin/countries/_form.html.erb +13 -1
  53. data/app/views/spree/admin/customer_returns/index.html.erb +2 -2
  54. data/app/views/spree/admin/general_settings/edit.html.erb +14 -14
  55. data/app/views/spree/admin/images/_form.html.erb +2 -2
  56. data/app/views/spree/admin/images/edit.html.erb +6 -6
  57. data/app/views/spree/admin/option_types/_form.html.erb +2 -2
  58. data/app/views/spree/admin/option_types/edit.html.erb +5 -5
  59. data/app/views/spree/admin/orders/_add_line_item.html.erb +5 -5
  60. data/app/views/spree/admin/orders/_add_product.html.erb +5 -5
  61. data/app/views/spree/admin/orders/_adjustments.html.erb +4 -3
  62. data/app/views/spree/admin/orders/_line_items.html.erb +4 -4
  63. data/app/views/spree/admin/orders/_risk_analysis.html.erb +3 -3
  64. data/app/views/spree/admin/orders/_shipment.html.erb +5 -5
  65. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +1 -1
  66. data/app/views/spree/admin/orders/customer_details/_form.html.erb +17 -17
  67. data/app/views/spree/admin/orders/customer_details/edit.html.erb +4 -4
  68. data/app/views/spree/admin/orders/index.html.erb +56 -33
  69. data/app/views/spree/admin/payment_methods/_form.html.erb +4 -4
  70. data/app/views/spree/admin/payments/_list.html.erb +3 -3
  71. data/app/views/spree/admin/payments/index.html.erb +1 -1
  72. data/app/views/spree/admin/product_properties/index.html.erb +10 -2
  73. data/app/views/spree/admin/products/_add_stock_form.html.erb +6 -6
  74. data/app/views/spree/admin/products/_form.html.erb +26 -31
  75. data/app/views/spree/admin/products/edit.html.erb +1 -1
  76. data/app/views/spree/admin/products/index.html.erb +5 -5
  77. data/app/views/spree/admin/products/new.html.erb +5 -5
  78. data/app/views/spree/admin/products/stock.html.erb +3 -3
  79. data/app/views/spree/admin/promotions/_actions.html.erb +4 -4
  80. data/app/views/spree/admin/promotions/_form.html.erb +7 -7
  81. data/app/views/spree/admin/promotions/_promotion_action.html.erb +4 -4
  82. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +12 -5
  83. data/app/views/spree/admin/promotions/_rules.html.erb +5 -5
  84. data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +5 -5
  85. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +5 -5
  86. data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +3 -3
  87. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +10 -6
  88. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +10 -6
  89. data/app/views/spree/admin/promotions/edit.html.erb +5 -5
  90. data/app/views/spree/admin/promotions/index.html.erb +3 -3
  91. data/app/views/spree/admin/promotions/rules/_country.html.erb +2 -2
  92. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +4 -4
  93. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +8 -8
  94. data/app/views/spree/admin/promotions/rules/_product.html.erb +2 -2
  95. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +2 -2
  96. data/app/views/spree/admin/promotions/rules/_user.html.erb +2 -2
  97. data/app/views/spree/admin/properties/_form.html.erb +2 -2
  98. data/app/views/spree/admin/properties/index.html.erb +3 -3
  99. data/app/views/spree/admin/prototypes/_prototypes.html.erb +10 -2
  100. data/app/views/spree/admin/reimbursement_types/_form.html.erb +6 -6
  101. data/app/views/spree/admin/reports/sales_total.html.erb +4 -2
  102. data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
  103. data/app/views/spree/admin/return_index/customer_returns.html.erb +3 -3
  104. data/app/views/spree/admin/return_index/return_authorizations.html.erb +15 -9
  105. data/app/views/spree/admin/shared/_account_nav.html.erb +60 -48
  106. data/app/views/spree/admin/shared/_address_form.html.erb +11 -4
  107. data/app/views/spree/admin/shared/_calculator_fields.html.erb +4 -4
  108. data/app/views/spree/admin/shared/_content_header.html.erb +4 -4
  109. data/app/views/spree/admin/shared/_header.html.erb +18 -21
  110. data/app/views/spree/admin/shared/_index_table_options.html.erb +4 -5
  111. data/app/views/spree/admin/shared/_main_menu.html.erb +37 -35
  112. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -7
  113. data/app/views/spree/admin/shared/_order_tabs.html.erb +47 -20
  114. data/app/views/spree/admin/shared/_product_tabs.html.erb +35 -11
  115. data/app/views/spree/admin/shared/_refunds.html.erb +1 -1
  116. data/app/views/spree/admin/shared/_table_filter.html.erb +7 -5
  117. data/app/views/spree/admin/shared/_version.html.erb +4 -2
  118. data/app/views/spree/admin/shared/named_types/_form.html.erb +1 -1
  119. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +1 -1
  120. data/app/views/spree/admin/shared/sub_menu/_product.html.erb +1 -1
  121. data/app/views/spree/admin/shared/sub_menu/_promotion.html.erb +1 -1
  122. data/app/views/spree/admin/shared/sub_menu/_returns.html.erb +1 -1
  123. data/app/views/spree/admin/shipping_methods/_form.html.erb +21 -21
  124. data/app/views/spree/admin/states/_form.html.erb +2 -2
  125. data/app/views/spree/admin/stock_locations/_form.html.erb +6 -6
  126. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +4 -4
  127. data/app/views/spree/admin/stock_movements/index.html.erb +1 -1
  128. data/app/views/spree/admin/stock_transfers/index.html.erb +34 -32
  129. data/app/views/spree/admin/stock_transfers/new.html.erb +13 -11
  130. data/app/views/spree/admin/stores/_form.html.erb +5 -6
  131. data/app/views/spree/admin/stores/index.html.erb +3 -1
  132. data/app/views/spree/admin/tax_categories/_form.html.erb +1 -1
  133. data/app/views/spree/admin/tax_rates/_form.html.erb +11 -9
  134. data/app/views/spree/admin/taxons/_form.html.erb +4 -4
  135. data/app/views/spree/admin/users/_addresses_form.html.erb +10 -10
  136. data/app/views/spree/admin/users/_form.html.erb +2 -2
  137. data/app/views/spree/admin/users/_lifetime_stats.html.erb +3 -3
  138. data/app/views/spree/admin/users/_sidebar.html.erb +26 -11
  139. data/app/views/spree/admin/users/addresses.html.erb +4 -2
  140. data/app/views/spree/admin/users/edit.html.erb +8 -8
  141. data/app/views/spree/admin/users/index.html.erb +3 -3
  142. data/app/views/spree/admin/users/items.html.erb +2 -2
  143. data/app/views/spree/admin/users/orders.html.erb +2 -2
  144. data/app/views/spree/admin/variants/_autocomplete.js.erb +5 -5
  145. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +1 -1
  146. data/app/views/spree/admin/variants/_form.html.erb +2 -2
  147. data/app/views/spree/admin/variants/_split.js.erb +3 -3
  148. data/app/views/spree/admin/variants/index.html.erb +2 -2
  149. data/app/views/spree/admin/variants/new.html.erb +8 -6
  150. data/app/views/spree/admin/zones/_country_members.html.erb +4 -4
  151. data/app/views/spree/admin/zones/_form.html.erb +9 -9
  152. data/app/views/spree/admin/zones/_state_members.html.erb +4 -4
  153. data/app/views/spree/admin/zones/index.html.erb +2 -2
  154. data/app/views/spree/layouts/admin.html.erb +9 -6
  155. data/lib/spree/backend.rb +3 -2
  156. data/lib/spree_backend.rb +2 -1
  157. data/spree_backend.gemspec +3 -2
  158. metadata +39 -27
  159. data/app/assets/stylesheets/spree/backend/components/_labels.scss +0 -55
  160. data/app/assets/stylesheets/spree/backend/components/_panels.scss +0 -3
  161. data/app/assets/stylesheets/spree/backend/components/_wells.scss +0 -3
  162. data/app/assets/stylesheets/spree/backend/sections/_account.scss +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea006e0dbe2f7266b92e30120848eb844215e4b453e8db297cf619be0fbfef23
4
- data.tar.gz: 4dbee1ec28c0934f14f8083c67bb9a5f5748711586119a5f8f7129d936999a58
3
+ metadata.gz: 1c6bb4782e47150187105202e4dd34777fbb307d3331e193b3b8c4cd58904208
4
+ data.tar.gz: 95a899a53419588fc599d0b171e83d1d1b447101253571021051a22bf14c838d
5
5
  SHA512:
6
- metadata.gz: 01423ce743bb6339fcfecf333d59b92c7797ca2fa3418b7e4c7970c44d3aa25bbd63ca8c186161175e63876a18132a71c8ecdb5830821051daecacc049c5963c
7
- data.tar.gz: 15d6a4e40e1cb293daa420b64e6221448a11a13092a0811035052cca6f629d4be9c489f4a58e754f581accffd6ddcff95d6e2c67887e58494233da2784ccaf27
6
+ metadata.gz: 447eeb4c95197a72921edbfe4c96ce7c8f6316a9cf4e2ecac621ba75fe1599a5704193a8ffdbba616857935bbd9721161cda4c6f244fec48a7ae76d7502ab87b
7
+ data.tar.gz: '059c56e08cb4605d838c23845d198252f71c38311b5173f30355f66c7d9806513715613e7498dca9b3bfb39c3e482b5cefcc419ecd01d99c9e552acf06bded5d'
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))
1
+ eval_gemfile('../common_spree_dependencies.rb')
2
2
 
3
3
  gem 'spree_core', path: '../core'
4
4
  gem 'spree_api', path: '../api'
@@ -1,7 +1,8 @@
1
1
  //= require modernizr
2
+ //= require jquery3
3
+ //= require popper
2
4
  //= require bootstrap-sprockets
3
5
  //= require handlebars
4
- //= require jquery
5
6
  //= require js.cookie
6
7
  //= require jquery.jstree/jquery.jstree
7
8
  //= require jquery_ujs
@@ -25,25 +25,38 @@ jQuery(function ($) {
25
25
  })
26
26
 
27
27
  // Sidebar nav toggle functionality
28
- $('#sidebar-toggle').on('click', function () {
29
- var wrapper = $('#wrapper')
30
- var main = $('#main-part')
31
- var sidebar = $('#main-sidebar')
28
+ const sidebar_toggle = $('#sidebar-toggle')
32
29
 
33
- // these should match `spree/backend/app/helpers/spree/admin/navigation_helper.rb#main_part_classes`
34
- var mainWrapperCollapsedClasses = 'col-xs-12 sidebar-collapsed'
35
- var mainWrapperExpandedClasses = 'col-xs-9 col-xs-offset-3 col-md-10 col-md-offset-2'
30
+ sidebar_toggle.on('click', function() {
31
+ const wrapper = $('#wrapper')
32
+ const main = $('#main-part')
33
+ const sidebar = $('#main-sidebar')
34
+ const version = $('.spree-version')
35
+ const collapsed = sidebar.find('[aria-expanded="true"]')
36
+ const collapsedIcons = sidebar.find('.icon-chevron-down')
36
37
 
37
38
  wrapper.toggleClass('sidebar-minimized')
38
- sidebar.toggleClass('hidden-xs')
39
+
40
+ collapsed
41
+ .attr('aria-expanded', 'false')
42
+ .next()
43
+ .removeClass('show')
44
+
45
+ collapsedIcons
46
+ .removeClass('icon-chevron-down')
47
+ .addClass('icon-chevron-left')
48
+
49
+ // these should match `spree/backend/app/helpers/spree/admin/navigation_helper.rb#main_part_classes`
39
50
  main
40
- .toggleClass(mainWrapperCollapsedClasses)
41
- .toggleClass(mainWrapperExpandedClasses)
51
+ .toggleClass('col-12 sidebar-collapsed')
52
+ .toggleClass('col-9 offset-3 col-md-10 offset-md-2')
42
53
 
43
54
  if (wrapper.hasClass('sidebar-minimized')) {
44
55
  Cookies.set('sidebar-minimized', 'true', { path: '/admin' })
56
+ version.removeClass('d-md-block')
45
57
  } else {
46
58
  Cookies.set('sidebar-minimized', 'false', { path: '/admin' })
59
+ version.addClass('d-md-block')
47
60
  }
48
61
  })
49
62
 
@@ -72,16 +85,16 @@ jQuery(function ($) {
72
85
  })
73
86
 
74
87
  // Main menu active item submenu show
75
- var activeItem = $('#main-sidebar').find('.selected')
76
- activeItem.closest('.nav-pills').addClass('in')
77
- activeItem.closest('.nav-sidebar')
88
+ var active_item = $('#main-sidebar').find('.selected')
89
+ active_item.closest('.nav-pills').addClass('in show')
90
+ active_item.closest('.nav-sidebar')
78
91
  .find('.icon-chevron-left')
79
92
  .removeClass('icon-chevron-left')
80
93
  .addClass('icon-chevron-down')
81
94
 
82
95
  // Replace ▼ and ▲ in sort_link with nicer icons
83
96
  $('.sort_link').each(function () {
84
- // Remove the   in the text
97
+ // Remove the &nbsp in the text
85
98
  var sortLinkText = $(this).text().replace('\xA0', '')
86
99
 
87
100
  if (sortLinkText.indexOf('▼') >= 0) {
@@ -136,8 +149,8 @@ jQuery(function ($) {
136
149
 
137
150
  label = ransackField(label.text()) + ': ' + ransackValue
138
151
 
139
- filter = '<span class="js-filter label label-default" data-ransack-field="' + ransackFieldId + '">' + label + '<span class="icon icon-delete js-delete-filter"></span></span>'
140
- $('.js-filters').append(filter).show()
152
+ filter = '<span class="js-filter badge badge-secondary" data-ransack-field="' + ransackFieldId + '">' + label + '<span class="icon icon-delete js-delete-filter"></span></span>'
153
+ $(".js-filters").append(filter).show()
141
154
  }
142
155
  })
143
156
 
@@ -205,7 +218,8 @@ function handle_date_picker_fields () {
205
218
  monthNames: Spree.translations.month_names,
206
219
  prevText: Spree.translations.previous,
207
220
  nextText: Spree.translations.next,
208
- showOn: 'focus'
221
+ showOn: 'focus',
222
+ showAnim: ''
209
223
  })
210
224
 
211
225
  // Correctly display range dates
@@ -217,18 +231,18 @@ function handle_date_picker_fields () {
217
231
  })
218
232
  }
219
233
 
220
- $(document).ready(function () {
234
+ $(document).ready(function(){
221
235
  handle_date_picker_fields()
222
- $('.observe_field').on('change', function () {
223
- var target = $(this).data('update')
236
+ $('.observe_field').on('change', function() {
237
+ target = $(this).data('update')
224
238
  $(target).hide()
225
- $.ajax({ dataType: 'html',
239
+ $.ajax({
240
+ dataType: 'html',
226
241
  url: $(this).data('base-url') + encodeURIComponent($(this).val()),
227
- type: 'get',
228
- success: function (data) {
229
- $(target).html(data)
230
- $(target).show()
231
- }
242
+ type: 'GET'
243
+ }).done(function (data) {
244
+ $(target).html(data)
245
+ $(target).show()
232
246
  })
233
247
  })
234
248
 
@@ -263,25 +277,23 @@ $(document).ready(function () {
263
277
  _method: 'delete',
264
278
  authenticity_token: AUTH_TOKEN
265
279
  },
266
- dataType: 'script',
267
- success: function (response) {
268
- var $flashElement = $('.alert-success')
269
- if ($flashElement.length) {
270
- el.parents('tr').fadeOut('hide', function () {
271
- $(this).remove()
272
- })
273
- }
274
- },
275
- error: function (response, textStatus, errorThrown) {
276
- show_flash('error', response.responseText)
280
+ dataType: 'script'
281
+ }).done(function () {
282
+ var $flash_element = $('.alert-success')
283
+ if ($flash_element.length) {
284
+ el.parents('tr').fadeOut('hide', function () {
285
+ $(this).remove()
286
+ })
277
287
  }
288
+ }).fail(function (response) {
289
+ show_flash('error', response.responseText)
278
290
  })
279
291
  }
280
292
  return false
281
293
  })
282
294
 
283
295
  $('body').on('click', 'a.spree_remove_fields', function () {
284
- var el = $(this)
296
+ el = $(this)
285
297
  el.prev('input[type=hidden]').val('1')
286
298
  el.closest('.fields').hide()
287
299
  if (el.prop('href').substr(-1) === '#') {
@@ -293,31 +305,28 @@ $(document).ready(function () {
293
305
  data: {
294
306
  _method: 'delete',
295
307
  authenticity_token: AUTH_TOKEN
296
- },
297
- success: function (response) {
298
- el.parents('tr').fadeOut('hide', function () {
299
- $(this).remove()
300
- })
301
- },
302
- error: function (response, textStatus, errorThrown) {
303
- show_flash('error', response.responseText)
304
308
  }
305
-
309
+ }).done(function () {
310
+ el.parents('tr').fadeOut('hide', function () {
311
+ $(this).remove()
312
+ })
313
+ }).fail(function (response) {
314
+ show_flash('error', response.responseText)
306
315
  })
307
316
  }
308
317
  return false
309
318
  })
310
319
 
311
- $('body').on('click', '.select_properties_from_prototype', function () {
320
+ $('body').on('click', '.select_properties_from_prototype', function(){
312
321
  $('#busy_indicator').show()
313
- var clickedLink = $(this)
314
- $.ajax({ dataType: 'script',
315
- url: clickedLink.prop('href'),
316
- type: 'get',
317
- success: function (data) {
318
- clickedLink.parent('td').parent('tr').hide()
319
- $('#busy_indicator').hide()
320
- }
322
+ var clicked_link = $(this)
323
+ $.ajax({
324
+ dataType: 'script',
325
+ url: clicked_link.prop('href'),
326
+ type: 'GET'
327
+ }).done(function () {
328
+ clicked_link.parent('td').parent('tr').hide()
329
+ $('#busy_indicator').hide()
321
330
  })
322
331
  return false
323
332
  })
@@ -337,13 +346,13 @@ $(document).ready(function () {
337
346
  handle: '.handle',
338
347
  helper: fixHelper,
339
348
  placeholder: 'ui-sortable-placeholder',
340
- update: function (event, ui) {
349
+ update: function(event, ui) {
341
350
  var tbody = this
342
351
  $('#progress').show()
343
- var positions = {}
344
- $.each($('tr', tbody), function (position, obj) {
345
- var reg = /spree_(\w+_?)+_(\d+)/
346
- var parts = reg.exec($(obj).prop('id'))
352
+ positions = {}
353
+ $.each($('tr', tbody), function(position, obj) {
354
+ reg = /spree_(\w+_?)+_(\d+)/
355
+ parts = reg.exec($(obj).prop('id'))
347
356
  if (parts) {
348
357
  positions['positions[' + parts[2] + ']'] = position + 1
349
358
  }
@@ -352,8 +361,9 @@ $(document).ready(function () {
352
361
  type: 'POST',
353
362
  dataType: 'script',
354
363
  url: $(ui.item).closest('table.sortable').data('sortable-link'),
355
- data: positions,
356
- success: function (data) { $('#progress').hide() }
364
+ data: positions
365
+ }).done(function () {
366
+ $('#progress').hide()
357
367
  })
358
368
  },
359
369
  start: function (event, ui) {
@@ -375,16 +385,15 @@ $(document).ready(function () {
375
385
  $(this).parent().fadeOut()
376
386
  })
377
387
 
378
- window.Spree.advanceOrder = function () {
388
+ window.Spree.advanceOrder = function() {
379
389
  $.ajax({
380
390
  type: 'PUT',
381
391
  async: false,
382
392
  data: {
383
393
  token: Spree.api_key
384
394
  },
385
- // eslint-disable-next-line camelcase
386
395
  url: Spree.url(Spree.routes.checkouts_api + '/' + order_number + '/advance')
387
- }).done(function () {
396
+ }).done(function() {
388
397
  window.location.reload()
389
398
  })
390
399
  }
@@ -3,15 +3,15 @@ $(function () {
3
3
  var originalCalcType = calculatorSelect.prop('value')
4
4
  $('.calculator-settings-warning').hide()
5
5
  calculatorSelect.change(function () {
6
- // eslint-disable-next-line eqeqeq
6
+ // eslint-disable-next-line
7
7
  if (calculatorSelect.prop('value') == originalCalcType) {
8
8
  $('div.calculator-settings').show()
9
9
  $('.calculator-settings-warning').hide()
10
- $('.calculator-settings').find('input,textarea').prop('disabled', false)
10
+ $('.calculator-settings').find('input, textarea').prop('disabled', false)
11
11
  } else {
12
12
  $('div.calculator-settings').hide()
13
13
  $('.calculator-settings-warning').show()
14
- $('.calculator-settings').find('input,texttarea').prop('disabled', true)
14
+ $('.calculator-settings').find('input, textarea').prop('disabled', true)
15
15
  }
16
16
  })
17
17
  })
@@ -2,7 +2,7 @@ $(function () {
2
2
  var originalGtwyType = $('#gtwy-type').prop('value')
3
3
  $('div#gateway-settings-warning').hide()
4
4
  $('#gtwy-type').change(function () {
5
- // eslint-disable-next-line eqeqeq
5
+ // eslint-disable-next-line
6
6
  if ($('#gtwy-type').prop('value') == originalGtwyType) {
7
7
  $('div.gateway-settings').show()
8
8
  $('div#gateway-settings-warning').hide()
@@ -20,34 +20,33 @@ $(document).ready(function () {
20
20
  function addVariant () {
21
21
  $('#stock_details').hide()
22
22
  var variantId = $('input.variant_autocomplete').val()
23
- var quantity = $("input.quantity[data-variant-id='" + variantId + "']").val()
23
+ var quantity = $('input#variant_quantity').val()
24
24
 
25
25
  adjustLineItems(order_number, variantId, quantity)
26
26
  return 1
27
27
  }
28
28
 
29
- function adjustLineItems (orderNumber, variantId, quantity) {
30
- var url = Spree.routes.orders_api + '/' + orderNumber + '/line_items'
29
+ adjustLineItems = function(order_number, variant_id, quantity){
30
+ var url = Spree.routes.orders_api + '/' + order_number + '/line_items'
31
31
 
32
- $.ajax({
33
- type: 'POST',
34
- url: Spree.url(url),
35
- data: {
36
- line_item: {
37
- variant_id: variantId,
38
- quantity: quantity
39
- },
40
- token: Spree.api_key
41
- }
42
- }).done(function (msg) {
43
- window.Spree.advanceOrder()
44
- window.location.reload()
45
- }).fail(function (msg) {
46
- // eslint-disable-next-line eqeqeq
47
- if (typeof msg.responseJSON.message != 'undefined') {
48
- alert(msg.responseJSON.message)
49
- } else {
50
- alert(msg.responseJSON.exception)
51
- }
52
- })
32
+ $.ajax({
33
+ type: 'POST',
34
+ url: Spree.url(url),
35
+ data: {
36
+ line_item: {
37
+ variant_id: variant_id,
38
+ quantity: quantity
39
+ },
40
+ token: Spree.api_key
41
+ }
42
+ }).done(function () {
43
+ window.Spree.advanceOrder()
44
+ window.location.reload()
45
+ }).fail(function (msg) {
46
+ if (typeof msg.responseJSON.message != 'undefined') {
47
+ alert(msg.responseJSON.message)
48
+ } else {
49
+ alert(msg.responseJSON.exception)
50
+ }
51
+ })
53
52
  }
@@ -140,12 +140,12 @@ function initProductActions () {
140
140
 
141
141
  setupRemoveLineItems()
142
142
  // Add line item to list
143
- $('.promotion_action.create_line_items button.add').unbind('click').click(function () {
143
+ $('.promotion_action.create_line_items button.add').off('click').click(function () {
144
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()
145
+ var product_name = $container.find('input[name="add_product_name"]').val()
146
+ var variant_id = $container.find('input[name="add_variant_id"]').val()
147
147
  var quantity = $container.find('input[name="add_quantity"]').val()
148
- if (variantId) {
148
+ if (variant_id) {
149
149
  // Add to the table
150
150
  var newRow = '<tr><td>' + productName + '</td><td>' + quantity + '</td><td><img src="/assets/admin/icons/cross.png"/></td></tr>'
151
151
  $container.find('table').append(newRow)
@@ -5,12 +5,12 @@ $(document).ready(function () {
5
5
 
6
6
  // handle variant selection, show stock level.
7
7
  $('#add_variant_id').change(function () {
8
- var variantId = $(this).val()
8
+ var variantId = parseInt($(this).val())
9
9
 
10
10
  var variant = _.find(window.variants, function (variant) {
11
- // eslint-disable-next-line eqeqeq
12
- return variant.id == variantId
11
+ return variant.id === variantId
13
12
  })
13
+
14
14
  $('#stock_details').html(variantStockTemplate({ variant: variant }))
15
15
  $('#stock_details').show()
16
16
 
@@ -80,7 +80,7 @@ $(document).ready(function () {
80
80
  }
81
81
  }).done(function () {
82
82
  window.location.reload()
83
- }).error(function (msg) {
83
+ }).fail(function (msg) {
84
84
  alert(msg.responseJSON.message || msg.responseJSON.exception)
85
85
  })
86
86
  })
@@ -111,12 +111,12 @@ $(document).ready(function () {
111
111
  }
112
112
  }).done(function () {
113
113
  window.location.reload()
114
- }).error(function (msg) {
114
+ }).fail(function (msg) {
115
115
  alert(msg.responseJSON.message || msg.responseJSON.exception)
116
116
  })
117
117
  })
118
118
 
119
- function toggleTrackingEdit (event) {
119
+ function toggleTrackingEdit(event) {
120
120
  event.preventDefault()
121
121
 
122
122
  var link = $(this)
@@ -128,7 +128,7 @@ $(document).ready(function () {
128
128
  $('a.edit-tracking').click(toggleTrackingEdit)
129
129
  $('a.cancel-tracking').click(toggleTrackingEdit)
130
130
 
131
- function createTrackingValueContent (data) {
131
+ function createTrackingValueContent(data) {
132
132
  var selectedShippingMethod = data.shipping_methods.filter(function (method) {
133
133
  return method.id === data.selected_shipping_rate.shipping_method_id
134
134
  })[0]
@@ -174,7 +174,7 @@ $(document).ready(function () {
174
174
  })
175
175
  })
176
176
 
177
- function adjustShipmentItems (shipmentNumber, variantId, quantity) {
177
+ function adjustShipmentItems(shipmentNumber, variantId, quantity) {
178
178
  var shipment = _.findWhere(shipments, { number: shipmentNumber + '' })
179
179
  var inventoryUnits = _.where(shipment.inventory_units, { variant_id: variantId })
180
180
  var url = Spree.routes.shipments_api + '/' + shipmentNumber
@@ -209,7 +209,7 @@ function adjustShipmentItems (shipmentNumber, variantId, quantity) {
209
209
  }
210
210
  }
211
211
 
212
- function toggleMethodEdit () {
212
+ function toggleMethodEdit() {
213
213
  var link = $(this)
214
214
  link.parents('tbody').find('tr.edit-method').toggle()
215
215
  link.parents('tbody').find('tr.show-method').toggle()
@@ -217,7 +217,7 @@ function toggleMethodEdit () {
217
217
  return false
218
218
  }
219
219
 
220
- function toggleItemEdit () {
220
+ function toggleItemEdit() {
221
221
  var link = $(this)
222
222
  var linkParent = link.parent()
223
223
  linkParent.find('a.edit-item').toggle()
@@ -231,7 +231,7 @@ function toggleItemEdit () {
231
231
  return false
232
232
  }
233
233
 
234
- function startItemSplit (event) {
234
+ function startItemSplit(event) {
235
235
  event.preventDefault()
236
236
  $('.cancel-split').each(function () {
237
237
  $(this).click()
@@ -253,9 +253,9 @@ function startItemSplit (event) {
253
253
  },
254
254
  token: Spree.api_key
255
255
  }
256
- }).success(function (data) {
256
+ }).done(function (data) {
257
257
  variant = data['variants'][0]
258
- }).error(function (msg) {
258
+ }).fail(function (msg) {
259
259
  alert(msg.responseJSON.message || msg.responseJSON.exception)
260
260
  })
261
261
 
@@ -268,7 +268,7 @@ function startItemSplit (event) {
268
268
  $('#item_stock_location').select2({ width: 'resolve', placeholder: Spree.translations.item_stock_placeholder })
269
269
  }
270
270
 
271
- function completeItemSplit (event) {
271
+ function completeItemSplit(event) {
272
272
  event.preventDefault()
273
273
 
274
274
  if ($('#item_stock_location').val() === '') {
@@ -287,24 +287,13 @@ function completeItemSplit (event) {
287
287
  var selectedShipment = stockItemRow.find($('#item_stock_location').select2('data').element)
288
288
  var targetShipmentNumber = selectedShipment.data('shipment-number')
289
289
  var newShipment = selectedShipment.data('new-shipment')
290
- // eslint-disable-next-line
291
- if (stockLocationId !== 'new_shipment') {
292
- var splitItems = function (opts) {
290
+ // eslint-disable-next-line eqeqeq
291
+ if (stockLocationId != 'new_shipment') {
292
+ if (newShipment !== undefined) {
293
+ // TRANSFER TO A NEW LOCATION
293
294
  $.ajax({
294
295
  type: 'POST',
295
296
  async: false,
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
297
  url: Spree.url(Spree.routes.shipments_api + '/transfer_to_location'),
309
298
  data: {
310
299
  original_shipment_number: originalShipmentNumber,
@@ -313,10 +302,16 @@ function completeItemSplit (event) {
313
302
  stock_location_id: stockLocationId,
314
303
  token: Spree.api_key
315
304
  }
305
+ }).fail(function (msg) {
306
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
307
+ }).done(function (msg) {
308
+ window.location.reload()
316
309
  })
317
310
  } else {
318
311
  // TRANSFER TO AN EXISTING SHIPMENT
319
- splitItems({
312
+ $.ajax({
313
+ type: 'POST',
314
+ async: false,
320
315
  url: Spree.url(Spree.routes.shipments_api + '/transfer_to_shipment'),
321
316
  data: {
322
317
  original_shipment_number: originalShipmentNumber,
@@ -325,12 +320,16 @@ function completeItemSplit (event) {
325
320
  quantity: quantity,
326
321
  token: Spree.api_key
327
322
  }
323
+ }).fail(function (msg) {
324
+ alert(msg.responseJSON.message || msg.responseJSON.exception)
325
+ }).done(function (msg) {
326
+ window.location.reload()
328
327
  })
329
328
  }
330
329
  }
331
330
  }
332
331
 
333
- function cancelItemSplit (event) {
332
+ function cancelItemSplit(event) {
334
333
  event.preventDefault()
335
334
  var link = $(this)
336
335
  var prevRow = link.closest('tr').prev()
@@ -340,7 +339,7 @@ function cancelItemSplit (event) {
340
339
  prevRow.find('a.delete-item').toggle()
341
340
  }
342
341
 
343
- function addVariantFromStockLocation (event) {
342
+ function addVariantFromStockLocation(event) {
344
343
  event.preventDefault()
345
344
 
346
345
  $('#stock_details').hide()
@@ -366,7 +365,7 @@ function addVariantFromStockLocation (event) {
366
365
  }
367
366
  }).done(function (msg) {
368
367
  window.location.reload()
369
- }).error(function (msg) {
368
+ }).fail(function (msg) {
370
369
  alert(msg.responseJSON.message || msg.responseJSON.exception)
371
370
  })
372
371
  } else {