alchemy-solidus 5.0.0 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -6
  3. data/Rakefile +18 -7
  4. data/app/assets/javascripts/alchemy/solidus/admin/product_select.js +27 -22
  5. data/app/assets/javascripts/alchemy/solidus/admin/select2_config.js +12 -10
  6. data/app/assets/javascripts/alchemy/solidus/admin.js +1 -0
  7. data/app/components/alchemy/ingredients/spree_product_view.rb +17 -0
  8. data/app/components/alchemy/ingredients/spree_taxon_view.rb +17 -0
  9. data/app/components/alchemy/ingredients/spree_variant_view.rb +17 -0
  10. data/app/overrides/alchemy/admin/pages/link/product_link.html.erb.deface +5 -0
  11. data/app/overrides/alchemy/admin/pages/link/product_link_tab.html.erb.deface +7 -0
  12. data/app/views/alchemy/admin/pages/_product_link.html.erb +30 -0
  13. data/app/views/alchemy/admin/pages/_product_link_script.html.erb +41 -0
  14. data/app/views/alchemy/ingredients/_spree_product_view.html.erb +4 -1
  15. data/app/views/alchemy/ingredients/_spree_taxon_view.html.erb +4 -1
  16. data/app/views/alchemy/ingredients/_spree_variant_view.html.erb +4 -1
  17. data/config/locales/alchemy_solidus_en.yml +3 -0
  18. data/lib/alchemy/solidus/spree_admin_unauthorized_redirect.rb +1 -1
  19. data/lib/alchemy/solidus/version.rb +1 -1
  20. data/lib/generators/alchemy/solidus/install/install_generator.rb +100 -55
  21. metadata +70 -24
  22. data/app/models/alchemy/essence_spree_product.rb +0 -30
  23. data/app/models/alchemy/essence_spree_taxon.rb +0 -30
  24. data/app/models/alchemy/essence_spree_variant.rb +0 -29
  25. data/app/views/alchemy/essences/_essence_spree_product_editor.html.erb +0 -26
  26. data/app/views/alchemy/essences/_essence_spree_product_view.html.erb +0 -0
  27. data/app/views/alchemy/essences/_essence_spree_taxon_editor.html.erb +0 -26
  28. data/app/views/alchemy/essences/_essence_spree_taxon_view.html.erb +0 -0
  29. data/app/views/alchemy/essences/_essence_spree_variant_editor.html.erb +0 -26
  30. data/app/views/alchemy/essences/_essence_spree_variant_view.html.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a62c5d703fd9ef1302e57ebf2ae840d8adf6646600d402e171bc2f4e51fc8bc3
4
- data.tar.gz: a6c8ada063c962cc66c59841c98f3c8295973d013bebe5d3551643be41315be8
3
+ metadata.gz: b5b9e5fe0454546aa34cbead4fed12017664b119a068bda5ba08e7064376f008
4
+ data.tar.gz: 14c4045f805268897fcb4422bee6b0c87aada111c9fefc6d7a6d5eb6b8dab9ce
5
5
  SHA512:
6
- metadata.gz: f3708d87a8af2485baa75a73a6e680d40395a8e0bf35a4e236991b9f1366c1c238bfd2ec79e2660bc14bfcbcd47887c08de14b8ca002ff0837eaefea7d873386
7
- data.tar.gz: cee5253f162afdce10025ddd8167507f68cb9c296128cb6647cd30c89ac3fcde099e5d635b80fd7aeafc91763b3fd594c7d300d1691f99b527b1433cfaed4e36
6
+ metadata.gz: 3f46f3e3aa9d9f854dcc662e879b48df43f306307f7b7857eb448d02c3cab0292edd7c7f84b3b4ab641ae8f69b950af95ff0803b1e561d57125602cb28daf1b0
7
+ data.tar.gz: 6a31f2ee758ff475e13c966f6fec4dbf35b19f3f0be0c4f7f0a6893344b5a5e01df1bf4208538e9ba656502759f48e94b14c1c311dbc8d1fbe716a1dbae2c4b2
data/README.md CHANGED
@@ -13,7 +13,7 @@ This is a [AlchemyCMS](https://alchemy-cms.com) and [Solidus](https://solidus.io
13
13
 
14
14
  ### Solidus
15
15
 
16
- This version runs with Solidus v2.11 and v3.0.
16
+ This version runs with Solidus v3.0 and up.
17
17
 
18
18
  - For a Solidus < 2.11 compatible version please use the `3.1-stable` branch or `3.3.0` gem version.
19
19
  - For a Solidus < 2.6 compatible version please use the `2.3-stable` branch or `2.3.2` gem version.
@@ -23,18 +23,20 @@ This version runs with Solidus v2.11 and v3.0.
23
23
 
24
24
  ### Alchemy
25
25
 
26
- This version runs with Alchemy v5.x and v6.0.
26
+ This version runs with Alchemy v7.0
27
27
 
28
- - For a Alchemy 4.x compatible version please use the `3.1-stable` branch or `3.3.0` gem version.
29
- - For a Alchemy 4.0 compatible version please use the `2.3-stable` branch or `2.3.2` gem version.
30
- - For a Alchemy 3.x compatible version please use the `1.0-stable` branch or `1.1.0` gem version.
28
+ - For a Alchemy 6.x compatible version please use the `5.0-stable` branch or `5.0` gem version.
29
+ - For a Alchemy 5.x compatible version please use the `4.1-stable` branch or `4.1` gem version.
30
+ - For a Alchemy 4.x compatible version please use the `3.1-stable` branch or `3.3` gem version.
31
+ - For a Alchemy 4.0 compatible version please use the `2.3-stable` branch or `2.3` gem version.
32
+ - For a Alchemy 3.x compatible version please use the `1.0-stable` branch or `1.1` gem version.
31
33
 
32
34
  ## Installation
33
35
 
34
36
  Add this line to your applications `Gemfile`:
35
37
 
36
38
  ```ruby
37
- gem 'alchemy-solidus', '~> 2.4.0'
39
+ gem 'alchemy-solidus', '~> 6.0'
38
40
  ```
39
41
 
40
42
  Install the gem with:
data/Rakefile CHANGED
@@ -10,16 +10,25 @@ require "rspec/core"
10
10
  require "rspec/core/rake_task"
11
11
  RSpec::Core::RakeTask.new(:spec)
12
12
 
13
- task default: [:test_setup, :spec]
13
+ task default: %i[test_setup spec]
14
14
 
15
15
  require "active_support/core_ext/string"
16
16
 
17
17
  desc "Setup test app"
18
18
  task :test_setup do
19
- solidus_version = ENV.fetch("SOLIDUS_VERSION", "3.2")
20
- solidus_32_install_options = "--payment-method none --frontend none --no-with-authentication"
21
- solidus_33_install_options = "--payment-method none --frontend none --authentication none"
22
- solidus_install_options = solidus_version == "3.2" ? solidus_32_install_options : solidus_33_install_options
19
+ solidus_version = ENV.fetch("SOLIDUS_VERSION", "4.0")
20
+ solidus_32_install_options =
21
+ "--payment-method none --frontend none --no-with-authentication"
22
+ solidus_33_install_options =
23
+ "--payment-method none --frontend none --authentication none"
24
+ solidus_install_options =
25
+ (
26
+ if solidus_version == "3.2"
27
+ solidus_32_install_options
28
+ else
29
+ solidus_33_install_options
30
+ end
31
+ )
23
32
  Dir.chdir("spec/dummy") do
24
33
  system <<-SETUP.strip_heredoc
25
34
  bin/rake db:environment:set db:drop && \
@@ -27,8 +36,10 @@ task :test_setup do
27
36
  bin/rails g gutentag:migration_versions && \
28
37
  bin/rails g solidus:install --force --auto-accept --no-seed --no-sample #{solidus_install_options} && \
29
38
  bin/rails g solidus_frontend:install --force --auto-accept && \
30
- bin/rails g alchemy:solidus:install --auto-accept --force && \
31
- bin/rake db:test:prepare
39
+ bin/rails javascript:install:esbuild && \
40
+ bin/rails g alchemy:solidus:install --auto-accept --skip && \
41
+ bin/rake db:test:prepare && \
42
+ bin/rails javascript:build
32
43
  SETUP
33
44
  exit($?.exitstatus) unless $?.success?
34
45
  end
@@ -1,32 +1,37 @@
1
1
  //= require alchemy/solidus/admin/select2_config
2
2
 
3
- $.fn.alchemyProductSelect = function(options) {
3
+ $.fn.alchemyProductSelect = function (options) {
4
4
  var config = Alchemy.Solidus.getSelect2Config(options)
5
5
 
6
- this.select2($.extend(true, config, {
7
- ajax: {
8
- data: function(term, page) {
6
+ function formatResultObject(product) {
7
+ return {
8
+ id: product.id,
9
+ text: product.name,
10
+ }
11
+ }
12
+
13
+ var select2config = Object.assign(config, {
14
+ ajax: Object.assign(config.ajax, {
15
+ data: function (term, page) {
9
16
  return {
10
- q: $.extend({
11
- name_cont: term
12
- }, options.query_params),
13
- page: page
17
+ q: Object.assign(
18
+ {
19
+ name_cont: term,
20
+ },
21
+ options.query_params
22
+ ),
23
+ page: page,
14
24
  }
15
25
  },
16
- results: function(data, page) {
26
+ results: function (data, page) {
17
27
  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
28
+ results: data.products.map(
29
+ options.formatResultObject || formatResultObject
30
+ ),
31
+ more: page * data.per_page < data.total_count,
25
32
  }
26
- }
27
- },
28
- formatSelection: function(product) {
29
- return product.text || product.name
30
- }
31
- }))
33
+ },
34
+ }),
35
+ })
36
+ this.select2(select2config)
32
37
  }
@@ -1,24 +1,26 @@
1
1
  Alchemy = window.Alchemy || {}
2
2
  Alchemy.Solidus = Alchemy.Solidus || {}
3
3
 
4
- Alchemy.Solidus.getSelect2Config = function(options) {
4
+ Alchemy.Solidus.getSelect2Config = function (options) {
5
5
  var headers = {
6
- 'Authorization': 'Bearer ' + options.apiToken
6
+ Authorization: "Bearer " + options.apiToken,
7
7
  }
8
8
 
9
9
  return {
10
10
  placeholder: options.placeholder,
11
11
  minimumInputLength: 3,
12
- initSelection: function(_$el, callback) {
13
- if (options.initialSelection) {
14
- callback(options.initialSelection)
15
- }
16
- },
12
+ initSelection:
13
+ options.initSelection ||
14
+ function (_$el, callback) {
15
+ if (options.initialSelection) {
16
+ callback(options.initialSelection)
17
+ }
18
+ },
17
19
  ajax: {
18
20
  url: options.baseUrl,
19
- datatype: 'json',
21
+ datatype: "json",
20
22
  quietMillis: 300,
21
- params: { headers: headers }
22
- }
23
+ params: { headers: headers },
24
+ },
23
25
  }
24
26
  }
@@ -1,3 +1,4 @@
1
1
  //= require alchemy/solidus/admin/product_select
2
2
  //= require alchemy/solidus/admin/variant_select
3
3
  //= require alchemy/solidus/admin/taxon_select
4
+ //= require spree
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ module Ingredients
5
+ class SpreeProductView < BaseView
6
+ delegate :product, to: :ingredient
7
+
8
+ def call
9
+ product.name
10
+ end
11
+
12
+ def render?
13
+ !!product
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ module Ingredients
5
+ class SpreeTaxonView < BaseView
6
+ delegate :taxon, to: :ingredient
7
+
8
+ def call
9
+ taxon.name
10
+ end
11
+
12
+ def render?
13
+ !!taxon
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ module Ingredients
5
+ class SpreeVariantView < BaseView
6
+ delegate :variant, to: :ingredient
7
+
8
+ def call
9
+ variant.name
10
+ end
11
+
12
+ def render?
13
+ !!variant
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ <!-- insert_bottom "#overlay_tabs" -->
2
+
3
+ <div id="overlay_tab_product_link">
4
+ <%= render "product_link" %>
5
+ </div>
@@ -0,0 +1,7 @@
1
+ <!-- insert_bottom "#overlay_tabs > ul" -->
2
+
3
+ <li>
4
+ <a href="#overlay_tab_product_link">
5
+ <%= Alchemy.t('link_overlay_tab_label.product') %>
6
+ </a>
7
+ </li>
@@ -0,0 +1,30 @@
1
+ <%= form_tag do %>
2
+ <%= render_message do %>
3
+ <h3><%= Alchemy.t(:choose_product_to_link) %></h3>
4
+ <% end %>
5
+ <div class="input select">
6
+ <label for="product_link" class="control-label">
7
+ <%= Spree::Product.model_name.human %>
8
+ </label>
9
+ <input type="text" id="product_link" class="alchemy_selectbox full_width">
10
+ </div>
11
+ <div class="input text">
12
+ <label for="product_link_title" class="control-label">
13
+ <%= Alchemy.t(:link_title) %>
14
+ </label>
15
+ <%= text_field_tag "product_link_title", '', class: 'link_title' %>
16
+ </div>
17
+ <div class="input select">
18
+ <label for="product_link_target" class="control-label">
19
+ <%= Alchemy.t("Open Link in") %>
20
+ </label>
21
+ <%= select_tag 'product_link_target',
22
+ options_for_select(Alchemy::Page.link_target_options),
23
+ class: 'alchemy_selectbox link_target' %>
24
+ </div>
25
+ <div class="submit">
26
+ <%= button_tag Alchemy.t(:apply), class: 'create-link button', data: { link_type: 'product' } %>
27
+ </div>
28
+ <% end %>
29
+
30
+ <%= render "product_link_script" %>
@@ -0,0 +1,41 @@
1
+ <script>
2
+ $("#overlay_tabs").on("SelectLinkTab.Alchemy", function(event, data) {
3
+ $("#product_link").select2("val", data.link.attr("href"))
4
+ })
5
+ $("#product_link").alchemyProductSelect({
6
+ placeholder: "<%= Alchemy.t(:search_product, scope: "solidus") %>",
7
+ apiToken: "<%= current_alchemy_user.spree_api_key %>",
8
+ baseUrl: "<%= spree.api_products_path %>",
9
+ formatResultObject(product) {
10
+ return {
11
+ id: Spree.mountedAt() + "products/"+ product.slug,
12
+ text: product.name,
13
+ }
14
+ },
15
+ initSelection($element, callback) {
16
+ var query = $element.val().replace(Spree.mountedAt() + "products/", "")
17
+ $.ajax({
18
+ url: "<%= spree.api_products_path %>",
19
+ data: {
20
+ q: { slug_eq: query },
21
+ page: 1,
22
+ per_page: 1
23
+ },
24
+ headers: {
25
+ Authorization: "Bearer <%= current_alchemy_user.spree_api_key %>"
26
+ }
27
+ }).done(function(data) {
28
+ var product = data.products[0]
29
+ if (product) {
30
+ callback({
31
+ id: Spree.mountedAt() + "products/"+ product.slug,
32
+ text: product.name
33
+ })
34
+ $("#overlay_tabs").tabs("option", "active",
35
+ $("#overlay_tabs > div").index($("#overlay_tab_product_link"))
36
+ )
37
+ }
38
+ })
39
+ },
40
+ })
41
+ </script>
@@ -1 +1,4 @@
1
- <%= spree_product_view.product&.name %>
1
+ <%= render spree_product_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
4
+ ) -%>
@@ -1 +1,4 @@
1
- <%= spree_taxon_view.taxon&.name %>
1
+ <%= render spree_taxon_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
4
+ ) -%>
@@ -1 +1,4 @@
1
- <%= spree_variant_view.variant&.name %>
1
+ <%= render spree_variant_view.as_view_component(
2
+ **local_assigns.slice(:options),
3
+ **local_assigns.slice(:html_options)
4
+ ) -%>
@@ -1,5 +1,8 @@
1
1
  en:
