alchemy-solidus 7.3.0 → 7.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46d8a3b3de7124d7a00825bd35e9f96ca0fe16f13b6d3dbcda7e31cd47367c46
|
4
|
+
data.tar.gz: '09cf18eece796eb7f3439eea4dd76ce60f44d9c268631e47e72d10fa1648cd9d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
3
|
+
$.fn.alchemyVariantSelect = function (options) {
|
4
|
+
const config = Alchemy.Solidus.getSelect2Config(options)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
41
|
+
name: "<%= spree_variant_editor.variant.name %>",
|
42
|
+
options_text: "<%= spree_variant_editor.variant.options_text %>"
|
23
43
|
}
|
24
44
|
<% end %>
|
25
45
|
})
|
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.
|
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-
|
11
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|