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,12 +1,11 @@
1
- $(document).ready(function() {
1
+ $(document).ready(function () {
2
2
  if ($('#permalink_part_display').length) {
3
- var field = $('#permalink_part'),
4
- target = $('#permalink_part_display'),
5
- permalink_part_default = target.text().trim();
6
-
7
- target.text(permalink_part_default + field.val());
3
+ var field = $('#permalink_part')
4
+ var target = $('#permalink_part_display')
5
+ var permalinkPartDefault = target.text().trim()
6
+ target.text(permalinkPartDefault + field.val())
8
7
  field.on('keyup blur', function () {
9
- target.text(permalink_part_default + $(this).val());
10
- });
8
+ target.text(permalinkPartDefault + $(this).val())
9
+ })
11
10
  };
12
- });
11
+ })
@@ -0,0 +1,35 @@
1
+ var root = typeof exports !== 'undefined' && exports !== null ? exports : this
2
+
3
+ root.taxon_tree_menu = function (obj, context) {
4
+ var adminBaseUrl = Spree.url(Spree.routes.admin_taxonomy_taxons_path)
5
+ var editUrl = adminBaseUrl.clone()
6
+ editUrl.setPath(editUrl.path() + '/' + obj.attr('id') + '/edit')
7
+ return {
8
+ create: {
9
+ label: '<span class="icon icon-plus"></span> ' + Spree.translations.add,
10
+ action: function (obj) {
11
+ return context.create(obj)
12
+ }
13
+ },
14
+ rename: {
15
+ label: '<span class="icon icon-pencil"></span> ' + Spree.translations.rename,
16
+ action: function (obj) {
17
+ return context.rename(obj)
18
+ }
19
+ },
20
+ remove: {
21
+ label: '<span class="icon icon-trash"></span> ' + Spree.translations.remove,
22
+ action: function (obj) {
23
+ return context.remove(obj)
24
+ }
25
+ },
26
+ edit: {
27
+ separator_before: true,
28
+ label: '<span class="icon icon-cog"></span> ' + Spree.translations.edit,
29
+ action: function () {
30
+ window.location = editUrl.toString()
31
+ return window.location
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,165 @@
1
+ function handle_ajax_error(last_rollback) {
2
+ $.jstree.rollback(last_rollback);
3
+ show_flash('error', '<strong>' + Spree.translations.server_error + '</strong><br />' + Spree.translations.taxonomy_tree_error);
4
+ }
5
+
6
+ function handle_move(e, data) {
7
+ var last_rollback = data.rlbk;
8
+ var position = data.rslt.cp;
9
+ var node = data.rslt.o;
10
+ var new_parent = data.rslt.np;
11
+ var url = Spree.url(base_url).clone();
12
+ url.setPath(url.path() + '/' + node.prop('id'));
13
+ $.ajax({
14
+ type: 'POST',
15
+ dataType: 'json',
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
+ },
23
+ }).fail(function () {
24
+ handle_ajax_error(last_rollback);
25
+ });
26
+ return true;
27
+ }
28
+
29
+ function handle_create(e, data) {
30
+ var last_rollback = data.rlbk;
31
+ var node = data.rslt.obj;
32
+ var name = data.rslt.name;
33
+ var position = data.rslt.position;
34
+ var new_parent = data.rslt.parent;
35
+ return $.ajax({
36
+ type: 'POST',
37
+ dataType: 'json',
38
+ url: base_url.toString(),
39
+ data: {
40
+ 'taxon[name]': name,
41
+ 'taxon[parent_id]': new_parent.prop('id'),
42
+ 'taxon[child_index]': position,
43
+ token: Spree.api_key
44
+ }
45
+ }).done(function (data) {
46
+ node.prop('id', data.id);
47
+ }).fail(function () {
48
+ return handle_ajax_error(last_rollback);
49
+ });
50
+ }
51
+
52
+ function handle_rename(e, data) {
53
+ var last_rollback = data.rlbk;
54
+ var node = data.rslt.obj;
55
+ var name = data.rslt.new_name;
56
+ var url = Spree.url(base_url).clone();
57
+ url.setPath(url.path() + '/' + node.prop('id'));
58
+ return $.ajax({
59
+ type: 'POST',
60
+ dataType: 'json',
61
+ url: url.toString(),
62
+ data: {
63
+ _method: 'put',
64
+ 'taxon[name]': name,
65
+ token: Spree.api_key
66
+ }
67
+ }).fail(function () {
68
+ handle_ajax_error(last_rollback);
69
+ });
70
+ }
71
+
72
+ function handle_delete(e, data) {
73
+ var last_rollback = data.rlbk;
74
+ var node = data.rslt.obj;
75
+ var delete_url = base_url.clone();
76
+ delete_url.setPath(delete_url.path() + '/' + node.prop('id'));
77
+ if (confirm(Spree.translations.are_you_sure_delete)) {
78
+ $.ajax({
79
+ type: 'POST',
80
+ dataType: 'json',
81
+ url: delete_url.toString(),
82
+ data: {
83
+ _method: 'delete',
84
+ token: Spree.api_key
85
+ }
86
+ }).fail(function () {
87
+ handle_ajax_error(last_rollback);
88
+ });
89
+ } else {
90
+ $.jstree.rollback(last_rollback);
91
+ last_rollback = null;
92
+ }
93
+ }
94
+
95
+ var root = typeof exports !== 'undefined' && exports !== null ? exports : this;
96
+
97
+ root.setup_taxonomy_tree = function (taxonomy_id) {
98
+ var $taxonomy_tree = $('#taxonomy_tree');
99
+ if (taxonomy_id !== void 0) {
100
+ // this is defined within admin/taxonomies/edit
101
+ root.base_url = Spree.url(Spree.routes.taxonomy_taxons_path);
102
+ $.ajax({
103
+ url: Spree.url(base_url.path().replace('/taxons', '/jstree')).toString(),
104
+ data: {
105
+ token: Spree.api_key
106
+ }
107
+ }).done(function (taxonomy) {
108
+ var last_rollback = null;
109
+ var conf = {
110
+ json_data: {
111
+ data: taxonomy,
112
+ ajax: {
113
+ url: function (e) {
114
+ return Spree.url(base_url.path() + '/' + e.prop('id') + '/jstree' + '?token=' + Spree.api_key).toString();
115
+ }
116
+ }
117
+ },
118
+ themes: {
119
+ theme: 'spree',
120
+ url: Spree.url(Spree.routes.jstree_theme_path)
121
+ },
122
+ strings: {
123
+ new_node: Spree.translations.new_taxon,
124
+ loading: Spree.translations.loading + '...'
125
+ },
126
+ crrm: {
127
+ move: {
128
+ check_move: function (m) {
129
+ var new_parent, node, position;
130
+ position = m.cp;
131
+ node = m.o;
132
+ new_parent = m.np;
133
+ if (!new_parent || node.prop('rel') === 'root') {
134
+ return false;
135
+ }
136
+ // can't drop before root
137
+ if (new_parent.prop('id') === 'taxonomy_tree' && position === 0) {
138
+ return false;
139
+ }
140
+ return true;
141
+ }
142
+ }
143
+ },
144
+ contextmenu: {
145
+ items: function (obj) {
146
+ return taxon_tree_menu(obj, this);
147
+ }
148
+ },
149
+ plugins: ['themes', 'json_data', 'dnd', 'crrm', 'contextmenu']
150
+ };
151
+ return $taxonomy_tree.jstree(conf).bind('move_node.jstree', handle_move).bind('remove.jstree', handle_delete).bind('create.jstree', handle_create).bind('rename.jstree', handle_rename).bind('loaded.jstree', function () {
152
+ return $(this).jstree('core').toggle_node($('.jstree-icon').first());
153
+ });
154
+ });
155
+ $taxonomy_tree.on('dblclick', 'a', function () {
156
+ $taxonomy_tree.jstree('rename', this);
157
+ });
158
+ // surpress form submit on enter/return
159
+ $(document).keypress(function (event) {
160
+ if (event.keyCode === 13) {
161
+ event.preventDefault();
162
+ }
163
+ });
164
+ }
165
+ };
@@ -0,0 +1,122 @@
1
+ /* global productTemplate */
2
+ $(function () {
3
+ window.productTemplate = Handlebars.compile($('#product_template').text())
4
+ var taxonProducts = $('#taxon_products')
5
+ var taxonId = $('#taxon_id')
6
+
7
+ taxonProducts.sortable({
8
+ handle: '.js-sort-handle'
9
+ })
10
+
11
+ taxonProducts.on('sortstop', function (event, ui) {
12
+ return $.ajax({
13
+ url: Spree.routes.classifications_api,
14
+ method: 'PUT',
15
+ dataType: 'json',
16
+ data: {
17
+ token: Spree.api_key,
18
+ product_id: ui.item.data('product-id'),
19
+ taxon_id: $('#taxon_id').val(),
20
+ position: ui.item.index()
21
+ }
22
+ })
23
+ })
24
+
25
+ if (taxonId.length > 0) {
26
+ taxonId.select2({
27
+ dropdownCssClass: 'taxon_select_box',
28
+ placeholder: Spree.translations.find_a_taxon,
29
+ ajax: {
30
+ url: Spree.routes.taxons_api,
31
+ datatype: 'json',
32
+ data: function (term, page) {
33
+ return {
34
+ per_page: 50,
35
+ page: page,
36
+ without_children: true,
37
+ token: Spree.api_key,
38
+ q: {
39
+ name_cont: term
40
+ }
41
+ }
42
+ },
43
+ results: function (data, page) {
44
+ var more = page < data.pages
45
+ return {
46
+ results: data['taxons'],
47
+ more: more
48
+ }
49
+ }
50
+ },
51
+ formatResult: formatTaxon,
52
+ formatSelection: formatTaxon
53
+ })
54
+ }
55
+
56
+ taxonId.on('change', function (e) {
57
+ var el = $('#taxon_products')
58
+ $.ajax({
59
+ url: Spree.routes.taxon_products_api,
60
+ data: {
61
+ id: e.val,
62
+ token: Spree.api_key
63
+ }
64
+ }).done(function (data) {
65
+ var i, j, len, len1, product, ref, ref1, results, variant
66
+ el.empty()
67
+ if (data.products.length === 0) {
68
+ return $('#taxon_products').html('<div class="alert alert-info">' + Spree.translations.no_results + '</div>')
69
+ } else {
70
+ ref = data.products
71
+ results = []
72
+ for (i = 0, len = ref.length; i < len; i++) {
73
+ product = ref[i]
74
+ if (product.master.images[0] !== void 0 && product.master.images[0].small_url !== void 0) {
75
+ product.image = product.master.images[0].small_url
76
+ } else {
77
+ ref1 = product.variants
78
+ for (j = 0, len1 = ref1.length; j < len1; j++) {
79
+ variant = ref1[j]
80
+ if (variant.images[0] !== void 0 && variant.images[0].small_url !== void 0) {
81
+ product.image = variant.images[0].small_url
82
+ break
83
+ }
84
+ }
85
+ }
86
+ results.push(el.append(productTemplate({
87
+ product: product
88
+ })))
89
+ }
90
+ return results
91
+ }
92
+ })
93
+ })
94
+ taxonProducts.on('click', '.js-delete-product', function (e) {
95
+ var currentTaxonId = $('#taxon_id').val()
96
+ var product = $(this).parents('.product')
97
+ var productId = product.data('product-id')
98
+ var productTaxons = String(product.data('taxons')).split(',').map(Number)
99
+ var productIndex = productTaxons.indexOf(parseFloat(currentTaxonId))
100
+ productTaxons.splice(productIndex, 1)
101
+ var taxonIds = productTaxons.length > 0 ? productTaxons : ['']
102
+ $.ajax({
103
+ url: Spree.routes.products_api + '/' + productId,
104
+ data: {
105
+ product: {
106
+ taxon_ids: taxonIds
107
+ },
108
+ token: Spree.api_key
109
+ },
110
+ type: 'PUT'
111
+ }).done(function () {
112
+ product.fadeOut(400, function (e) {
113
+ product.remove()
114
+ })
115
+ })
116
+ })
117
+ $('.variant_autocomplete').variantAutocomplete()
118
+
119
+ function formatTaxon (taxon) {
120
+ return Select2.util.escapeMarkup(taxon.pretty_name)
121
+ }
122
+ })
@@ -1,8 +1,8 @@
1
1
  $.fn.userAutocomplete = function () {
2
- 'use strict';
2
+ 'use strict'
3
3
 
4
- function formatUser(user) {
5
- return Select2.util.escapeMarkup(user.email);
4
+ function formatUser (user) {
5
+ return Select2.util.escapeMarkup(user.email)
6
6
  }
7
7
 
8
8
  this.select2({
@@ -13,8 +13,8 @@ $.fn.userAutocomplete = function () {
13
13
  ids: element.val(),
14
14
  token: Spree.api_key
15
15
  }, function (data) {
16
- callback(data.users);
17
- });
16
+ callback(data.users)
17
+ })
18
18
  },
19
19
  ajax: {
20
20
  url: Spree.routes.users_api,
@@ -25,19 +25,19 @@ $.fn.userAutocomplete = function () {
25
25
  email_cont: term
26
26
  },
27
27
  token: Spree.api_key
28
- };
28
+ }
29
29
  },
30
30
  results: function (data) {
31
31
  return {
32
32
  results: data.users
33
- };
33
+ }
34
34
  }
