solidus_backend 3.2.9 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend/orders/edit.js +3 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +25 -6
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +32 -4
- data/app/assets/javascripts/spree/backend/views/cart/line_item_row.js +3 -1
- data/app/controllers/spree/admin/payment_methods_controller.rb +6 -0
- data/app/controllers/spree/admin/resource_controller.rb +1 -3
- data/app/controllers/spree/admin/variants_controller.rb +1 -0
- data/app/views/spree/admin/products/_form.html.erb +1 -8
- data/app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/_form.html.erb +14 -0
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/variants/_form.html.erb +16 -6
- data/solidus_backend.gemspec +1 -1
- data/vendor/assets/javascripts/solidus_admin/underscore.js +1823 -1329
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 167281f642dc52cabba45304f1ec89744ea6583885fc53783303a88d949d83e6
|
4
|
+
data.tar.gz: 1a49a77a9e9c3dedbe2fedbfb5877a61c5fade7e435df5a28b88755bcf8cb6ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4715eaba5c97daa199678e78498cb606bf1ce3cfaffe9b209c0dd388175454d91f9c46666c5143dff8244342fc1aa1061dbe18b202482c1e1a8e9531263fbb21
|
7
|
+
data.tar.gz: 5f9bd79cd6ce2c349bbe553889d00ba0fdf0dc3fd06961e8f72cc9ff208db8a427eaac33d038b774d840d074cd34300faef41f46558f101b7179fd354014a0df
|
@@ -1,6 +1,8 @@
|
|
1
1
|
Spree.ready(function () {
|
2
2
|
'use strict';
|
3
3
|
|
4
|
-
$('[data-hook="add_product_name"]').find('.variant_autocomplete').variantAutocomplete({
|
4
|
+
$('[data-hook="add_product_name"]').find('.variant_autocomplete').variantAutocomplete({
|
5
|
+
searchParameters: function (_term) { return { suppliable_only: true } }
|
6
|
+
});
|
5
7
|
$("[data-hook='admin_orders_index_search']").find(".variant_autocomplete").variantAutocomplete();
|
6
8
|
});
|
@@ -1,9 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* Make the element a select2 dropdown used for finding Products. By default,
|
3
|
+
* it allows the Products to be found by its name and its Variants' SKUs.
|
4
|
+
* @param {Object} options Options
|
5
|
+
* @param {Boolean} [options.multiple=true] Allow multiple products to be selectable
|
6
|
+
* @param {Function|undefined} options.searchParameters Returns a hash object for params to merge on the select2 ajax request
|
7
|
+
* Accepts an argument of the select2 search term. To use custom Ransack
|
8
|
+
* define q on the hash and add your custom terms. Note, you need to
|
9
|
+
* ensure that the attributes are allowed to be Ransacked.
|
10
|
+
*/
|
1
11
|
$.fn.productAutocomplete = function (options) {
|
2
12
|
'use strict';
|
3
13
|
|
4
14
|
// Default options
|
5
15
|
options = options || {}
|
6
16
|
var multiple = typeof(options['multiple']) !== 'undefined' ? options['multiple'] : true
|
17
|
+
function extraParameters(term) {
|
18
|
+
if (typeof(options['searchParameters']) === 'function') {
|
19
|
+
return options['searchParameters'](term)
|
20
|
+
}
|
21
|
+
|
22
|
+
return {
|
23
|
+
q: {
|
24
|
+
name_cont: term,
|
25
|
+
variants_including_master_sku_start: term,
|
26
|
+
m: 'or'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
7
30
|
|
8
31
|
function formatProduct(product) {
|
9
32
|
return Select2.util.escapeMarkup(product.name);
|
@@ -26,15 +49,11 @@ $.fn.productAutocomplete = function (options) {
|
|
26
49
|
datatype: 'json',
|
27
50
|
params: { "headers": { 'Authorization': 'Bearer ' + Spree.api_key } },
|
28
51
|
data: function (term, page) {
|
29
|
-
|
30
|
-
q: {
|
31
|
-
name_cont: term,
|
32
|
-
variants_including_master_sku_start: term,
|
33
|
-
m: 'or'
|
34
|
-
},
|
52
|
+
const params = {
|
35
53
|
token: Spree.api_key,
|
36
54
|
page: page
|
37
55
|
};
|
56
|
+
return _.extend(params, extraParameters(term));
|
38
57
|
},
|
39
58
|
results: function (data, page) {
|
40
59
|
var products = data.products ? data.products : [];
|
@@ -7,10 +7,38 @@
|
|
7
7
|
});
|
8
8
|
};
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
/**
|
11
|
+
* Make the element a select2 dropdown used for finding Variants. By default, the search term will be
|
12
|
+
* passed to the defined Spree::Config.variant_search_class by the controller with its defined scope.
|
13
|
+
* @param {Object|undefined|null} options Options
|
14
|
+
* @param {Function|undefined} options.searchParameters Returns a hash object for params to merge on the select2 ajax request
|
15
|
+
* Accepts an argument of the select2 search term. To use Ransack, define
|
16
|
+
* variant_search_term as a falsy value, and q as the Ransack query. Note,
|
17
|
+
* you need to ensure that the attributes are allowed to be Ransacked.
|
18
|
+
*/
|
19
|
+
$.fn.variantAutocomplete = function(options) {
|
20
|
+
function extraParameters(term) {
|
21
|
+
if (typeof(options) === 'object') {
|
22
|
+
if (typeof(options['searchParameters']) === 'function') {
|
23
|
+
return options['searchParameters'](term)
|
24
|
+
} else {
|
25
|
+
console.warn(
|
26
|
+
"Solidus deprecation: Passing an object of parameters to variantAutocomplete is deprecated. Instead, on the options object, please declare `searchParameters` as a function returning the parameters.\n\n",
|
27
|
+
"Deprecated usage:\n",
|
28
|
+
"$('#id').variantAutocomplete({\n",
|
29
|
+
" suppliable_only: true\n",
|
30
|
+
"})",
|
31
|
+
"\n\nNew usage:\n",
|
32
|
+
"$('#id').variantAutocomplete({\n",
|
33
|
+
" searchParameters: function (_selectSearchTerm) { return { suppliable_only: true } }\n",
|
34
|
+
"})"
|
35
|
+
)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
return {}
|
13
40
|
}
|
41
|
+
|
14
42
|
this.select2({
|
15
43
|
placeholder: Spree.translations.variant_placeholder,
|
16
44
|
minimumInputLength: 3,
|
@@ -35,7 +63,7 @@
|
|
35
63
|
token: Spree.api_key,
|
36
64
|
page: page
|
37
65
|
};
|
38
|
-
return _.extend(searchData,
|
66
|
+
return _.extend(searchData, extraParameters(term));
|
39
67
|
},
|
40
68
|
|
41
69
|
results: function(data, page) {
|
@@ -84,6 +84,8 @@ Spree.Views.Cart.LineItemRow = Backbone.View.extend({
|
|
84
84
|
noCancel: this.model.isNew() && this.model.collection.length == 1
|
85
85
|
});
|
86
86
|
this.$el.html(html);
|
87
|
-
this.$("[name=variant_id]").variantAutocomplete({
|
87
|
+
this.$("[name=variant_id]").variantAutocomplete({
|
88
|
+
searchParameters: function (_term) { return { suppliable_only: true } }
|
89
|
+
});
|
88
90
|
}
|
89
91
|
});
|
@@ -82,9 +82,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
|
|
82
82
|
records = model_class.where(id: positions.keys).to_a
|
83
83
|
|
84
84
|
positions.each do |id, index|
|
85
|
-
|
86
|
-
# and in params under the string representation instead of integer
|
87
|
-
records.find { |r| r.id.to_s == id }&.set_list_position(index)
|
85
|
+
records.find { |r| r.id == id.to_i }&.set_list_position(index)
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|
@@ -142,14 +142,7 @@
|
|
142
142
|
</div>
|
143
143
|
<% end %>
|
144
144
|
</div>
|
145
|
-
|
146
|
-
<%= f.field_container :track_inventory do %>
|
147
|
-
<label>
|
148
|
-
<%= f.check_box :track_inventory %>
|
149
|
-
<%= Spree::Variant.human_attribute_name(:track_inventory) %>
|
150
|
-
</label>
|
151
|
-
<% end %>
|
152
|
-
</div>
|
145
|
+
|
153
146
|
<% end %>
|
154
147
|
|
155
148
|
<div data-hook="admin_product_form_shipping_categories">
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div data-hook="admin_<%= model_name %>_form_generate_vat_prices" class="
|
1
|
+
<div data-hook="admin_<%= model_name %>_form_generate_vat_prices" class="checkbox">
|
2
2
|
<label>
|
3
3
|
<%= form.check_box :rebuild_vat_prices, checked: form.object.prices.size <= 1 %>
|
4
4
|
<%= Spree::Variant.human_attribute_name(:rebuild_vat_prices) %>
|
@@ -19,6 +19,20 @@
|
|
19
19
|
<%= t('spree.included_in_price') %>
|
20
20
|
</label>
|
21
21
|
</div>
|
22
|
+
<div data-hook="level" class="field">
|
23
|
+
<%= f.label :level, t('spree.tax_rate_level') %>
|
24
|
+
<%= admin_hint t('spree.tax_rate_level'), t(:tax_rate_level, scope: [:spree, :hints, "spree/tax_rate"]) %>
|
25
|
+
<ul>
|
26
|
+
<% Spree::TaxRate.levels.keys.each do |level| %>
|
27
|
+
<li>
|
28
|
+
<label>
|
29
|
+
<%= f.radio_button :level, level %>
|
30
|
+
<%= t("spree.#{level}_level") %>
|
31
|
+
</label>
|
32
|
+
</li>
|
33
|
+
<% end %>
|
34
|
+
</ul>
|
35
|
+
</div>
|
22
36
|
</div>
|
23
37
|
|
24
38
|
<div class="col-5">
|
@@ -70,14 +70,11 @@
|
|
70
70
|
<%= f.label :price %>
|
71
71
|
<%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :price, currency: @variant.default_price_or_build.currency %>
|
72
72
|
</div>
|
73
|
+
<% if show_rebuild_vat_checkbox? %>
|
74
|
+
<%= render "spree/admin/shared/rebuild_vat_prices_checkbox", form: f, model_name: "variant" %>
|
75
|
+
<% end %>
|
73
76
|
</div>
|
74
77
|
|
75
|
-
<% if show_rebuild_vat_checkbox? %>
|
76
|
-
<div class="col-3">
|
77
|
-
<%= render "spree/admin/shared/rebuild_vat_prices_checkbox", form: f, model_name: "variant", wrapper_class: "field" %>
|
78
|
-
</div>
|
79
|
-
<% end %>
|
80
|
-
|
81
78
|
<div class="col-3">
|
82
79
|
<div class="field" data-hook="cost_price">
|
83
80
|
<%= f.label :cost_price %>
|
@@ -97,6 +94,19 @@
|
|
97
94
|
{ class: 'custom-select fullwidth' } %>
|
98
95
|
</div>
|
99
96
|
</div>
|
97
|
+
|
98
|
+
<div class="col-3">
|
99
|
+
<div class="field" data-hook="shipping_category">
|
100
|
+
<%= f.label :shipping_category %>
|
101
|
+
<%= f.field_hint :shipping_category %>
|
102
|
+
<%= f.collection_select :shipping_category_id,
|
103
|
+
@shipping_categories,
|
104
|
+
:id,
|
105
|
+
:name,
|
106
|
+
{ include_blank: t('.use_product_shipping_category') },
|
107
|
+
{ class: 'custom-select fullwidth' } %>
|
108
|
+
</div>
|
109
|
+
</div>
|
100
110
|
</div>
|
101
111
|
</fieldset>
|
102
112
|
</div>
|
data/solidus_backend.gemspec
CHANGED