2
2
  alchemy:
3
+ choose_product_to_link: Choose a product to link to
4
+ link_overlay_tab_label:
5
+ product: Product
3
6
  solidus:
4
7
  search_variant: Search a variant by name or sku
5
8
  search_product: Search a product by name
@@ -1,5 +1,5 @@
1
1
  Spree::Admin::BaseController.unauthorized_redirect = -> do
2
- if try_spree_current_user
2
+ if spree_current_user
3
3
  flash[:error] = I18n.t('spree.authorization_failure')
4
4
  redirect_to spree.root_path
5
5
  else
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module Solidus
3
- VERSION = "5.0.0"
3
+ VERSION = "6.0.1"
4
4
  end
5
5
  end
@@ -1,17 +1,17 @@
1
- require 'rails/generators'
2
- require 'alchemy/version'
1
+ require "rails/generators"
2
+ require "alchemy/version"
3
3
 
4
4
  if Alchemy.gem_version >= Gem::Version.new("5.0.0.a")
5
- require 'generators/alchemy/install/install_generator'
5
+ require "generators/alchemy/install/install_generator"
6
6
  else
7
- require 'rails/generators/alchemy/install/install_generator'
7
+ require "rails/generators/alchemy/install/install_generator"
8
8
  end
9
9
 
10
- require 'generators/spree/custom_user/custom_user_generator'
11
- require 'solidus_support'
10
+ require "generators/spree/custom_user/custom_user_generator"
11
+ require "solidus_support"
12
12
 