35
35
  },
36
36
  formatResult: formatUser,
37
37
  formatSelection: formatUser
38
- });
39
- };
38
+ })
39
+ }
40
40
 
41
41
  $(document).ready(function () {
42
- $('.user_picker').userAutocomplete();
43
- });
42
+ $('.user_picker').userAutocomplete()
43
+ })
@@ -1,18 +1,17 @@
1
- $( document ).ready(function() {
2
- var use_billing = $('#user_use_billing');
1
+ $(document).ready(function () {
2
+ var useBilling = $('#user_use_billing')
3
3
 
4
- if(use_billing.is(':checked')) {
5
- $('#shipping').hide();
4
+ if (useBilling.is(':checked')) {
5
+ $('#shipping').hide()
6
6
  }
7
7
 
8
- use_billing.change(function() {
9
- if(this.checked){
10
- $('#shipping').hide();
11
- return $('#shipping input, #shipping select').prop('disabled', true);
12
- }
13
- else {
14
- $('#shipping').show();
15
- $('#shipping input, #shipping select').prop('disabled', false);
16
- }
17
- });
18
- });
8
+ useBilling.change(function () {
9
+ if (this.checked) {
10
+ $('#shipping').hide()
11
+ return $('#shipping input, #shipping select').prop('disabled', true)
12
+ } else {
13
+ $('#shipping').show()
14
+ $('#shipping input, #shipping select').prop('disabled', false)
15
+ }
16
+ })
17
+ })
@@ -0,0 +1,61 @@
1
+ /* global variantTemplate */
2
+ // variant autocompletion
3
+ $(function () {
4
+ var variantAutocompleteTemplate = $('#variant_autocomplete_template')
5
+ if (variantAutocompleteTemplate.length > 0) {
6
+ window.variantTemplate = Handlebars.compile(variantAutocompleteTemplate.text())
7
+ window.variantStockTemplate = Handlebars.compile($('#variant_autocomplete_stock_template').text())
8
+ window.variantLineItemTemplate = Handlebars.compile($('#variant_line_items_autocomplete_stock_template').text())
9
+ }
10
+ })
11
+
12
+ function formatVariantResult (variant) {
13
+ if (variant['images'][0] !== undefined && variant['images'][0].mini_url !== undefined) {
14
+ variant.image = variant.images[0].mini_url
15
+ }
16
+ return variantTemplate({
17
+ variant: variant
18
+ })
19
+ }
20
+
21
+ $.fn.variantAutocomplete = function () {
22
+ return this.select2({
23
+ placeholder: Spree.translations.variant_placeholder,
24
+ minimumInputLength: 3,
25
+ initSelection: function (element, callback) {
26
+ return $.get(Spree.routes.variants_api + '/' + element.val(), {
27
+ token: Spree.api_key
28
+ }).done(function (data) {
29
+ return callback(data)
30
+ })
31
+ },
32
+ ajax: {
33
+ url: Spree.url(Spree.routes.variants_api),
34
+ quietMillis: 200,
35
+ datatype: 'json',
36
+ data: function (term) {
37
+ return {
38
+ q: {
39
+ product_name_or_sku_cont: term
40
+ },
41
+ token: Spree.api_key
42
+ }
43
+ },
44
+ results: function (data) {
45
+ window.variants = data['variants']
46
+ return {
47
+ results: data['variants']
48
+ }
49
+ }
50
+ },
51
+ formatResult: formatVariantResult,
52
+ formatSelection: function (variant) {
53
+ // eslint-disable-next-line no-extra-boolean-cast
54
+ if (!!variant.options_text) {
55
+ return Select2.util.escapeMarkup(variant.name + '(' + variant.options_text + ')')
56
+ } else {
57
+ return Select2.util.escapeMarkup(variant.name)
58
+ }
59
+ }
60
+ })
61
+ }