spree_backend 4.2.0.rc2 → 4.2.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +0 -1
- data/app/assets/javascripts/spree/backend/address_states.js +20 -9
- data/app/assets/javascripts/spree/backend/calculator.js +2 -0
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +99 -71
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +1 -1
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +31 -37
- data/app/assets/javascripts/spree/backend/option_value_picker.js +50 -23
- data/app/assets/javascripts/spree/backend/product_picker.js +35 -19
- data/app/assets/javascripts/spree/backend/promotions.js +32 -27
- data/app/assets/javascripts/spree/backend/shipments.js +28 -37
- data/app/assets/javascripts/spree/backend/spree-select2.js +33 -14
- data/app/assets/javascripts/spree/backend/stock_transfer.js +32 -13
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +30 -43
- data/app/assets/javascripts/spree/backend/taxons.js +60 -47
- data/app/assets/javascripts/spree/backend/user_picker.js +16 -18
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +23 -22
- data/app/assets/stylesheets/spree/backend/components/_badges.scss +1 -1
- data/app/assets/stylesheets/spree/backend/components/_tables.scss +2 -2
- data/app/assets/stylesheets/spree/backend/global/_variables.scss +1 -1
- data/app/assets/stylesheets/spree/backend/plugins/_select2_custom.scss +11 -0
- data/app/assets/stylesheets/spree/backend/plugins/select2_bootstrap4.scss +622 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +2 -1
- data/app/controllers/spree/admin/orders_controller.rb +15 -2
- data/app/controllers/spree/admin/products_controller.rb +2 -2
- data/app/controllers/spree/admin/states_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons_controller.rb +15 -5
- data/app/helpers/spree/admin/base_helper.rb +21 -5
- data/app/helpers/spree/admin/navigation_helper.rb +11 -1
- data/app/helpers/spree/admin/payments_helper.rb +3 -3
- data/app/helpers/spree/admin/stock_movements_helper.rb +2 -0
- data/app/views/spree/admin/countries/index.html.erb +6 -6
- data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +3 -1
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +3 -1
- data/app/views/spree/admin/customer_returns/index.html.erb +2 -2
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- data/app/views/spree/admin/general_settings/edit.html.erb +25 -2
- data/app/views/spree/admin/option_types/index.html.erb +1 -1
- data/app/views/spree/admin/orders/_add_line_item.html.erb +1 -1
- data/app/views/spree/admin/orders/_add_product.html.erb +1 -1
- data/app/views/spree/admin/orders/_channel_form.html.erb +18 -0
- data/app/views/spree/admin/orders/_shipment.html.erb +3 -1
- data/app/views/spree/admin/orders/channel.html.erb +7 -0
- data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +35 -12
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +2 -2
- data/app/views/spree/admin/orders/customer_details/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/index.html.erb +10 -11
- data/app/views/spree/admin/payment_methods/_form.html.erb +65 -46
- data/app/views/spree/admin/payment_methods/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +4 -4
- data/app/views/spree/admin/products/index.html.erb +2 -1
- data/app/views/spree/admin/products/new.html.erb +2 -2
- data/app/views/spree/admin/promotion_rules/create.js.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +1 -1
- data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_option_value.html.erb +8 -7
- data/app/views/spree/admin/promotions/rules/_product.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_taxon.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_user.html.erb +1 -1
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/reimbursements/edit.html.erb +4 -2
- data/app/views/spree/admin/reimbursements/show.html.erb +3 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +7 -5
- data/app/views/spree/admin/return_authorizations/index.html.erb +2 -2
- data/app/views/spree/admin/return_index/customer_returns.html.erb +2 -2
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +2 -2
- data/app/views/spree/admin/shared/_account_nav.html.erb +1 -1
- data/app/views/spree/admin/shared/_address_form.html.erb +7 -7
- data/app/views/spree/admin/shared/_head.html.erb +4 -0
- data/app/views/spree/admin/shared/_order_summary.html.erb +25 -21
- data/app/views/spree/admin/shared/_order_tabs.html.erb +9 -0
- data/app/views/spree/admin/shared/_refunds.html.erb +1 -1
- data/app/views/spree/admin/shared/_translations.html.erb +1 -0
- data/app/views/spree/admin/shared/_update_order_state.js.erb +6 -2
- data/app/views/spree/admin/shared/named_types/_index.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/shipping_methods/index.html.erb +5 -1
- data/app/views/spree/admin/stock_locations/_form.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/index.html.erb +2 -2
- data/app/views/spree/admin/stock_transfers/_stock_movements.html.erb +1 -1
- data/app/views/spree/admin/stock_transfers/index.html.erb +42 -37
- data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
- data/app/views/spree/admin/stores/_form.html.erb +64 -11
- data/app/views/spree/admin/stores/index.html.erb +11 -6
- data/app/views/spree/admin/tax_categories/index.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/index.html.erb +2 -2
- data/app/views/spree/admin/taxons/_form.html.erb +39 -35
- data/app/views/spree/admin/taxons/index.html.erb +1 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +4 -6
- data/app/views/spree/admin/variants/_form.html.erb +2 -2
- data/app/views/spree/admin/zones/index.html.erb +1 -1
- data/config/routes.rb +7 -1
- data/spree_backend.gemspec +1 -1
- metadata +15 -14
- data/app/assets/javascripts/spree/backend/tag_picker.js +0 -52
- data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +0 -190
- data/app/views/spree/admin/general_settings/_form.html.erb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ea801a7a77488cba4283f0bb1d99d237d7a5e9b180c98092837cb39f86ca794
|
4
|
+
data.tar.gz: 0b2fe5d30019037e6712b7c4cbb19def4ea4096d7b81224cc2d762654b50fd1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce23c93f231611913fffa2accf3cb5934a53f400d3f5cb03a72db40541502e44a66b64cf6b79e74a15f27e8496fa8e696b1d65d425c95e90f86515b4deb54e2
|
7
|
+
data.tar.gz: ad48197a9b626b2cfd07d2094e94165b62e01d265054ba12755932efef8cc267071e0c9ef67e04564c14adb61a898ccb6c6ec6be94496ddcb95d02500924df63
|
@@ -50,7 +50,6 @@
|
|
50
50
|
//= require spree/backend/taxons
|
51
51
|
//= require spree/backend/users/edit
|
52
52
|
//= require spree/backend/user_picker
|
53
|
-
//= require spree/backend/tag_picker
|
54
53
|
//= require spree/backend/variant_autocomplete
|
55
54
|
//= require spree/backend/variant_management
|
56
55
|
//= require spree/backend/zone
|
@@ -1,31 +1,42 @@
|
|
1
1
|
// eslint-disable-next-line camelcase, no-unused-vars
|
2
|
-
function update_state
|
2
|
+
function update_state(region, done) {
|
3
3
|
'use strict'
|
4
4
|
|
5
|
-
var
|
6
|
-
var
|
7
|
-
var
|
5
|
+
var countryId = $('#' + region + 'country select').val()
|
6
|
+
var stateContainer = $('#' + region + 'state').parent()
|
7
|
+
var stateSelect = $('#' + region + 'state select')
|
8
|
+
var stateInput = $('#' + region + 'state input.state_name')
|
8
9
|
|
9
|
-
$.get(Spree.routes.states_search + '?country_id=' +
|
10
|
+
$.get(Spree.routes.states_search + '?country_id=' + countryId, function (data) {
|
10
11
|
var states = data.states
|
12
|
+
var statesRequired = data.states_required
|
11
13
|
if (states.length > 0) {
|
12
14
|
stateSelect.html('')
|
13
15
|
var statesWithBlank = [{
|
14
16
|
name: '',
|
15
17
|
id: ''
|
16
18
|
}].concat(states)
|
17
|
-
$.each(statesWithBlank, function (
|
19
|
+
$.each(statesWithBlank, function (_pos, state) {
|
18
20
|
var opt = $(document.createElement('option'))
|
19
21
|
.prop('value', state.id)
|
20
22
|
.html(state.name)
|
21
|
-
stateSelect.append(opt)
|
23
|
+
stateSelect.append(opt).trigger('change')
|
22
24
|
})
|
23
25
|
stateSelect.prop('disabled', false).show()
|
24
26
|
stateSelect.select2()
|
25
27
|
stateInput.hide().prop('disabled', true)
|
28
|
+
stateContainer.show()
|
26
29
|
} else {
|
27
|
-
|
28
|
-
stateSelect.
|
30
|
+
stateSelect.val(null).trigger('change')
|
31
|
+
if (stateSelect.data('select2')) {
|
32
|
+
stateSelect.select2('destroy')
|
33
|
+
}
|
34
|
+
stateSelect.hide()
|
35
|
+
if (statesRequired) {
|
36
|
+
stateInput.prop('disabled', false).show()
|
37
|
+
} else {
|
38
|
+
stateContainer.hide()
|
39
|
+
}
|
29
40
|
}
|
30
41
|
|
31
42
|
if (done) done()
|
@@ -6,10 +6,12 @@ $(function () {
|
|
6
6
|
// eslint-disable-next-line
|
7
7
|
if (calculatorSelect.prop('value') == originalCalcType) {
|
8
8
|
$('div.calculator-settings').show()
|
9
|
+
$('#shipping_method_calculator_attributes_preferred_currency').removeAttr('disabled')
|
9
10
|
$('.calculator-settings-warning').hide()
|
10
11
|
$('.calculator-settings').find('input, textarea').prop('disabled', false)
|
11
12
|
} else {
|
12
13
|
$('div.calculator-settings').hide()
|
14
|
+
$('#shipping_method_calculator_attributes_preferred_currency').attr('disabled', 'disabled')
|
13
15
|
$('.calculator-settings-warning').show()
|
14
16
|
$('.calculator-settings').find('input, textarea').prop('disabled', true)
|
15
17
|
}
|
@@ -1,85 +1,109 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
function clearAddressFields(addressKinds) {
|
2
|
+
if (addressKinds === undefined) {
|
3
|
+
addressKinds = ['ship', 'bill']
|
4
|
+
}
|
5
|
+
addressKinds.forEach(function(addressKind) {
|
6
|
+
ADDRESS_FIELDS.forEach(function(field) {
|
7
|
+
$('#order_' + addressKind + '_address_attributes_' + field).val('')
|
8
|
+
})
|
9
9
|
})
|
10
10
|
}
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
function formatCustomerResult(customer) {
|
13
|
+
var escapedResult = window.customerTemplate({
|
14
|
+
customer: customer,
|
15
|
+
bill_address: customer.bill_address,
|
16
|
+
ship_address: customer.ship_address
|
17
|
+
})
|
18
|
+
return $(escapedResult)
|
19
|
+
}
|
20
|
+
|
21
|
+
function formatCustomerAddress(address, kind) {
|
22
|
+
$('#order_' + kind + '_address_attributes_firstname').val(address.firstname)
|
23
|
+
$('#order_' + kind + '_address_attributes_lastname').val(address.lastname)
|
24
|
+
$('#order_' + kind + '_address_attributes_address1').val(address.address1)
|
25
|
+
$('#order_' + kind + '_address_attributes_company').val(address.company)
|
26
|
+
$('#order_' + kind + '_address_attributes_address2').val(address.address2)
|
27
|
+
$('#order_' + kind + '_address_attributes_city').val(address.city)
|
28
|
+
$('#order_' + kind + '_address_attributes_zipcode').val(address.zipcode)
|
29
|
+
$('#order_' + kind + '_address_attributes_phone').val(address.phone)
|
30
|
+
$('#order_' + kind + '_address_attributes_phone').val(address.phone)
|
31
|
+
$('#order_' + kind + '_address_attributes_country_id').val(address.country_id)
|
32
|
+
$('#order_' + kind + '_address_attributes_country_id').trigger('change')
|
33
|
+
|
34
|
+
var stateSelect = $('#order_' + kind + '_address_attributes_state_id')
|
35
|
+
|
36
|
+
update_state(kind.charAt(0), function() {
|
37
|
+
stateSelect.val(address.state_id).trigger('change')
|
38
|
+
})
|
39
|
+
}
|
40
|
+
|
41
|
+
function formatCustomerSelection(customer) {
|
42
|
+
$('#order_email').val(customer.email)
|
43
|
+
$('#order_user_id').val(customer.id)
|
44
|
+
$('#guest_checkout_true').prop('checked', false)
|
45
|
+
$('#guest_checkout_false').prop('checked', true)
|
46
|
+
$('#guest_checkout_false').prop('disabled', false)
|
47
|
+
|
48
|
+
var billAddress = customer.bill_address
|
49
|
+
var shipAddress = customer.ship_address
|
50
|
+
|
51
|
+
if (billAddress) {
|
52
|
+
formatCustomerAddress(billAddress, 'bill')
|
53
|
+
} else {
|
54
|
+
clearAddressFields(['bill'])
|
15
55
|
}
|
16
56
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ship_address: customer.ship_address
|
22
|
-
})
|
57
|
+
if (shipAddress) {
|
58
|
+
formatCustomerAddress(shipAddress, 'ship')
|
59
|
+
} else {
|
60
|
+
clearAddressFields(['ship'])
|
23
61
|
}
|
24
62
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
return { results: data.users }
|
63
|
+
return customer.email
|
64
|
+
}
|
65
|
+
|
66
|
+
$.fn.customerAutocomplete = function() {
|
67
|
+
this.select2({
|
68
|
+
minimumInputLength: 3,
|
69
|
+
placeholder: Spree.translations.choose_a_customer,
|
70
|
+
ajax: {
|
71
|
+
url: Spree.routes.users_api,
|
72
|
+
datatype: 'json',
|
73
|
+
data: function (params) {
|
74
|
+
return {
|
75
|
+
q: {
|
76
|
+
'm': 'or',
|
77
|
+
email_start: params.term,
|
78
|
+
ship_address_firstname_start: params.term,
|
79
|
+
ship_address_lastname_start: params.term,
|
80
|
+
bill_address_firstname_start: params.term,
|
81
|
+
bill_address_lastname_start: params.term
|
82
|
+
},
|
83
|
+
token: Spree.api_key
|
47
84
|
}
|
48
85
|
},
|
49
|
-
|
50
|
-
|
51
|
-
formatSelection: function (customer) {
|
52
|
-
$('#order_email').val(customer.email)
|
53
|
-
$('#order_user_id').val(customer.id)
|
54
|
-
$('#guest_checkout_true').prop('checked', false)
|
55
|
-
$('#guest_checkout_false').prop('checked', true)
|
56
|
-
$('#guest_checkout_false').prop('disabled', false)
|
57
|
-
|
58
|
-
var billAddress = customer.bill_address
|
59
|
-
if (billAddress) {
|
60
|
-
$('#order_bill_address_attributes_firstname').val(billAddress.firstname)
|
61
|
-
$('#order_bill_address_attributes_lastname').val(billAddress.lastname)
|
62
|
-
$('#order_bill_address_attributes_company').val(billAddress.company)
|
63
|
-
$('#order_bill_address_attributes_address1').val(billAddress.address1)
|
64
|
-
$('#order_bill_address_attributes_address2').val(billAddress.address2)
|
65
|
-
$('#order_bill_address_attributes_city').val(billAddress.city)
|
66
|
-
$('#order_bill_address_attributes_zipcode').val(billAddress.zipcode)
|
67
|
-
$('#order_bill_address_attributes_phone').val(billAddress.phone)
|
68
|
-
|
69
|
-
$('#order_bill_address_attributes_country_id').select2('val', billAddress.country_id).promise().done(function () {
|
70
|
-
update_state('b', function () {
|
71
|
-
$('#order_bill_address_attributes_state_id').select2('val', billAddress.state_id)
|
72
|
-
})
|
73
|
-
})
|
74
|
-
} else {
|
75
|
-
clear_address_fields()
|
76
|
-
}
|
77
|
-
return Select2.util.escapeMarkup(customer.email)
|
86
|
+
processResults: function (data) {
|
87
|
+
return { results: data.users }
|
78
88
|
}
|
79
|
-
}
|
89
|
+
},
|
90
|
+
templateResult: formatCustomerResult
|
91
|
+
}).on('select2:select', function (e) {
|
92
|
+
var data = e.params.data;
|
93
|
+
formatCustomerSelection(data)
|
94
|
+
})
|
95
|
+
}
|
96
|
+
|
97
|
+
document.addEventListener('DOMContentLoaded', function() {
|
98
|
+
$('#customer_search').customerAutocomplete()
|
99
|
+
|
100
|
+
if ($('#customer_autocomplete_template').length > 0) {
|
101
|
+
window.customerTemplate = Handlebars.compile($('#customer_autocomplete_template').text())
|
80
102
|
}
|
81
103
|
|
104
|
+
// Handle Billing Shipping Address
|
82
105
|
var orderUseBillingInput = $('input#order_use_billing')
|
106
|
+
|
83
107
|
var orderUseBilling = function () {
|
84
108
|
if (!orderUseBillingInput.is(':checked')) {
|
85
109
|
$('#shipping').show()
|
@@ -88,13 +112,17 @@ $(document).ready(function () {
|
|
88
112
|
}
|
89
113
|
}
|
90
114
|
|
91
|
-
|
115
|
+
// On page load hide shipping address from
|
92
116
|
orderUseBilling()
|
93
117
|
|
118
|
+
// On click togggle shipping address from
|
119
|
+
orderUseBillingInput.click(orderUseBilling)
|
120
|
+
|
121
|
+
// If guest checkout clear fields
|
94
122
|
$('#guest_checkout_true').change(function () {
|
95
123
|
$('#customer_search').val('')
|
96
124
|
$('#order_user_id').val('')
|
97
125
|
$('#order_email').val('')
|
98
|
-
|
126
|
+
clearAddressFields()
|
99
127
|
})
|
100
128
|
})
|
@@ -19,7 +19,7 @@ $(document).ready(function () {
|
|
19
19
|
|
20
20
|
function addVariant () {
|
21
21
|
$('#stock_details').hide()
|
22
|
-
var variantId = $('
|
22
|
+
var variantId = $('select.variant_autocomplete').val()
|
23
23
|
var quantity = $('input#variant_quantity').val()
|
24
24
|
|
25
25
|
adjustLineItems(order_number, variantId, quantity)
|
@@ -1,43 +1,37 @@
|
|
1
|
-
|
1
|
+
$.fn.optionTypeAutocomplete = function () {
|
2
2
|
'use strict'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
this.select2({
|
5
|
+
minimumInputLength: 2,
|
6
|
+
multiple: true,
|
7
|
+
ajax: {
|
8
|
+
url: Spree.routes.option_types_api,
|
9
|
+
datatype: 'json',
|
10
|
+
data: function (params) {
|
11
|
+
var query = {
|
12
|
+
q: {
|
13
|
+
name_cont: params.term
|
14
|
+
},
|
15
15
|
token: Spree.api_key
|
16
|
-
})
|
17
|
-
return $.getJSON(url, null, function (data) {
|
18
|
-
return callback(data)
|
19
|
-
})
|
20
|
-
},
|
21
|
-
ajax: {
|
22
|
-
url: Spree.routes.option_types_api,
|
23
|
-
quietMillis: 200,
|
24
|
-
datatype: 'json',
|
25
|
-
data: function (term) {
|
26
|
-
return {
|
27
|
-
q: {
|
28
|
-
name_cont: term
|
29
|
-
},
|
30
|
-
token: Spree.api_key
|
31
|
-
}
|
32
|
-
},
|
33
|
-
results: function (data) {
|
34
|
-
return {
|
35
|
-
results: data
|
36
|
-
}
|
37
16
|
}
|
17
|
+
|
18
|
+
return query
|
38
19
|
},
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
20
|
+
processResults: function (data) {
|
21
|
+
return {
|
22
|
+
results: data
|
23
|
+
}
|
24
|
+
}
|
25
|
+
},
|
26
|
+
templateResult: function (optionType) {
|
27
|
+
return optionType.name
|
28
|
+
},
|
29
|
+
templateSelection: function (optionType) {
|
30
|
+
return optionType.text
|
31
|
+
}
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
$(document).ready(function () {
|
36
|
+
$('#product_option_type_ids').optionTypeAutocomplete()
|
43
37
|
})
|
@@ -5,40 +5,67 @@ $.fn.optionValueAutocomplete = function (options) {
|
|
5
5
|
options = options || {}
|
6
6
|
var multiple = typeof (options.multiple) !== 'undefined' ? options.multiple : true
|
7
7
|
var productSelect = options.productSelect
|
8
|
+
var productId = options.productId
|
9
|
+
var values = options.values
|
10
|
+
var clearSelection = options.clearSelection
|
11
|
+
|
12
|
+
function formatOptionValueList(values) {
|
13
|
+
return values.map(function(obj) {
|
14
|
+
return { id: obj.id, text: obj.name }
|
15
|
+
})
|
16
|
+
}
|
17
|
+
|
18
|
+
function addOptions(select, productId, values) {
|
19
|
+
$.ajax({
|
20
|
+
type: 'GET',
|
21
|
+
url: Spree.routes.option_values_api,
|
22
|
+
dataType: 'json',
|
23
|
+
data: {
|
24
|
+
token: Spree.api_key,
|
25
|
+
q: {
|
26
|
+
id_in: values,
|
27
|
+
variants_product_id_eq: productId
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}).then(function (data) {
|
31
|
+
select.addSelect2Options(data)
|
32
|
+
})
|
33
|
+
}
|
8
34
|
|
9
35
|
this.select2({
|
10
|
-
minimumInputLength: 3,
|
11
36
|
multiple: multiple,
|
12
|
-
|
13
|
-
$.get(Spree.routes.option_values_api, {
|
14
|
-
ids: element.val().split(','),
|
15
|
-
token: Spree.api_key
|
16
|
-
}, function (data) {
|
17
|
-
callback(multiple ? data : data[0])
|
18
|
-
})
|
19
|
-
},
|
37
|
+
minimumInputLength: 1,
|
20
38
|
ajax: {
|
21
39
|
url: Spree.routes.option_values_api,
|
22
|
-
|
23
|
-
data: function (
|
24
|
-
var
|
25
|
-
|
40
|
+
dataType: 'json',
|
41
|
+
data: function (params) {
|
42
|
+
var selectedProductId = typeof (productSelect) !== 'undefined' ? productSelect.val() : null
|
43
|
+
|
44
|
+
var query = {
|
26
45
|
q: {
|
27
|
-
name_cont: term,
|
28
|
-
variants_product_id_eq:
|
46
|
+
name_cont: params.term,
|
47
|
+
variants_product_id_eq: selectedProductId
|
29
48
|
},
|
30
49
|
token: Spree.api_key
|
31
50
|
}
|
51
|
+
|
52
|
+
return query;
|
32
53
|
},
|
33
|
-
|
34
|
-
|
54
|
+
processResults: function(data) {
|
55
|
+
var results = formatOptionValueList(data)
|
56
|
+
|
57
|
+
return {
|
58
|
+
results: results
|
59
|
+
}
|
35
60
|
}
|
36
|
-
},
|
37
|
-
formatResult: function (optionValue) {
|
38
|
-
return optionValue.name
|
39
|
-
},
|
40
|
-
formatSelection: function (optionValue) {
|
41
|
-
return optionValue.name
|
42
61
|
}
|
43
62
|
})
|
63
|
+
|
64
|
+
if (values && productId && !clearSelection) {
|
65
|
+
addOptions(this, productId, values)
|
66
|
+
}
|
67
|
+
|
68
|
+
if (clearSelection) {
|
69
|
+
this.val(null).trigger('change')
|
70
|
+
}
|
44
71
|
}
|