13
13
  begin
14
- require 'generators/alchemy/devise/install/install_generator'
14
+ require "generators/alchemy/devise/install/install_generator"
15
15
  rescue LoadError
16
16
  end
17
17
 
@@ -21,46 +21,81 @@ module Alchemy
21
21
  SPREE_MOUNT_REGEXP = /mount\sSpree::Core::Engine.*$/
22
22
  desc "Installs Alchemy Solidus into your App."
23
23
 
24
- class_option :skip_alchemy_installer, default: false, type: :boolean,
25
- desc: "Set true if you don't want to run the Alchemy installer"
26
- class_option :skip_alchemy_devise_installer, default: false, type: :boolean,
27
- desc: "Set true if you don't want to run the Alchemy Devise installer. NOTE: Automatically skipped if Alchemy::Devise is not available."
28
- class_option :skip_spree_custom_user_generator, default: false, type: :boolean,
29
- desc: "Set true if you don't want to run the Solidus custom user generator. NOTE: Automatically skipped if Alchemy::Devise is not available."
30
- class_option :skip_alchemy_user_generator, default: false, type: :boolean,
31
- desc: "Set true if you don't want to generate an admin user. NOTE: Automatically skipped if Alchemy::Devise is not available."
32
- class_option :auto_accept, default: false, type: :boolean,
33
- desc: 'Set true if run from a automated script (ie. on a CI)'
34
-
35
- source_root File.expand_path('files', __dir__)
24
+ class_option :skip_alchemy_installer,
25
+ default: false,
26
+ type: :boolean,
27
+ desc:
28
+ "Set true if you don't want to run the Alchemy installer"
29
+ class_option :skip_alchemy_devise_installer,
30
+ default: false,
31
+ type: :boolean,
32
+ desc:
33
+ "Set true if you don't want to run the Alchemy Devise installer. NOTE: Automatically skipped if Alchemy::Devise is not available."
34
+ class_option :skip_spree_custom_user_generator,
35
+ default: false,
36
+ type: :boolean,
37
+ desc:
38
+ "Set true if you don't want to run the Solidus custom user generator. NOTE: Automatically skipped if Alchemy::Devise is not available."
39
+ class_option :skip_alchemy_user_generator,
40
+ default: false,
41
+ type: :boolean,
42
+ desc:
43
+ "Set true if you don't want to generate an admin user. NOTE: Automatically skipped if Alchemy::Devise is not available."
44
+ class_option :auto_accept,
45
+ default: false,
46
+ type: :boolean,
47
+ desc: "Set true if run from a automated script (ie. on a CI)"
48
+
49
+ source_root File.expand_path("files", __dir__)
36
50
 
