alchemy-solidus 2.4.0 → 2.5.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/README.md +1 -0
- data/Rakefile +8 -0
- data/app/assets/javascripts/alchemy/solidus/admin.js +3 -0
- data/app/assets/javascripts/alchemy/solidus/admin/product_select.js +32 -0
- data/app/assets/javascripts/alchemy/solidus/admin/select2_config.js +24 -0
- data/app/assets/javascripts/alchemy/solidus/admin/taxon_select.js +32 -0
- data/app/assets/javascripts/alchemy/solidus/admin/variant_select.js +32 -0
- data/app/models/alchemy/essence_spree_product.rb +21 -7
- data/app/models/alchemy/essence_spree_taxon.rb +21 -7
- data/app/models/alchemy/essence_spree_variant.rb +27 -0
- data/app/views/alchemy/essences/_essence_spree_product_editor.html.erb +21 -6
- data/app/views/alchemy/essences/_essence_spree_taxon_editor.html.erb +20 -11
- data/app/views/alchemy/essences/_essence_spree_variant_editor.html.erb +24 -0
- data/app/views/alchemy/essences/_essence_spree_variant_view.html.erb +0 -0
- data/config/locales/alchemy_solidus_en.yml +5 -0
- data/db/migrate/20191107135822_create_alchemy_essence_spree_variants.rb +9 -0
- data/lib/alchemy/solidus/version.rb +1 -1
- data/lib/generators/alchemy/solidus/install/install_generator.rb +5 -0
- metadata +39 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78297e4bf371b6cfc4d26faa46417dbcbf165650a64d484f60dac52feae1ebde
|
4
|
+
data.tar.gz: 9d985945b0d70a693cef42837edf97791ac4c7b3b38b5df5e5e5c79e21382642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c1f70ee1697b9dc3aa3fdca9ab58e532a5adbf81c0ed5ddc7f3c1e07033c77717b43815920ca47f9d1a0731792fe69e7185402289a9cb5a4aa99bb4a6ae5d53
|
7
|
+
data.tar.gz: 7e5923735790b534b8e780f71a51b3cb4e07c34692a7977bf0accf9abb949406eee23cd4166c839b6d40df62c374832367e2dedef16f11ac4163e84041ec6c50
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -26,3 +26,11 @@ task :test_setup do
|
|
26
26
|
exit($?.exitstatus) unless $?.success?
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
require 'github_changelog_generator/task'
|
31
|
+
require 'alchemy/solidus/version'
|
32
|
+
GitHubChangelogGenerator::RakeTask.new(:changelog) do |config|
|
33
|
+
config.user = 'AlchemyCMS'
|
34
|
+
config.project = 'alchemy-solidus'
|
35
|
+
config.future_release = "v#{Alchemy::Solidus::VERSION}"
|
36
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
//= require alchemy/solidus/admin/select2_config
|
2
|
+
|
3
|
+
$.fn.alchemyProductSelect = function(options) {
|
4
|
+
var config = Alchemy.Solidus.getSelect2Config(options)
|
5
|
+
|
6
|
+
this.select2($.extend(true, config, {
|
7
|
+
ajax: {
|
8
|
+
data: function(term, page) {
|
9
|
+
return {
|
10
|
+
q: $.extend({
|
11
|
+
name_cont: term
|
12
|
+
}, options.query_params),
|
13
|
+
page: page
|
14
|
+
}
|
15
|
+
},
|
16
|
+
results: function(data, page) {
|
17
|
+
return {
|
18
|
+
results: data.products.map(function(product) {
|
19
|
+
return {
|
20
|
+
id: product.id,
|
21
|
+
text: product.name
|
22
|
+
}
|
23
|
+
}),
|
24
|
+
more: page * data.per_page < data.total_count
|
25
|
+
}
|
26
|
+
}
|
27
|
+
},
|
28
|
+
formatSelection: function(product) {
|
29
|
+
return product.text || product.name
|
30
|
+
}
|
31
|
+
}))
|
32
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Alchemy = window.Alchemy || {}
|
2
|
+
Alchemy.Solidus = Alchemy.Solidus || {}
|
3
|
+
|
4
|
+
Alchemy.Solidus.getSelect2Config = function(options) {
|
5
|
+
var headers = {
|
6
|
+
'X-Spree-Token': options.apiToken
|
7
|
+
}
|
8
|
+
|
9
|
+
return {
|
10
|
+
placeholder: options.placeholder,
|
11
|
+
minimumInputLength: 3,
|
12
|
+
initSelection: function(_$el, callback) {
|
13
|
+
if (options.initialSelection) {
|
14
|
+
callback(options.initialSelection)
|
15
|
+
}
|
16
|
+
},
|
17
|
+
ajax: {
|
18
|
+
url: options.baseUrl,
|
19
|
+
datatype: 'json',
|
20
|
+
quietMillis: 300,
|
21
|
+
params: { headers: headers }
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
//= require alchemy/solidus/admin/select2_config
|
2
|
+
|
3
|
+
$.fn.alchemyTaxonSelect = function(options) {
|
4
|
+
var config = Alchemy.Solidus.getSelect2Config(options)
|
5
|
+
|
6
|
+
this.select2($.extend(true, config, {
|
7
|
+
ajax: {
|
8
|
+
data: function(term, page) {
|
9
|
+
return {
|
10
|
+
q: $.extend({
|
11
|
+
name_cont: term
|
12
|
+
}, options.query_params),
|
13
|
+
page: page
|
14
|
+
}
|
15
|
+
},
|
16
|
+
results: function(data, page) {
|
17
|
+
return {
|
18
|
+
results: data.taxons.map(function(taxon) {
|
19
|
+
return {
|
20
|
+
id: taxon.id,
|
21
|
+
text: taxon.name
|
22
|
+
}
|
23
|
+
}),
|
24
|
+
more: page * data.per_page < data.total_count
|
25
|
+
}
|
26
|
+
}
|
27
|
+
},
|
28
|
+
formatSelection: function(taxon) {
|
29
|
+
return taxon.text || taxon.name
|
30
|
+
}
|
31
|
+
}))
|
32
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
//= require alchemy/solidus/admin/select2_config
|
2
|
+
|
3
|
+
$.fn.alchemyVariantSelect = function(options) {
|
4
|
+
var config = Alchemy.Solidus.getSelect2Config(options)
|
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
|
+
}
|
15
|
+
},
|
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
|
+
}))
|
32
|
+
}
|
@@ -1,14 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
class EssenceSpreeProduct < ActiveRecord::Base
|
3
|
-
|
5
|
+
PRODUCT_ID = /\A\d+\z/
|
6
|
+
|
7
|
+
belongs_to :product, class_name: 'Spree::Product',
|
8
|
+
optional: true, foreign_key: 'spree_product_id'
|
4
9
|
|
5
|
-
acts_as_essence(
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
acts_as_essence(ingredient_column: :product)
|
11
|
+
|
12
|
+
def ingredient=(product_or_id)
|
13
|
+
case product_or_id
|
14
|
+
when PRODUCT_ID
|
15
|
+
self.spree_product_id = product_or_id
|
16
|
+
when Spree::Product
|
17
|
+
self.product = product_or_id
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
9
22
|
|
10
|
-
def
|
11
|
-
product
|
23
|
+
def preview_text(_maxlength)
|
24
|
+
return unless product
|
25
|
+
product.name
|
12
26
|
end
|
13
27
|
end
|
14
28
|
end
|
@@ -1,14 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alchemy
|
2
4
|
class EssenceSpreeTaxon < ActiveRecord::Base
|
3
|
-
|
5
|
+
TAXON_ID = /\A\d+\z/
|
6
|
+
|
7
|
+
belongs_to :taxon, class_name: 'Spree::Taxon',
|
8
|
+
optional: true, foreign_key: 'taxon_id'
|
4
9
|
|
5
|
-
acts_as_essence(
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
acts_as_essence(ingredient_column: :taxon)
|
11
|
+
|
12
|
+
def ingredient=(taxon_or_id)
|
13
|
+
case taxon_or_id
|
14
|
+
when TAXON_ID
|
15
|
+
self.taxon_id = taxon_or_id
|
16
|
+
when Spree::Taxon
|
17
|
+
self.taxon = taxon_or_id
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
9
22
|
|
10
|
-
def
|
11
|
-
taxon
|
23
|
+
def preview_text(_maxlength)
|
24
|
+
return unless taxon
|
25
|
+
taxon.name
|
12
26
|
end
|
13
27
|
end
|
14
28
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
class EssenceSpreeVariant < ActiveRecord::Base
|
5
|
+
VARIANT_ID = /\A\d+\z/
|
6
|
+
|
7
|
+
belongs_to :variant, class_name: 'Spree::Variant', optional: true
|
8
|
+
|
9
|
+
acts_as_essence(ingredient_column: :variant)
|
10
|
+
|
11
|
+
def ingredient=(variant_or_id)
|
12
|
+
case variant_or_id
|
13
|
+
when VARIANT_ID
|
14
|
+
self.variant_id = variant_or_id
|
15
|
+
when Spree::Variant
|
16
|
+
self.variant = variant_or_id
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def preview_text(_maxlength)
|
23
|
+
return unless variant
|
24
|
+
variant.descriptive_name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,9 +1,24 @@
|
|
1
|
-
<div class="content_editor essence_spree_product">
|
2
|
-
|
3
|
-
<%=
|
1
|
+
<div class="content_editor essence_spree_product" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
|
2
|
+
<%= content_label(content) %>
|
3
|
+
<%= text_field_tag(
|
4
4
|
content.form_field_name,
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
content.essence.spree_product_id,
|
6
|
+
id: content.form_field_id,
|
7
|
+
class: 'alchemy_selectbox full_width'
|
8
8
|
) %>
|
9
9
|
</div>
|
10
|
+
|
11
|
+
<script>
|
12
|
+
$('#<%= content.form_field_id %>').alchemyProductSelect({
|
13
|
+
placeholder: "<%= Alchemy.t(:search_product, scope: 'solidus') %>",
|
14
|
+
apiToken: "<%= current_alchemy_user.spree_api_key %>",
|
15
|
+
baseUrl: "<%= spree.api_products_path %>",
|
16
|
+
query_params: <%== content.settings[:query_params].to_json %>,
|
17
|
+
<% if content.essence.product %>
|
18
|
+
initialSelection: {
|
19
|
+
id: <%= content.essence.spree_product_id %>,
|
20
|
+
text: "<%= content.essence.product.name %>"
|
21
|
+
}
|
22
|
+
<% end %>
|
23
|
+
})
|
24
|
+
</script>
|
@@ -1,15 +1,24 @@
|
|
1
|
-
<div class="content_editor essence_spree_taxon
|
1
|
+
<div class="content_editor essence_spree_taxon" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
|
2
2
|
<%= content_label(content) %>
|
3
|
-
<%=
|
3
|
+
<%= text_field_tag(
|
4
4
|
content.form_field_name,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:pretty_name,
|
9
|
-
content.essence.taxon_id
|
10
|
-
),
|
11
|
-
include_blank: t(".none"),
|
12
|
-
class: ["alchemy_selectbox", "essence_editor_select", html_options[:class]].join(' '),
|
13
|
-
style: html_options[:style]
|
5
|
+
content.essence.taxon_id,
|
6
|
+
id: content.form_field_id,
|
7
|
+
class: 'alchemy_selectbox full_width'
|
14
8
|
) %>
|
15
9
|
</div>
|
10
|
+
|
11
|
+
<script>
|
12
|
+
$('#<%= content.form_field_id %>').alchemyTaxonSelect({
|
13
|
+
placeholder: "<%= Alchemy.t(:search_taxon, scope: 'solidus') %>",
|
14
|
+
apiToken: "<%= current_alchemy_user.spree_api_key %>",
|
15
|
+
baseUrl: "<%= spree.api_taxons_path %>",
|
16
|
+
query_params: <%== content.settings[:query_params].to_json %>,
|
17
|
+
<% if content.essence.taxon %>
|
18
|
+
initialSelection: {
|
19
|
+
id: <%= content.essence.taxon_id %>,
|
20
|
+
text: "<%= content.essence.taxon.name %>"
|
21
|
+
}
|
22
|
+
<% end %>
|
23
|
+
})
|
24
|
+
</script>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="content_editor essence_spree_variant" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
|
2
|
+
<%= content_label(content) %>
|
3
|
+
<%= text_field_tag(
|
4
|
+
content.form_field_name,
|
5
|
+
content.essence.variant_id,
|
6
|
+
id: content.form_field_id,
|
7
|
+
class: 'alchemy_selectbox full_width'
|
8
|
+
) %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<script>
|
12
|
+
$('#<%= content.form_field_id %>').alchemyVariantSelect({
|
13
|
+
placeholder: "<%= Alchemy.t(:search_variant, scope: 'solidus') %>",
|
14
|
+
apiToken: "<%= current_alchemy_user.spree_api_key %>",
|
15
|
+
baseUrl: "<%= spree.api_variants_path %>",
|
16
|
+
query_params: <%== content.settings[:query_params].to_json %>,
|
17
|
+
<% if content.essence.variant %>
|
18
|
+
initialSelection: {
|
19
|
+
id: <%= content.essence.variant_id %>,
|
20
|
+
text: "<%= content.essence.variant.name %>"
|
21
|
+
}
|
22
|
+
<% end %>
|
23
|
+
})
|
24
|
+
</script>
|
File without changes
|
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: 2.
|
4
|
+
version: 2.5.0
|
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: 2019-
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - "~>"
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '3.7'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: shoulda-matchers
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '4.0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '4.0'
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: capybara
|
117
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,6 +182,20 @@ dependencies:
|
|
168
182
|
- - "~>"
|
169
183
|
- !ruby/object:Gem::Version
|
170
184
|
version: '2.7'
|
185
|
+
- !ruby/object:Gem::Dependency
|
186
|
+
name: github_changelog_generator
|
187
|
+
requirement: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
type: :development
|
193
|
+
prerelease: false
|
194
|
+
version_requirements: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
171
199
|
description: A AlchemyCMS and Solidus integration
|
172
200
|
email:
|
173
201
|
- thomas@vondeyen.com
|
@@ -178,12 +206,20 @@ files:
|
|
178
206
|
- LICENSE
|
179
207
|
- README.md
|
180
208
|
- Rakefile
|
209
|
+
- app/assets/javascripts/alchemy/solidus/admin.js
|
210
|
+
- app/assets/javascripts/alchemy/solidus/admin/product_select.js
|
211
|
+
- app/assets/javascripts/alchemy/solidus/admin/select2_config.js
|
212
|
+
- app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
|
213
|
+
- app/assets/javascripts/alchemy/solidus/admin/variant_select.js
|
181
214
|
- app/models/alchemy/essence_spree_product.rb
|
182
215
|
- app/models/alchemy/essence_spree_taxon.rb
|
216
|
+
- app/models/alchemy/essence_spree_variant.rb
|
183
217
|
- app/views/alchemy/essences/_essence_spree_product_editor.html.erb
|
184
218
|
- app/views/alchemy/essences/_essence_spree_product_view.html.erb
|
185
219
|
- app/views/alchemy/essences/_essence_spree_taxon_editor.html.erb
|
186
220
|
- app/views/alchemy/essences/_essence_spree_taxon_view.html.erb
|
221
|
+
- app/views/alchemy/essences/_essence_spree_variant_editor.html.erb
|
222
|
+
- app/views/alchemy/essences/_essence_spree_variant_view.html.erb
|
187
223
|
- app/views/spree/admin/shared/_alchemy_sub_menu.html.erb
|
188
224
|
- config/initializers/alchemy.rb
|
189
225
|
- config/initializers/solidus.rb
|
@@ -192,6 +228,7 @@ files:
|
|
192
228
|
- config/locales/en.yml
|
193
229
|
- db/migrate/20120229160509_create_alchemy_essence_spree_products.rb
|
194
230
|
- db/migrate/20131030140218_create_alchemy_essence_spree_taxons.rb
|
231
|
+
- db/migrate/20191107135822_create_alchemy_essence_spree_variants.rb
|
195
232
|
- lib/alchemy-solidus.rb
|
196
233
|
- lib/alchemy/solidus/alchemy_in_solidus.rb
|
197
234
|
- lib/alchemy/solidus/alchemy_user_extension.rb
|