solidus_backend 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b86594eac44c015e9c7d6c206ce3c15086baa96db0338ccb845e026b9d61c0d
4
- data.tar.gz: 388007e9b8b1dc8fe7ac3c04af96d60bb06d44fbddc0cd84919aaae65a7b5497
3
+ metadata.gz: 167281f642dc52cabba45304f1ec89744ea6583885fc53783303a88d949d83e6
4
+ data.tar.gz: 1a49a77a9e9c3dedbe2fedbfb5877a61c5fade7e435df5a28b88755bcf8cb6ed
5
5
  SHA512:
6
- metadata.gz: a1005b2bed74bc5c3fe9c20bf964aa5c73a96fe45f751752751a1f17f8f18fef03c695cc911d4e6e72f7381aad45399f5a63f188316931bea22bd8db3079e3bf
7
- data.tar.gz: 5c98470d7f898b841413275bb8296f4c4ed50263c995696b3baf5b8be0ac98e4dbaeb82022b18833facfffd082d5c002fd86bf7c12d81e925c41dbd3d9b01677
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
  });
@@ -1,3 +1,5 @@
1
+ @import "spree/backend/components/actions";
2
+
1
3
  table {
2
4
  // Extend all tables with Bootstrap's default table style
3
5
  @extend .table;
@@ -114,8 +116,8 @@ table {
114
116
  tbody {
115
117
  tr {
116
118
  &.deleted td {
117
- background-color: lighten(theme-color("danger"), 6);
118
- border-color: lighten(theme-color("danger"), 15);
119
+ background-color: $color-action-remove-bg;
120
+ text-decoration: line-through;
119
121
  }
120
122
  }
121
123
 
@@ -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
@@ -8,7 +8,7 @@ module Spree
8
8
  def index
9
9
  params[:q] ||= {}
10
10
 
11
- @search = @product.prices.accessible_by(current_ability, :index).ransack(params[:q])
11
+ @search = @product.prices.kept.accessible_by(current_ability, :index).ransack(params[:q])
12
12
  @master_prices = @search.result
13
13
  .currently_valid
14
14
  .for_master
@@ -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
@@ -36,7 +36,7 @@
36
36
  </tbody>
37
37
  </table>
38
38
 
39
- <% if can?([:create, :update], Spree::ProductProperty) %>
39
+ <% if can?(:create, Spree::ProductProperty) && can?(:update, Spree::ProductProperty) %>
40
40
  <%= render 'spree/admin/shared/edit_resource_links' %>
41
41
  <% end %>
42
42
 
@@ -95,7 +95,7 @@
95
95
  <% end %>
96
96
  </tbody>
97
97
  </table>
98
- <% if can?([:create, :update], Spree::VariantPropertyRule) %>
98
+ <% if can?(:create, Spree::VariantPropertyRule) && can?(:update, Spree::VariantPropertyRule) %>
99
99
  <%= render 'spree/admin/shared/edit_resource_links' %>
100
100
  <% end %>
101
101
  </fieldset>
@@ -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 %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :page_actions do %>
2
- <% if can?([:admin, :create], Spree::Order) %>
2
+ <% if can?(:admin, Spree::Order) && can?(:create, Spree::Order) %>
3
3
  <li>
4
4
  <%= link_to t(".create_order"), spree.new_admin_order_path(user_id: @user.id), class: 'btn btn-primary' %>
5
5
  </li>
@@ -60,7 +60,7 @@
60
60
  </span>
61
61
  </td>
62
62
  <td class="order-number">
63
- <% if can?([:admin, :edit], order) %>
63
+ <% if can?(:admin, order) && can?(:edit, order) %>
64
64
  <%= link_to order.number, edit_admin_order_url(order) %>
65
65
  <% else %>
66
66
  <%= order.number %>
@@ -38,7 +38,7 @@
38
38
  <tr data-hook="admin_orders_index_rows">
39
39
  <td class="order-completed-at"><%= l(order.completed_at.to_date) if order.completed_at %></td>
40
40
  <td class="order-number">
41
- <% if can?([:admin, :edit], order) %>
41
+ <% if can?(:admin, order) && can?(:edit, order) %>
42
42
  <%= link_to order.number, edit_admin_order_path(order) %>
43
43
  <% else %>
44
44
  <%= order.number %>
@@ -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