37
51
  def run_alchemy_installer
38
52
  unless options[:skip_alchemy_installer]
39
- arguments = options[:auto_accept] ? ['--skip-demo-files', '--force', '--auto-accept'] : []
53
+ arguments =
54
+ (
55
+ if options[:auto_accept]
56
+ %w[--skip-demo-files --skip --auto-accept]
57
+ else
58
+ []
59
+ end
60
+ )
40
61
  Alchemy::Generators::InstallGenerator.start(arguments)
41
- rake('railties:install:migrations', abort_on_failure: true)
42
- rake('db:migrate', abort_on_failure: true)
62
+ rake("railties:install:migrations", abort_on_failure: true)
63
+ rake("db:migrate", abort_on_failure: true)
43
64
  end
44
65
  end
45
66
 
46
67
  def run_alchemy_devise_installer
47
68
  if alchemy_devise_present? && !options[:skip_alchemy_devise_installer]
48
- arguments = options[:auto_accept] ? ['--force'] : []
69
+ arguments = options[:auto_accept] ? ["--force"] : []
49
70
  Alchemy::Devise::Generators::InstallGenerator.start(arguments)
50
71
  end
51
72
  end
52
73
 
53
74
  def run_spree_custom_user_generator
54
- if alchemy_devise_present? && !options[:skip_spree_custom_user_generator]
55
- arguments = options[:auto_accept] ? ['Alchemy::User', '--force'] : ['Alchemy::User']
75
+ if alchemy_devise_present? &&
76
+ !options[:skip_spree_custom_user_generator]
77
+ arguments =
78
+ (
79
+ if options[:auto_accept]
80
+ %w[Alchemy::User --force]
81
+ else
82
+ ["Alchemy::User"]
83
+ end
84
+ )
56
85
  Spree::CustomUserGenerator.start(arguments)
57
- gsub_file 'lib/spree/authentication_helpers.rb', /main_app\./, 'Alchemy.'
58
- rake('db:migrate', abort_on_failure: true)
86
+ gsub_file "lib/spree/authentication_helpers.rb",
87
+ /main_app\./,
88
+ "Alchemy."
89
+ rake("db:migrate", abort_on_failure: true)
59
90
  end
60
91
  end
61
92
 
62
93
  def inject_admin_tab
63
- inject_into_file 'config/initializers/spree.rb', {after: "Spree::Backend::Config.configure do |config|\n"} do
94
+ inject_into_file "config/initializers/spree.rb",
95
+ {
96
+ after:
97
+ "Spree::Backend::Config.configure do |config|\n"
98
+ } do
64
99
  <<~ADMIN_TAB
65
100
  \ # AlchemyCMS admin tabs
