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,7 +1,7 @@
1
- jQuery(function($) {
1
+ jQuery(function ($) {
2
2
  // Make select beautiful
3
3
  $('select.select2').select2({
4
4
  allowClear: true,
5
5
  dropdownAutoWidth: true
6
- });
7
- });
6
+ })
7
+ })
@@ -1,13 +1,13 @@
1
1
  $(document).ready(function () {
2
- 'use strict';
2
+ 'use strict'
3
3
 
4
4
  if ($('#new_state_link').length) {
5
5
  $('#country').on('change', function () {
6
- var new_state_link_href = $('#new_state_link').prop('href');
7
- var selected_country_id = $('#country option:selected').prop('value');
8
- var new_link = new_state_link_href.replace(/countries\/(\d+)/,
9
- 'countries/' + selected_country_id);
10
- $('#new_state_link').attr('href', new_link);
11
- });
6
+ var newStateLinkHref = $('#new_state_link').prop('href')
7
+ var selectedCountryId = $('#country option:selected').prop('value')
8
+ var newLink = newStateLinkHref.replace(/countries\/(\d+)/,
9
+ 'countries/' + selectedCountryId)
10
+ $('#new_state_link').attr('href', newLink)
11
+ })
12
12
  };
13
- });
13
+ })
@@ -1,3 +1,4 @@
1
- $(document).ready(function(){
2
- $('[data-hook=stock_location_country] span#country .select2').on('change', function() { update_state(''); });
3
- });
1
+ /* global update_state */
2
+ $(document).ready(function () {
3
+ $('[data-hook=stock_location_country] span#country .select2').on('change', function () { update_state('') })
4
+ })
@@ -0,0 +1,13 @@
1
+ $(function () {
2
+ $('.stock_item_backorderable').on('click', function () {
3
+ $(this).parent('form').submit()
4
+ })
5
+ $('.toggle_stock_item_backorderable').on('submit', function () {
6
+ $.ajax({
7
+ type: this.method,
8
+ url: this.action,
9
+ data: $(this).serialize()
10
+ })
11
+ return false
12
+ })
13
+ })
@@ -0,0 +1,35 @@
1
+ /* global variantTemplate */
2
+ $(function () {
3
+ var el = $('#stock_movement_stock_item_id')
4
+ el.select2({
5
+ placeholder: 'Find a stock item', // translate
6
+ ajax: {
7
+ url: Spree.url(Spree.routes.stock_items_api(el.data('stock-location-id'))),
8
+ data: function (term, page) {
9
+ return {
10
+ q: {
11
+ variant_product_name_cont: term
12
+ },
13
+ per_page: 50,
14
+ page: page,
15
+ token: Spree.api_key
16
+ }
17
+ },
18
+ results: function (data, page) {
19
+ var more = (page * 50) < data.count
20
+ return {
21
+ results: data.stock_items,
22
+ more: more
23
+ }
24
+ }
25
+ },
26
+ formatResult: function (stockItem) {
27
+ return variantTemplate({
28
+ variant: stockItem.variant
29
+ })
30
+ },
31
+ formatSelection: function (stockItem) {
32
+ return Select2.util.escapeMarkup(stockItem.variant.name + '(' + stockItem.variant.options_text + ')')
33
+ }
34
+ })
35
+ })
@@ -0,0 +1,260 @@
1
+ $(function () {
2
+ function TransferVariant (variant1) {
3
+ this.variant = variant1
4
+ this.id = this.variant.id
5
+ this.name = this.variant.name + ' - ' + this.variant.sku
6
+ this.quantity = 0
7
+ }
8
+ TransferVariant.prototype.add = function (quantity) {
9
+ this.quantity += quantity
10
+ return this.quantity
11
+ }
12
+
13
+ function TransferLocations () {
14
+ this.source = $('#transfer_source_location_id')
15
+ this.destination = $('#transfer_destination_location_id')
16
+ this.source.change(this.populate_destination.bind(this))
17
+ $('#transfer_receive_stock').change(this.receive_stock_change.bind(this))
18
+ $.getJSON(Spree.url(Spree.routes.stock_locations_api) + '?token=' + Spree.api_key + '&per_page=1000', function (data) {
19
+ this.locations = (function () {
20
+ var ref = data.stock_locations
21
+ var results = []
22
+ var i, len
23
+ for (i = 0, len = ref.length; i < len; i++) {
24
+ results.push(ref[i])
25
+ }
26
+ return results
27
+ })()
28
+ if (this.locations.length < 2) {
29
+ this.force_receive_stock()
30
+ }
31
+ this.populate_source()
32
+ this.populate_destination()
33
+ }.bind(this))
34
+ }
35
+
36
+ TransferLocations.prototype.force_receive_stock = function () {
37
+ $('#receive_stock_field').hide()
38
+ $('#transfer_receive_stock').prop('checked', true)
39
+ this.toggle_source_location(true)
40
+ }
41
+
42
+ TransferLocations.prototype.is_source_location_hidden = function () {
43
+ return $('#transfer_source_location_id_field').css('visibility') === 'hidden'
44
+ }
45
+
46
+ TransferLocations.prototype.toggle_source_location = function (hide) {
47
+ if (hide == null) {
48
+ hide = false
49
+ }
50
+ this.source.trigger('change')
51
+ var transferSourceLocationIdField = $('#transfer_source_location_id_field')
52
+ if (this.is_source_location_hidden() && !hide) {
53
+ transferSourceLocationIdField.css('visibility', 'visible')
54
+ transferSourceLocationIdField.show()
55
+ } else {
56
+ transferSourceLocationIdField.css('visibility', 'hidden')
57
+ transferSourceLocationIdField.hide()
58
+ }
59
+ }
60
+
61
+ TransferLocations.prototype.receive_stock_change = function (event) {
62
+ this.toggle_source_location(event.target.checked)
63
+ this.populate_destination(!event.target.checked)
64
+ }
65
+
66
+ TransferLocations.prototype.populate_source = function () {
67
+ this.populate_select(this.source)
68
+ this.source.trigger('change')
69
+ }
70
+
71
+ TransferLocations.prototype.populate_destination = function () {
72
+ if (this.is_source_location_hidden()) {
73
+ return this.populate_select(this.destination)
74
+ } else {
75
+ return this.populate_select(this.destination, parseInt(this.source.val()))
76
+ }
77
+ }
78
+
79
+ TransferLocations.prototype.populate_select = function (select, except) {
80
+ var i, len, location, ref
81
+ if (except == null) {
82
+ except = 0
83
+ }
84
+ select.children('option').remove()
85
+ ref = this.locations
86
+ for (i = 0, len = ref.length; i < len; i++) {
87
+ location = ref[i]
88
+ if (location.id !== except) {
89
+ select.append($('<option></option>').text(location.name).attr('value', location.id))
90
+ }
91
+ }
92
+ return select.select2()
93
+ }
94
+
95
+ function TransferVariants () {
96
+ $('#transfer_source_location_id').change(this.refresh_variants.bind(this))
97
+ }
98
+
99
+ TransferVariants.prototype.receiving_stock = function () {
100
+ return $('#transfer_receive_stock:checked').length > 0
101
+ }
102
+
103
+ TransferVariants.prototype.refresh_variants = function () {
104
+ if (this.receiving_stock()) {
105
+ return this._search_transfer_variants()
106
+ } else {
107
+ return this._search_transfer_stock_items()
108
+ }
109
+ }
110
+
111
+ TransferVariants.prototype._search_transfer_variants = function () {
112
+ return this.build_select(Spree.url(Spree.routes.variants_api), 'product_name_or_sku_cont')
113
+ }
114
+
115
+ TransferVariants.prototype._search_transfer_stock_items = function () {
116
+ var stockLocationId = $('#transfer_source_location_id').val()
117
+ return this.build_select(Spree.url(Spree.routes.stock_locations_api + ('/' + stockLocationId + '/stock_items')), 'variant_product_name_or_variant_sku_cont')
118
+ }
119
+
120
+ TransferVariants.prototype.format_variant_result = function (result) {
121
+ // eslint-disable-next-line no-extra-boolean-cast
122
+ if (!!result.options_text) {
123
+ return result.name + ' - ' + result.sku + ' (' + result.options_text + ')'
124
+ } else {
125
+ return result.name + ' - ' + result.sku
126
+ }
127
+ }
128
+
129
+ TransferVariants.prototype.build_select = function (url, query) {
130
+ return $('#transfer_variant').select2({
131
+ minimumInputLength: 3,
132
+ ajax: {
133
+ url: url,
134
+ datatype: 'json',
135
+ data: function (term) {
136
+ var q = {}
137
+ q[query] = term
138
+ return {
139
+ q: q,
140
+ token: Spree.api_key
141
+ }
142
+ },
143
+ results: function (data) {
144
+ var result = data['variants'] || data['stock_items']
145
+ if (data['stock_items'] != null) {
146
+ result = _(result).map(function (variant) {
147
+ return variant.variant
148
+ })
149
+ }
150
+ window.variants = result
151
+ return {
152
+ results: result
153
+ }
154
+ }
155
+ },
156
+ formatResult: this.format_variant_result,
157
+ formatSelection: function (variant) {
158
+ // eslint-disable-next-line no-extra-boolean-cast
159
+ if (!!variant.options_text) {
160
+ return variant.name + (' (' + variant.options_text + ')') + (' - ' + variant.sku)
161
+ } else {
162
+ return variant.name + (' - ' + variant.sku)
163
+ }
164
+ }
165
+ })
166
+ }
167
+
168
+ function TransferAddVariants () {
169
+ this.variants = []
170
+ this.template = Handlebars.compile($('#transfer_variant_template').html())
171
+ $('#transfer_source_location_id').change(this.clear_variants.bind(this))
172
+ $('button.transfer_add_variant').click(function (event) {
173
+ event.preventDefault()
174
+ if ($('#transfer_variant').select2('data') != null) {
175
+ this.add_variant()
176
+ } else {
177
+ alert('Please select a variant first')
178
+ }
179
+ }.bind(this))
180
+ $('#transfer-variants-table').on('click', '.transfer_remove_variant', function (event) {
181
+ event.preventDefault()
182
+ this.remove_variant($(event.target))
183
+ }.bind(this))
184
+ $('button.transfer_transfer').click(function () {
185
+ if (!(this.variants.length > 0)) {
186
+ alert('no variants to transfer')
187
+ return false
188
+ }
189
+ }.bind(this))
190
+ }
191
+
192
+ TransferAddVariants.prototype.add_variant = function () {
193
+ var variant = $('#transfer_variant').select2('data')
194
+ var quantity = parseInt($('#transfer_variant_quantity').val())
195
+ variant = this.find_or_add(variant)
196
+ variant.add(quantity)
197
+ return this.render()
198
+ }
199
+
200
+ TransferAddVariants.prototype.find_or_add = function (variant) {
201
+ var existing = _.find(this.variants, function (v) {
202
+ return v.id === variant.id
203
+ })
204
+ if (existing) {
205
+ return existing
206
+ } else {
207
+ variant = new TransferVariant($.extend({}, variant))
208
+ this.variants.push(variant)
209
+ return variant
210
+ }
211
+ }
212
+
213
+ TransferAddVariants.prototype.remove_variant = function (target) {
214
+ var v
215
+ var variantId = parseInt(target.data('variantId'))
216
+ this.variants = (function () {
217
+ var ref = this.variants
218
+ var results = []
219
+ var i, len
220
+ for (i = 0, len = ref.length; i < len; i++) {
221
+ v = ref[i]
222
+ if (v.id !== variantId) {
223
+ results.push(v)
224
+ }
225
+ }
226
+ return results
227
+ }.call(this))
228
+ return this.render()
229
+ }
230
+
231
+ TransferAddVariants.prototype.clear_variants = function () {
232
+ this.variants = []
233
+ return this.render()
234
+ }
235
+
236
+ TransferAddVariants.prototype.contains = function (id) {
237
+ return _.contains(_.pluck(this.variants, 'id'), id)
238
+ }
239
+
240
+ TransferAddVariants.prototype.render = function () {
241
+ if (this.variants.length === 0) {
242
+ $('#transfer-variants-table').hide()
243
+ return $('.no-objects-found').show()
244
+ } else {
245
+ $('#transfer-variants-table').show()
246
+ $('.no-objects-found').hide()
247
+ return $('#transfer_variants_tbody').html(this.template({
248
+ variants: this.variants
249
+ }))
250
+ }
251
+ }
252
+
253
+ if ($('#transfer_source_location_id').length > 0) {
254
+ /* eslint-disable no-new */
255
+ new TransferLocations()
256
+ new TransferVariants()
257
+ new TransferAddVariants()
258
+ /* eslint-enable no-new */
259
+ }
260
+ })
@@ -1,8 +1,8 @@
1
1
  $.fn.tagAutocomplete = function () {
2
- 'use strict';
2
+ 'use strict'
3
3
 
4
- function formatTag(tag) {
5
- return Select2.util.escapeMarkup(tag.name);
4
+ function formatTag (tag) {
5
+ return Select2.util.escapeMarkup(tag.name)
6
6
  }
7
7
 
8
8
  this.select2({
@@ -12,10 +12,10 @@ $.fn.tagAutocomplete = function () {
12
12
  multiple: true,
13
13
  tags: true,
14
14
  initSelection: function (element, callback) {
15
- var data = $(element.val().split(',')).map(function() {
16
- return { name: this, id: this };
17
- });
18
- callback(data);
15
+ var data = $(element.val().split(',')).map(function () {
16
+ return { name: this, id: this }
17
+ })
18
+ callback(data)
19
19
  },
20
20
  ajax: {
21
21
  url: Spree.routes.tags_api,
@@ -25,28 +25,28 @@ $.fn.tagAutocomplete = function () {
25
25
  return {
26
26
  q: term,
27
27
  token: Spree.api_key
28
- };
28
+ }
29
29
  },
30
30
  results: function (data) {
31
31
  return {
32
- results: data.tags.map(function(tag) {
33
- return { name: tag.name, id: tag.name };
32
+ results: data.tags.map(function (tag) {
33
+ return { name: tag.name, id: tag.name }
34
34
  })
35
- };
35
+ }
36
36
  }
37
37
  },
38
- createSearchChoice: function(term, data) {
39
- if ($(data).filter(function() {
40
- return this.name.localeCompare(term)===0;
41
- }).length===0) {
42
- return { id: term, name: term };
38
+ createSearchChoice: function (term, data) {
39
+ if ($(data).filter(function () {
40
+ return this.name.localeCompare(term) === 0
41
+ }).length === 0) {
42
+ return { id: term, name: term }
43
43
  }
44
44
  },
45
- formatResult: formatTag,
45
+ formatResult: formatTag,
46
46
  formatSelection: formatTag
47
- });
48
- };
47
+ })
48
+ }
49
49
 
50
50
  $(document).ready(function () {
51
- $('.tag_picker').tagAutocomplete();
52
- });
51
+ $('.tag_picker').tagAutocomplete()
52
+ })
@@ -1,8 +1,8 @@
1
- 'use strict';
2
-
3
- var set_taxon_select = function(selector){
4
- function formatTaxon(taxon) {
5
- return Select2.util.escapeMarkup(taxon.pretty_name);
1
+ 'use strict'
2
+ // eslint-disable-next-line camelcase
3
+ function set_taxon_select (selector) {
4
+ function formatTaxon (taxon) {
5
+ return Select2.util.escapeMarkup(taxon.pretty_name)
6
6
  }
7
7
 
8
8
  if ($(selector).length > 0) {
@@ -14,10 +14,10 @@ var set_taxon_select = function(selector){
14
14
  ids: element.val(),
15
15
  without_children: true,
16
16
  token: Spree.api_key
17
- });
17
+ })
18
18
  return $.getJSON(url, null, function (data) {
19
- return callback(data['taxons']);
20
- });
19
+ return callback(data['taxons'])
20
+ })
21
21
  },
22
22
  ajax: {
23
23
  url: Spree.routes.taxons_api,
@@ -31,22 +31,22 @@ var set_taxon_select = function(selector){
31
31
  name_cont: term
32
32
  },
33
33
  token: Spree.api_key
34
- };
34
+ }
35
35
  },
36
36
  results: function (data, page) {
37
- var more = page < data.pages;
37
+ var more = page < data.pages
38
38
  return {
39
39
  results: data['taxons'],
40
40
  more: more
41
- };
41
+ }
42
42
  }
43
43
  },
44
44
  formatResult: formatTaxon,
45
45
  formatSelection: formatTaxon
46
- });
46
+ })
47
47
  }
48
48
  }
49
49
 
50
50
  $(document).ready(function () {
51
51
  set_taxon_select('#product_taxon_ids')
52
- });
52
+ })