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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ebd88037c534ab114b9df0719ef4648d5572501a4adfb326e7a10a58b0490a5
4
- data.tar.gz: 4eae2ee341af874256562f9584e5ccd78736b6f9a33d7cfa7c4310571f991544
3
+ metadata.gz: 167281f642dc52cabba45304f1ec89744ea6583885fc53783303a88d949d83e6
4
+ data.tar.gz: 1a49a77a9e9c3dedbe2fedbfb5877a61c5fade7e435df5a28b88755bcf8cb6ed
5
5
  SHA512:
6
- metadata.gz: 5a4dac579a6a7a6e25c714bb6f6c4e1bf60592c714904f533598907651bef8d563a728a0e0a2216ae34b8946dc8dbd7ab62c29a1d985029e28981aa804cfee01
7
- data.tar.gz: 640d77bb6c592c45c3abac26201ca8ab6e5c38a5b909751eb0c18fa62ac342745fb9fc20815367afdfb4c1bad1e4bb1d61f729128ded682677edcc6767a946a7
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({ suppliable_only: true });
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
- return {
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
- $.fn.variantAutocomplete = function(searchOptions) {
11
- if (searchOptions == null) {
12
- searchOptions = {};
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, searchOptions);
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({ suppliable_only: true });
87
+ this.$("[name=variant_id]").variantAutocomplete({
88
+ searchParameters: function (_term) { return { suppliable_only: true } }
89
+ });
88
90
  }
89
91
  });
@@ -69,6 +69,12 @@ module Spree
69
69
  def payment_method_params
70
70
  params.require(:payment_method).permit!
71
71
  end
72
+
73
+ def build_resource
74
+ model_class.new(
75
+ store_ids: [Spree::Store.default.id].compact
76
+ )
77
+ end
72
78
  end
73
79
  end
74
80
  end
@@ -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
- # To permit the use of UUID as id, we compare models id in database
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
 
@@ -32,6 +32,7 @@ module Spree
32
32
 
33
33
  def load_data
34
34
  @tax_categories = Spree::TaxCategory.order(:name)
35
+ @shipping_categories = Spree::ShippingCategory.order(:name)
35
36
  end
36
37
 
37
38
  def variant_includes
@@ -142,14 +142,7 @@
142
142
  </div>
143
143
  <% end %>
144
144
  </div>
145
- <div data-hook="admin_product_form_track_inventory">
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="<%= local_assigns[:wrapper_class] %> checkbox">
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">
@@ -12,7 +12,7 @@
12
12
  <% if @taxon.parent %>
13
13
  <div class="input-group-prepend">
14
14
  <span class="input-group-text">
15
- <%= @taxon.permalink.split('/')[0...-1].join('/') + '/' %>
15
+ <%= @taxon.permalink.split('/')[...-1].join('/') + '/' %>
16
16
  </span>
17
17
  </div>
18
18
  <% end %>
@@ -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>
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  f.match(%r{^(spec|script)/})
21
21
  end
22
22
 
23
- s.required_ruby_version = '>= 2.5.0'
23
+ s.required_ruby_version = '>= 2.7.0'
24
24
  s.required_rubygems_version = '>= 1.8.23'
25
25
 
26
26
  s.add_dependency 'solidus_api', s.version