66
101
  \ config.menu_items << config.class::MenuItem.new(
@@ -77,64 +112,74 @@ module Alchemy
77
112
  end
78
113
 
79
114
  def create_admin_user
80
- if alchemy_devise_present? && !options[:skip_alchemy_user_generator] && Alchemy::User.count.zero?
81
- login = ENV.fetch('ALCHEMY_ADMIN_USER_LOGIN', 'admin')
82
- email = ENV.fetch('ALCHEMY_ADMIN_USER_EMAIL', 'admin@example.com')
83
- password = ENV.fetch('ALCHEMY_ADMIN_USER_PASSWORD', 'test1234')
115
+ if alchemy_devise_present? && !options[:skip_alchemy_user_generator] &&
116
+ Alchemy::User.count.zero?
117
+ login = ENV.fetch("ALCHEMY_ADMIN_USER_LOGIN", "admin")
118
+ email = ENV.fetch("ALCHEMY_ADMIN_USER_EMAIL", "admin@example.com")
119
+ password = ENV.fetch("ALCHEMY_ADMIN_USER_PASSWORD", "test1234")
84
120
  unless options[:auto_accept]
85
- login = ask("\nEnter the username for the admin user", default: login)
121
+ login =
122
+ ask("\nEnter the username for the admin user", default: login)
86
123
  email = ask("Enter the email for the admin user", default: email)
87
- password = ask("Enter the password for the admin user", default: password)
124
+ password =
125
+ ask("Enter the password for the admin user", default: password)
88
126
  end
89
127
 
90
128
  # This is a bit strange, but without the double save this fails with a failed validation.
91
- Alchemy::User.create!(
92
- login: login,
93
- email: email,
94
- password: password,
95
- password_confirmation: password,
96
- alchemy_roles: 'admin'
97
- ).tap do |user|
98
- user.spree_roles = [Spree::Role.find_or_create_by!(name: 'admin')]
99
- user.save!
100
- end
129
+ Alchemy::User
130
+ .create!(
131
+ login: login,
132
+ email: email,
133
+ password: password,
134
+ password_confirmation: password,
135
+ alchemy_roles: "admin"
136
+ )
137
+ .tap do |user|
138
+ user.spree_roles = [Spree::Role.find_or_create_by!(name: "admin")]
139
+ user.save!
140
+ end
101
141
  end
102
142
  end
103
143
 
104
144
  def inject_routes
105
- routes_file_path = Rails.root.join('config', 'routes.rb')
106
- mountpoint = '/'
145
+ routes_file_path = Rails.root.join("config", "routes.rb")
146
+ mountpoint = "/"
107
147
  unless options[:auto_accept]
108
- mountpoint = ask("\nAt which path do you want to mount AlchemyCMS at?", default: mountpoint)
148
+ mountpoint =
149
+ ask(
150
+ "\nAt which path do you want to mount AlchemyCMS at?",
151
+ default: mountpoint
152
+ )
109
153
  end
110
154
  if File.read(routes_file_path).match SPREE_MOUNT_REGEXP
111
155
  sentinel = SPREE_MOUNT_REGEXP
112
156
  else
113
157
  sentinel = "Rails.application.routes.draw do\n"
114
158
  end
115
- inject_into_file routes_file_path, {after: sentinel} do
116
- "\n mount Alchemy::Engine, at: '/#{mountpoint.chomp('/')}'\n"
159
+ inject_into_file routes_file_path, { after: sentinel } do
160
+ "\n mount Alchemy::Engine, at: '/#{mountpoint.chomp("/")}'\n"
117
161
  end
118
162
  end
119
163
 
120
164
  def set_root_route
121
- routes_file_path = Rails.root.join('config', 'routes.rb')
122
- if options[:auto_accept] || yes?("\nDo you want Alchemy to handle the root route '/'? (y/n)")
165
+ routes_file_path = Rails.root.join("config", "routes.rb")
166
+ if options[:auto_accept] ||
167
+ yes?("\nDo you want Alchemy to handle the root route '/'? (y/n)")
123
168
  sentinel = "Rails.application.routes.draw do\n"
124
- inject_into_file routes_file_path, {after: sentinel} do
169
+ inject_into_file routes_file_path, { after: sentinel } do
125
170
  <<~ROOT_ROUTE
126
171
  \ # Let AlchemyCMS handle the root route
127
172
  \ root to: 'alchemy/pages#index'
128
173
  ROOT_ROUTE
129
174
  end
130
- copy_file('db/seeds/alchemy/pages.yml')
131
- rake('alchemy:db:seed', abort_on_failure: true)
175
+ copy_file("db/seeds/alchemy/pages.yml")
176
+ rake("alchemy:db:seed", abort_on_failure: true)
132
177
  end
133
178
  end
134
179
 
135
180
  def append_assets
136
181
  append_file "vendor/assets/javascripts/alchemy/admin/all.js",
137
- "//= require alchemy/solidus/admin.js"
182
+ "//= require alchemy/solidus/admin.js"
138
183
  end
139
184
 
140
185
  private
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: 5.0.0
4
+ version: 6.0.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: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: 7.0.0.b
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 6.0.0
29
+ version: 7.0.0.b
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: solidus_core
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 3.0.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '4.0'
42
+ version: '4.1'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 3.0.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '4.0'
52
+ version: '4.1'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: solidus_backend
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: 3.0.0
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '4.0'
62
+ version: '4.1'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ dependencies:
69
69
  version: 3.0.0
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '4.0'
72
+ version: '4.1'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: solidus_support
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -104,14 +104,14 @@ dependencies:
104
104
  requirements:
105
105
  - - "~>"
106
106
  - !ruby/object:Gem::Version
107
- version: '5.0'
107
+ version: '6.0'
108
108
  type: :development
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - "~>"
113
113
  - !ruby/object:Gem::Version
114
- version: '5.0'
114
+ version: '6.0'
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: shoulda-matchers
117
117
  requirement: !ruby/object:Gem::Requirement
@@ -132,14 +132,14 @@ dependencies:
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: '2.15'
135
+ version: '3.0'
136
136
  type: :development
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: '2.15'
142
+ version: '3.0'
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: capybara-screenshot
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -196,6 +196,54 @@ dependencies:
196
196
  - - ">="
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
+ - !ruby/object:Gem::Dependency
200
+ name: selenium-webdriver
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - "~>"
204
+ - !ruby/object:Gem::Version
205
+ version: '4.8'
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 4.8.3
209
+ type: :development
210
+ prerelease: false
211
+ version_requirements: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '4.8'
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: 4.8.3
219
+ - !ruby/object:Gem::Dependency
220
+ name: puma
221
+ requirement: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - "~>"
224
+ - !ruby/object:Gem::Version
225
+ version: '6.0'
226
+ type: :development
227
+ prerelease: false
228
+ version_requirements: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - "~>"
231
+ - !ruby/object:Gem::Version
232
+ version: '6.0'
233
+ - !ruby/object:Gem::Dependency
234
+ name: webdrivers
235
+ requirement: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - "~>"
238
+ - !ruby/object:Gem::Version
239
+ version: '5.0'
240
+ type: :development
241
+ prerelease: false
242
+ version_requirements: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - "~>"
245
+ - !ruby/object:Gem::Version
246
+ version: '5.0'
199
247
  description: A AlchemyCMS and Solidus integration
200
248
  email:
201
249
  - thomas@vondeyen.com
@@ -211,18 +259,16 @@ files:
211
259
  - app/assets/javascripts/alchemy/solidus/admin/select2_config.js
212
260
  - app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
213
261
  - app/assets/javascripts/alchemy/solidus/admin/variant_select.js
214
- - app/models/alchemy/essence_spree_product.rb
215
- - app/models/alchemy/essence_spree_taxon.rb
216
- - app/models/alchemy/essence_spree_variant.rb
262
+ - app/components/alchemy/ingredients/spree_product_view.rb
263
+ - app/components/alchemy/ingredients/spree_taxon_view.rb
264
+ - app/components/alchemy/ingredients/spree_variant_view.rb
217
265
  - app/models/alchemy/ingredients/spree_product.rb
218
266
  - app/models/alchemy/ingredients/spree_taxon.rb
219
267
  - app/models/alchemy/ingredients/spree_variant.rb
220
- - app/views/alchemy/essences/_essence_spree_product_editor.html.erb
221
- - app/views/alchemy/essences/_essence_spree_product_view.html.erb
222
- - app/views/alchemy/essences/_essence_spree_taxon_editor.html.erb
223
- - app/views/alchemy/essences/_essence_spree_taxon_view.html.erb
224
- - app/views/alchemy/essences/_essence_spree_variant_editor.html.erb
225
- - app/views/alchemy/essences/_essence_spree_variant_view.html.erb
268
+ - app/overrides/alchemy/admin/pages/link/product_link.html.erb.deface
269
+ - app/overrides/alchemy/admin/pages/link/product_link_tab.html.erb.deface
270
+ - app/views/alchemy/admin/pages/_product_link.html.erb
271
+ - app/views/alchemy/admin/pages/_product_link_script.html.erb
226
272
  - app/views/alchemy/ingredients/_spree_product_editor.html.erb
227
273
  - app/views/alchemy/ingredients/_spree_product_view.html.erb
228
274
  - app/views/alchemy/ingredients/_spree_taxon_editor.html.erb
@@ -268,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
314
  - !ruby/object:Gem::Version
269
315
  version: '0'
270
316
  requirements: []
271
- rubygems_version: 3.4.6
317
+ rubygems_version: 3.4.12
272
318
  signing_key:
273
319
  specification_version: 4
274
320
  summary: The World's Most Flexible E-Commerce Platform meets The World's Most Flexible
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- class EssenceSpreeProduct < ActiveRecord::Base
5
- PRODUCT_ID = /\A\d+\z/
6
-
7
- belongs_to :product,
8
- class_name: "Spree::Product",
9
- optional: true,
10
- foreign_key: "spree_product_id"
11
-
12
- acts_as_essence(ingredient_column: :product)
13
-
14
- def ingredient=(product_or_id)
15
- case product_or_id
16
- when PRODUCT_ID, ""
17
- self.spree_product_id = product_or_id
18
- when Spree::Product
19
- self.product = product_or_id
20
- else
21
- super
22
- end
23
- end
24
-
25
- def preview_text(_maxlength)
26
- return unless product
27
- product.name
28
- end
29
- end
30
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- class EssenceSpreeTaxon < ActiveRecord::Base
5
- TAXON_ID = /\A\d+\z/
6
-
7
- belongs_to :taxon,
8
- class_name: "Spree::Taxon",
9
- optional: true,
10
- foreign_key: "taxon_id"
11
-
12
- acts_as_essence(ingredient_column: :taxon)
13
-
14
- def ingredient=(taxon_or_id)
15
- case taxon_or_id
16
- when TAXON_ID, ""
17
- self.taxon_id = taxon_or_id
18
- when Spree::Taxon
19
- self.taxon = taxon_or_id
20
- else
21
- super
22
- end
23
- end
24
-
25
- def preview_text(_maxlength)
26
- return unless taxon
27
- taxon.name
28
- end
29
- end
30
- end
@@ -1,29 +0,0 @@
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,
8
- class_name: "Spree::Variant",
9
- optional: true
10
-
11
- acts_as_essence(ingredient_column: :variant)
12
-
13
- def ingredient=(variant_or_id)
14
- case variant_or_id
15
- when VARIANT_ID, ""
16
- self.variant_id = variant_or_id
17
- when Spree::Variant
18
- self.variant = variant_or_id
19
- else
20
- super
21
- end
22
- end
23
-
24
- def preview_text(_maxlength)
25
- return unless variant
26
- variant.descriptive_name
27
- end
28
- end
29
- end
@@ -1,26 +0,0 @@
1
- <% content ||= local_assigns[:content] || local_assigns[:essence_spree_product_editor] %>
2
-
3
- <div class="content_editor essence_spree_product" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
4
- <%= content_label(content) %>
5
- <%= text_field_tag(
6
- content.form_field_name,
7
- content.essence.spree_product_id,
8
- id: content.form_field_id,
9
- class: 'alchemy_selectbox full_width'
10
- ) %>
11
- </div>
12
-
13
- <script>
14
- $('#<%= content.form_field_id %>').alchemyProductSelect({
15
- placeholder: "<%= Alchemy.t(:search_product, scope: 'solidus') %>",
16
- apiToken: "<%= current_alchemy_user.spree_api_key %>",
17
- baseUrl: "<%= spree.api_products_path %>",
18
- query_params: <%== content.settings[:query_params].to_json %>,
19
- <% if content.essence.product %>
20
- initialSelection: {
21
- id: <%= content.essence.spree_product_id %>,
22
- text: "<%= content.essence.product.name %>"
23
- }
24
- <% end %>
25
- })
26
- </script>
@@ -1,26 +0,0 @@
1
- <% content ||= local_assigns[:content] || local_assigns[:essence_spree_taxon_editor] %>
2
-
3
- <div class="content_editor essence_spree_taxon" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
4
- <%= content_label(content) %>
5
- <%= text_field_tag(
6
- content.form_field_name,
7
- content.essence.taxon_id,
8
- id: content.form_field_id,
9
- class: 'alchemy_selectbox full_width'
10
- ) %>
11
- </div>
12
-
13
- <script>
14
- $('#<%= content.form_field_id %>').alchemyTaxonSelect({
15
- placeholder: "<%= Alchemy.t(:search_taxon, scope: 'solidus') %>",
16
- apiToken: "<%= current_alchemy_user.spree_api_key %>",
17
- baseUrl: "<%= spree.api_taxons_path %>",
18
- query_params: <%== content.settings[:query_params].to_json %>,
19
- <% if content.essence.taxon %>
20
- initialSelection: {
21
- id: <%= content.essence.taxon_id %>,
22
- text: "<%= content.essence.taxon.pretty_name %>"
23
- }
24
- <% end %>
25
- })
26
- </script>
@@ -1,26 +0,0 @@
1
- <% content ||= local_assigns[:content] || local_assigns[:essence_spree_variant_editor] %>
2
-
3
- <div class="content_editor essence_spree_variant" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
4
- <%= content_label(content) %>
5
- <%= text_field_tag(
6
- content.form_field_name,
7
- content.essence.variant_id,
8
- id: content.form_field_id,
9
- class: 'alchemy_selectbox full_width'
10
- ) %>
11
- </div>
12
-
13
- <script>
14
- $('#<%= content.form_field_id %>').alchemyVariantSelect({
15
- placeholder: "<%= Alchemy.t(:search_variant, scope: 'solidus') %>",
16
- apiToken: "<%= current_alchemy_user.spree_api_key %>",
17
- baseUrl: "<%= spree.api_variants_path %>",
18
- query_params: <%== content.settings[:query_params].to_json %>,
19
- <% if content.essence.variant %>
20
- initialSelection: {
21
- id: <%= content.essence.variant_id %>,
22
- text: "<%= content.essence.variant.name %>"
23
- }
24
- <% end %>
25
- })
26
- </script>