alchemy-solidus 7.3.0 → 7.3.1

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: 823fe7fab5027f254ca1440418ca0f5957e3e4825dba007096b8fd5268694141
4
- data.tar.gz: cb223e06aa86c2a2cffed82b594e03d6febe9004b0fe55787b47b2ce76a5c3a0
3
+ metadata.gz: 46d8a3b3de7124d7a00825bd35e9f96ca0fe16f13b6d3dbcda7e31cd47367c46
4
+ data.tar.gz: '09cf18eece796eb7f3439eea4dd76ce60f44d9c268631e47e72d10fa1648cd9d'
5
5
  SHA512:
6
- metadata.gz: ff3cadb5fc31dc7603910e487cbaf59e13edf00f764ddb38af6dcd25f745b53e83a286ece56829acb34bcda3711210cb6144ae1cf3488a95cf00a0c48c06ecf2
7
- data.tar.gz: 061dbe3d8ccf9c1884dac806d44737f9e6e5f0d605da197f517200f2fd2a40dd0a1820c5b08e28d62d02eb3deb07346dbb3de68e55fc91c4b2344844e7efa755
6
+ metadata.gz: b33362b6ed914b1f180346296f4d0a5d62e47e42754bde997649737cd4d440c2a2d9cfdaea9acce67fa935c01db82eb93e0d6e5af1f1ba2afd60a30906f48bc8
7
+ data.tar.gz: db8d3049d169f31d31843199125781fd42dd72c2109168853f445fe144be62626d3d8ad9b2e1f5472a4e8b0afb378c982298076dcc7d422a4d96a6a4fb613c4a
data/README.md CHANGED
@@ -30,8 +30,9 @@ This version runs with Solidus v4.0 and up.
30
30
 
31
31
  ### Alchemy
32
32
 
33
- This version runs with Alchemy v7.0 and v7.1
33
+ This version runs with Alchemy v7.2
34
34
 
35
+ - For a Alchemy 7.0/7.1 compatible version please use the `7.2-stable` branch or `7.2` gem version.
35
36
  - For a Alchemy 6.x compatible version please use the `5.0-stable` branch or `5.0` gem version.
36
37
  - For a Alchemy 5.x compatible version please use the `4.1-stable` branch or `4.1` gem version.
37
38
  - For a Alchemy 4.x compatible version please use the `3.1-stable` branch or `3.3` gem version.
@@ -1,32 +1,55 @@
1
1
  //= require alchemy/solidus/admin/select2_config
2
2
 
3
- $.fn.alchemyVariantSelect = function(options) {
4
- var config = Alchemy.Solidus.getSelect2Config(options)
3
+ $.fn.alchemyVariantSelect = function (options) {
4
+ const config = Alchemy.Solidus.getSelect2Config(options)
5
5
 
6
- this.select2($.extend(true, config, {
7
- ajax: {
8
- data: function(term, page) {
9
- return {
10
- q: $.extend({
11
- product_name_or_sku_cont: term
12
- }, options.query_params),
13
- page: page
14
- }
6
+ function formatSelection(variant) {
7
+ return variant.options_text
8
+ ? `${variant.name} - ${variant.options_text}`
9
+ : variant.name
10
+ }
11
+
12
+ function formatResult(variant, _el, query) {
13
+ const matchTerm = new RegExp(query.term, "gi")
14
+ const formatMatch = (match) => `<em>${match}</em>`
15
+ const name = variant.name.replace(matchTerm, formatMatch)
16
+ const sku = variant.sku.replace(matchTerm, formatMatch)
17
+ return `
18
+ <div class="variant-select-result">
19
+ <div>
20
+ <span>${name}</span>
21
+ </div>
22
+ <div>
23
+ <span>${variant.options_text}</span>
24
+ <span>${sku}</span>
25
+ </div>
26
+ </div>
27
+ `
28
+ }
29
+
30
+ this.select2(
31
+ $.extend(true, config, {
32
+ ajax: {
33
+ data: function (term, page) {
34
+ return {
35
+ q: $.extend(
36
+ {
37
+ product_name_or_sku_cont: term,
38
+ },
39
+ options.query_params
40
+ ),
41
+ page: page,
42
+ }
43
+ },
44
+ results: function (data, page) {
45
+ return {
46
+ results: data.variants,
47
+ more: page * data.per_page < data.total_count,
48
+ }
49
+ },
15
50
  },
16
- results: function(data, page) {
17
- return {
18
- results: data.variants.map(function(variant) {
19
- return {
20
- id: variant.id,
21
- text: variant.frontend_display
22
- }
23
- }),
24
- more: page * data.per_page < data.total_count
25
- }
26
- }
27
- },
28
- formatSelection: function(variant) {
29
- return variant.text || variant.frontend_display
30
- }
31
- }))
51
+ formatSelection,
52
+ formatResult,
53
+ })
54
+ )
32
55
  }
@@ -10,6 +10,25 @@
10
10
  <% end %>
11
11
  <% end %>
12
12
 
13
+ <style>
14
+ .variant-select-result > * {
15
+ display: flex;
16
+ justify-content: space-between;
17
+ min-height: 16px;
18
+
19
+ > span {
20
+ display: inline-block;
21
+ overflow: hidden;
22
+ text-overflow: ellipsis;
23
+ white-space: nowrap;
24
+ }
25
+
26
+ &:last-child {
27
+ color: hsl(224, 8%, 63%);
28
+ }
29
+ }
30
+ </style>
31
+
13
32
  <script>
14
33
  $('#<%= spree_variant_editor.form_field_id(:variant_id) %>').alchemyVariantSelect({
15
34
  placeholder: "<%= Alchemy.t(:search_variant, scope: 'solidus') %>",
@@ -19,7 +38,8 @@
19
38
  <% if spree_variant_editor.variant %>
20
39
  initialSelection: {
21
40
  id: <%= spree_variant_editor.variant.id %>,
22
- text: "<%= spree_variant_editor.variant.name %>"
41
+ name: "<%= spree_variant_editor.variant.name %>",
42
+ options_text: "<%= spree_variant_editor.variant.options_text %>"
23
43
  }
24
44
  <% end %>
25
45
  })
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module Solidus
3
- VERSION = "7.3.0"
3
+ VERSION = "7.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-solidus
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.0
4
+ version: 7.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-24 00:00:00.000000000 Z
11
+ date: 2024-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms