spree_frontend 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +18 -17
  3. data/.eslintrc +1 -1
  4. data/Gemfile +4 -8
  5. data/README.md +55 -2
  6. data/app/assets/config/spree_frontend_manifest.js +1 -0
  7. data/app/assets/javascripts/spree/{api → frontend/api}/main.js +4 -4
  8. data/app/assets/javascripts/spree/{api → frontend/api}/storefront/cart.js +1 -1
  9. data/app/assets/javascripts/spree/frontend/checkout/address.js +3 -3
  10. data/app/assets/javascripts/spree/frontend/currency.js +6 -7
  11. data/app/assets/javascripts/spree/frontend/locale.es6 +1 -2
  12. data/app/assets/javascripts/{spree.js → spree/frontend/main.js} +5 -5
  13. data/app/assets/javascripts/spree/frontend/{turbolinks_scroll_fix.js → turbo_scroll_fix.js} +3 -3
  14. data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +1 -1
  15. data/app/assets/javascripts/spree/frontend/views/spree/product/related.js +1 -1
  16. data/app/assets/javascripts/spree/frontend/views/spree/products/cart_form.js +8 -8
  17. data/app/assets/javascripts/spree/frontend/views/spree/products/description.js +1 -1
  18. data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +1 -1
  19. data/app/assets/javascripts/spree/frontend/views/spree/shared/mobile_navigation.js +4 -4
  20. data/app/assets/javascripts/spree/frontend/views/spree/shared/variant_select.js +3 -3
  21. data/app/assets/javascripts/spree/frontend.js +10 -17
  22. data/app/controllers/spree/addresses_controller.rb +2 -2
  23. data/app/controllers/spree/checkout_controller.rb +2 -2
  24. data/app/controllers/spree/locale_controller.rb +2 -1
  25. data/app/controllers/spree/orders_controller.rb +1 -1
  26. data/app/helpers/spree/frontend_helper.rb +14 -8
  27. data/app/helpers/spree/navigation_helper.rb +1 -1
  28. data/app/helpers/spree/products_filters_helper.rb +1 -1
  29. data/app/views/spree/checkout/edit.html.erb +1 -1
  30. data/app/views/spree/checkout/registration.html.erb +1 -1
  31. data/app/views/spree/orders/_line_item.html.erb +1 -1
  32. data/app/views/spree/orders/_line_item_data.html.erb +1 -1
  33. data/app/views/spree/products/_color_option_type.html.erb +2 -2
  34. data/app/views/spree/products/_filters_desktop.html.erb +3 -3
  35. data/app/views/spree/products/_filters_mobile.html.erb +2 -2
  36. data/app/views/spree/products/_thumbnails.html.erb +2 -2
  37. data/app/views/spree/shared/_head.html.erb +3 -2
  38. data/app/views/spree/shared/_line_item.html.erb +1 -1
  39. data/app/views/spree/shared/_link_to_account.html.erb +1 -1
  40. data/app/views/spree/shared/_login.html.erb +1 -1
  41. data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
  42. data/app/views/spree/shared/_nav_bar.html.erb +1 -1
  43. data/app/views/spree/shared/_order_details.html.erb +1 -1
  44. data/app/views/spree/shared/_translations.html.erb +1 -1
  45. data/app/views/spree/shared/carousel/_single.html.erb +2 -2
  46. data/app/views/spree/shared/carousel/_thumbnails.html.erb +1 -1
  47. data/app/views/spree/shared/cms/sections/_hero_image.html.erb +9 -9
  48. data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +21 -21
  49. data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +14 -14
  50. data/app/views/spree/taxons/_header.html.erb +1 -1
  51. data/app/views/spree/users/_address_controls.html.erb +1 -1
  52. data/lib/generators/spree/frontend/install/install_generator.rb +1 -1
  53. data/lib/spree/frontend/configuration.rb +18 -0
  54. data/lib/spree/frontend/engine.rb +3 -8
  55. data/lib/spree/frontend/version.rb +1 -1
  56. data/lib/spree/frontend.rb +2 -1
  57. data/spree_frontend.gemspec +3 -2
  58. metadata +35 -21
  59. data/app/models/spree/frontend_configuration.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8869ebc4be30c0c2bf7e2527048cadda71ec5cc14891b4e74cd00304e64f7faa
4
- data.tar.gz: 4ab3f2fb4fe452d35ee0fd63c5a5c915555f0afbfd97020a9bac37691dc21cf3
3
+ metadata.gz: 1402fb31c7f3b252aa0143299ea5a3d7fbacda30d8d28fb535c26fef9e06bbf4
4
+ data.tar.gz: 6ae0c987bc34ff834db6b02c2133277412175aba67f5586f9d938813677a3150
5
5
  SHA512:
6
- metadata.gz: 10ddbe145b8b328d4545e64538785ef5990cd745b873c217f8a571d820f2e5499a1c333f2d86867a3eaab3b756a07b33311342981e35c747f7ac5ae3636e9b00
7
- data.tar.gz: b39decf33e2597c9b6dfca8647b514c000033b758cad9fb900a8be7c41231b8abca2918389d25adccbc373a6d5f1a88f9906a2f537d2f95ee299a715c50ff757
6
+ metadata.gz: 899e115454881c1e7c759cfb95ed0e9990d7bbe519c0b114dbf506426864f296f557b5ecebe3196c42b6f59ce0d33a66038f8eea8bf6e37013b35fac2c2871fc
7
+ data.tar.gz: a51ca9229e1f1130ab4c6d951f9c415410f5c9980d65937a417131eb99164b09dde80045bd5b8c086efa02842572318c60aaaff2ffd244d23234f4b0f99758fd
data/.circleci/config.yml CHANGED
@@ -7,9 +7,10 @@ defaults: &defaults
7
7
  BUNDLE_JOBS: 4
8
8
  BUNDLE_RETRY: 3
9
9
  BUNDLE_PATH: ~/spree/vendor/bundle
10
+ RAILS_VERSION: '~> 7.0'
10
11
  working_directory: ~/spree
11
12
  docker:
12
- - image: &ruby_image circleci/ruby:2.7-node-browsers
13
+ - image: &ruby_2_7_image circleci/ruby:2.7-node-browsers
13
14
  - image: &redis_image circleci/redis:6.2-alpine
14
15
 
15
16
  defaults_3_0: &defaults_3_0
@@ -18,7 +19,7 @@ defaults_3_0: &defaults_3_0
18
19
  - image: &ruby_3_0_image circleci/ruby:3.0-node-browsers
19
20
  - image: *redis_image
20
21
 
21
- run_tests: &run_tests
22
+ run_tests_2_7: &run_tests_2_7
22
23
  <<: *defaults
23
24
  parallelism: 8
24
25
  steps:
@@ -91,7 +92,7 @@ run_tests_3_0: &run_tests_3_0
91
92
  path: tmp/capybara
92
93
 
93
94
  jobs:
94
- bundle:
95
+ bundle_ruby_2_7:
95
96
  <<: *defaults
96
97
  steps:
97
98
  - checkout
@@ -137,21 +138,21 @@ jobs:
137
138
  - vendor/bundle
138
139
  key: spree-storefront-old-bundle-v10-ruby-3-0-{{ checksum "Gemfile.lock" }}
139
140
 
140
- tests_postgres: &tests_postgres
141
- <<: *run_tests
141
+ tests_ruby_2_7_rails_7_0_postgres:
142
+ <<: *run_tests_2_7
142
143
  environment: &postgres_environment
143
144
  <<: *environment
144
145
  DB: postgres
145
146
  DB_HOST: localhost
146
147
  DB_USERNAME: postgres
147
148
  docker:
148
- - image: *ruby_image
149
+ - image: *ruby_2_7_image
149
150
  - image: *redis_image
150
151
  - image: &postgres_image circleci/postgres:12-alpine
151
152
  environment:
152
153
  POSTGRES_USER: postgres
153
154
 
154
- tests_postgres_ruby_3_0: &tests_postgres_ruby_3_0
155
+ tests_ruby_3_0_rails_7_0_postgres:
155
156
  <<: *run_tests_3_0
156
157
  environment:
157
158
  <<: *postgres_environment
@@ -160,8 +161,8 @@ jobs:
160
161
  - image: *postgres_image
161
162
  - image: *redis_image
162
163
 
163
- tests_mysql: &tests_mysql
164
- <<: *run_tests
164
+ tests_ruby_2_7_rails_7_0_mysql:
165
+ <<: *run_tests_2_7
165
166
  environment: &mysql_environment
166
167
  <<: *environment
167
168
  DB: mysql
@@ -170,7 +171,7 @@ jobs:
170
171
  COVERAGE: true
171
172
  COVERAGE_DIR: /tmp/workspace/simplecov
172
173
  docker:
173
- - image: *ruby_image
174
+ - image: *ruby_2_7_image
174
175
  - image: *redis_image
175
176
  - image: &mysql_image circleci/mysql:8-ram
176
177
 
@@ -178,14 +179,14 @@ workflows:
178
179
  version: 2
179
180
  main:
180
181
  jobs:
181
- - bundle
182
+ - bundle_ruby_2_7
182
183
  - bundle_ruby_3_0
183
- - tests_postgres:
184
- requires:
185
- - bundle
186
- - tests_postgres_ruby_3_0:
184
+ - tests_ruby_3_0_rails_7_0_postgres:
187
185
  requires:
188
186
  - bundle_ruby_3_0
189
- - tests_mysql:
187
+ - tests_ruby_2_7_rails_7_0_postgres:
188
+ requires:
189
+ - bundle_ruby_2_7
190
+ - tests_ruby_2_7_rails_7_0_mysql:
190
191
  requires:
191
- - bundle
192
+ - bundle_ruby_2_7
data/.eslintrc CHANGED
@@ -16,7 +16,7 @@ globals:
16
16
  SpreePaths: true
17
17
  CouponManager: true
18
18
  ThumbnailsCarousel: true
19
- Turbolinks: true
19
+ Turbo: true
20
20
  ADDRESS_FIELDS: true
21
21
  AUTH_TOKEN: true
22
22
  SPREE_LOCALE: true
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
6
6
  actionmailer actionpack actionview activejob activemodel activerecord
7
7
  activestorage activesupport railties
8
8
  ].each do |rails_gem|
9
- gem rails_gem, ENV.fetch('RAILS_VERSION', '~> 6.1.0'), require: false
9
+ gem rails_gem, ENV.fetch('RAILS_VERSION', '~> 7.0.0'), require: false
10
10
  end
11
11
 
12
12
  platforms :jruby do
@@ -49,16 +49,12 @@ group :test, :development do
49
49
  gem 'rubocop-rspec', require: false
50
50
  gem 'pry-byebug'
51
51
  gem 'webdrivers', '~> 4.1'
52
- gem 'puma'
52
+ # Puma 6.0 causes issues in specs due to conflict with capybara version
53
+ gem 'puma', '< 6.0'
53
54
  gem 'ffaker'
54
55
  end
55
56
 
56
- group :development do
57
- gem 'github_fast_changelog'
58
- gem 'solargraph'
59
- end
60
-
61
- spree_opts = { github: 'spree/spree', branch: ENV.fetch('SPREE_BRANCH', '4-4-stable') }
57
+ spree_opts = { github: 'spree/spree', branch: ENV.fetch('SPREE_BRANCH', 'main') }
62
58
  gem 'spree_core', spree_opts
63
59
  gem 'spree_api', spree_opts
64
60
 
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Spree (Legacy) Frontend
2
2
 
3
- This is the old Spree Storefront extracted from Spree < 4.3.
3
+ This is the old Spree Storefront extracted from Spree < 4.3 which was upgraded to Turbo/Hotwire.
4
+
5
+ ## Developed by
6
+
7
+ [![Vendo](https://assets-global.website-files.com/6230c485f2c32ea1b0daa438/623372f40a8c54ca9aea34e8_vendo%202.svg)](https://getvendo.com?utm_source=spree_frontend_github)
8
+
9
+ > All-in-one platform for all your Marketplace and B2B eCommerce needs. [Start your 30-day free trial](https://e98esoirr8c.typeform.com/contactvendo?typeform-source=spree_sdk_github)
4
10
 
5
11
  ## Installation
6
12
 
@@ -10,13 +16,60 @@ Add
10
16
  gem 'spree_frontend'
11
17
  ```
12
18
 
13
- to your `Gemfile`.
19
+ to your `Gemfile`, making sure that the `spree_frontend` gem is before `spree_auth_devise`.
20
+
21
+ Make sure both `gem 'jsbundling-rails'` and `gem 'turbo-rails'` are added as well.
14
22
 
15
23
  Run:
16
24
 
17
25
  ```bash
18
26
  bundle install
27
+ bin/rails javascript:install:esbuild
28
+ bin/rails turbo:install
19
29
  bin/rails g spree:frontend:install
30
+ yarn build
31
+ ```
32
+
33
+ ### Troubleshooting
34
+
35
+ #### Disabled 'Add to Cart' Button Issue
36
+
37
+ If you notice that the 'Add to Cart' button is disabled on product pages, try the following:
38
+ * run `yarn build` again in your main repo
39
+ * if that doesn't fix the issue, try running the following setup commands again:
40
+ ```
41
+ bin/rails javascript:install:esbuild
42
+ bin/rails turbo:install
43
+ bin/rails g spree:frontend:install
44
+ yarn build
45
+ ```
46
+
47
+ This issue may come up if you switch the source of your `spree_frontend` in your Gemfile, e.g. from github to a local path, etc.
48
+
49
+ #### Checkout without logging in results in 500 error
50
+
51
+ When you navigate to checkout without logging in first, you may get a a 500 error notifying you that "yourdomain.com redirected you too many times."
52
+
53
+ This error results from the routes defined in `spree_frontend` and `spree_auth_devise` not being built in the correct order. Make sure the `spree_frontend` gem is listed before `spree_auth_devise` in your main project's gemfile, then try again.
54
+
55
+ ## Running Tests
56
+
57
+ In order to generate the dummy app required for running tests, you’ll need to have the following installed on your machine:
58
+ * node v16.13.1 (npm v8.1.2)
59
+ * yarn ≥ v1.22.15
60
+ * ruby v3.0.3
61
+
62
+ To run tests locally, first run `bundle exec rake test_app`, then `bundle exec rspec`.
63
+
64
+ ### Troubleshooting
65
+ If you are running on a Mac with an M1 processor, you may run into the following error when running tests:
66
+ ```
67
+ Webdrivers::NetworkError:
68
+ Net::HTTPServerException: 404 "Not Found"
69
+ ```
70
+ If so, update your gemfile locally to get version 5.0 or higher for the web drivers gem:
71
+ ```
72
+ gem 'webdrivers', '~> 5.0'
20
73
  ```
21
74
 
22
75
  ## Maintanence policy
@@ -2,3 +2,4 @@
2
2
  //
3
3
  //= link spree/frontend/all.js
4
4
  //= link spree/frontend/all.css
5
+ //= link application.js
@@ -1,4 +1,4 @@
1
- //= require spree
1
+ //= require spree/frontend/main
2
2
 
3
3
  var SpreeAPI = {
4
4
  oauthToken: null, // user Bearer token to authorize operations for the given user
@@ -9,9 +9,9 @@ SpreeAPI.Storefront = {}
9
9
  SpreeAPI.Platform = {}
10
10
 
11
11
  // API routes
12
- Spree.routes.api_v2_storefront_cart_create = Spree.pathFor('api/v2/storefront/cart')
13
- Spree.routes.api_v2_storefront_cart_add_item = Spree.pathFor('api/v2/storefront/cart/add_item')
14
- Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.pathFor('api/v2/storefront/cart/apply_coupon_code')
12
+ Spree.routes.api_v2_storefront_cart_create = Spree.localizedPathFor('api/v2/storefront/cart')
13
+ Spree.routes.api_v2_storefront_cart_add_item = Spree.localizedPathFor('api/v2/storefront/cart/add_item')
14
+ Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.localizedPathFor('api/v2/storefront/cart/apply_coupon_code')
15
15
 
16
16
  // helpers
17
17
  SpreeAPI.handle500error = function () {
@@ -1,4 +1,4 @@
1
- //= require spree/api/main
1
+ //= require spree/frontend/api/main
2
2
 
3
3
  SpreeAPI.Storefront.createCart = function (successCallback, failureCallback) {
4
4
  fetch(Spree.routes.api_v2_storefront_cart_create, {
@@ -69,11 +69,11 @@ Spree.ready(function($) {
69
69
  var stateSpanRequired = statePara.find('abbr')
70
70
 
71
71
  if (states.length > 0) {
72
- selected = parseInt(stateSelect.val())
72
+ selected = stateSelect.val()
73
73
  stateSelect.html('')
74
74
  $.each(states, function(idx, state) {
75
- var opt = $(document.createElement('option')).attr('value', state.id).html(state.name)
76
- if (selected.toString(10) === state.id.toString(10)) {
75
+ var opt = $(document.createElement('option')).attr('value', state.id.toString()).html(state.name)
76
+ if (selected && selected.toString() === state.id.toString()) {
77
77
  opt.prop('selected', true)
78
78
  }
79
79
  stateSelect.append(opt)
@@ -1,12 +1,11 @@
1
- document.addEventListener('turbolinks:load', function(event) {
2
- // this condition checks if this is the first initial load of turbolinks application
3
- if (!event.data.timing.visitStart) {
1
+ document.addEventListener('turbo:load', function(event) {
2
+ // this condition checks if this is the first initial load of turbo application
3
+ if (!event.detail.timing.visitStart) {
4
4
  var currencySelect = document.querySelectorAll('select[name=switch_to_currency]')
5
5
 
6
6
  if (currencySelect.length) {
7
7
  currencySelect.forEach(function (element) {
8
8
  element.addEventListener('change', function () {
9
- Spree.showProgressBar()
10
9
  var newCurrency = this.value
11
10
 
12
11
  // we need to make AJAX call here to the backend to set currency in session
@@ -28,16 +27,16 @@ document.addEventListener('turbolinks:load', function(event) {
28
27
 
29
28
  // fix back button issue with different currency set
30
29
  // invalidate page if cached page has different currency then the current one
31
- document.addEventListener('turbolinks:load', function(event) {
30
+ document.addEventListener('turbo:load', function(event) {
32
31
  if (typeof (SPREE_DEFAULT_CURRENCY) !== 'undefined' && typeof (SPREE_CURRENCY) !== 'undefined') {
33
32
  if (SPREE_CURRENCY === SPREE_DEFAULT_CURRENCY) {
34
33
  var regexAnyCurrency = new RegExp('currency=')
35
- if (event.data.url.match(regexAnyCurrency) && !event.data.url.match(SPREE_CURRENCY)) {
34
+ if (event.detail.url.match(regexAnyCurrency) && !event.detail.url.match(SPREE_CURRENCY)) {
36
35
  Spree.setCurrency(SPREE_CURRENCY)
37
36
  }
38
37
  } else {
39
38
  var regex = new RegExp('currency=' + SPREE_CURRENCY)
40
- if (!event.data.url.match(regex)) {
39
+ if (!event.detail.url.match(regex)) {
41
40
  Spree.setCurrency(SPREE_CURRENCY)
42
41
  }
43
42
  }
@@ -1,11 +1,10 @@
1
- document.addEventListener('turbolinks:load', () => {
1
+ document.addEventListener('turbo:load', () => {
2
2
  const localeSelect = document.querySelectorAll('select[name=switch_to_locale]')
3
3
 
4
4
  if (localeSelect.length) {
5
5
  localeSelect.forEach((element) => {
6
6
  element.addEventListener('change', () => {
7
7
  Spree.clearCache()
8
- Spree.showProgressBar()
9
8
  element.form.submit()
10
9
  })
11
10
  })
@@ -2,7 +2,7 @@
2
2
  function Spree () {}
3
3
 
4
4
  Spree.ready = function (callback) {
5
- return jQuery(document).on('page:load turbolinks:load', function () {
5
+ return jQuery(document).on('page:load turbo:load', function () {
6
6
  return callback(jQuery)
7
7
  })
8
8
  }
@@ -32,7 +32,7 @@ Spree.localizedPathFor = function(path) {
32
32
  if (pathName.match(/api\/v/)) {
33
33
  params.set('locale', SPREE_LOCALE)
34
34
  } else {
35
- pathName = (this.mountedAt()) + SPREE_LOCALE + '/' + path
35
+ pathName = (this.mountedAt()) + SPREE_LOCALE + '/' + pathName
36
36
  }
37
37
  return fullUrl.origin + pathName + '?' + params.toString()
38
38
  }
@@ -68,11 +68,11 @@ Spree.ajax = function (urlOrSettings, settings) {
68
68
  }
69
69
 
70
70
  Spree.routes = {
71
- states_search: Spree.pathFor('api/v1/states'),
71
+ states_search: Spree.localizedPathFor('api/v1/states'),
72
72
  apply_coupon_code: function (orderId) {
73
- return Spree.pathFor('api/v1/orders/' + orderId + '/apply_coupon_code')
73
+ return Spree.localizedPathFor('api/v1/orders/' + orderId + '/apply_coupon_code')
74
74
  },
75
- cart: Spree.pathFor('cart')
75
+ cart: Spree.localizedPathFor('cart')
76
76
  }
77
77
 
78
78
  Spree.url_params = {}
@@ -15,8 +15,8 @@
15
15
 
16
16
  // Invalidate the page when the next page is different from the current page
17
17
  // Persist scroll information across pages
18
- document.addEventListener('turbolinks:before-visit', function (event) {
19
- if (event.data.url !== location.href) {
18
+ document.addEventListener('turbo:before-visit', function (event) {
19
+ if (event.detail.url !== location.href) {
20
20
  sessionStorage.setItem(PAGE_INVALIDATED, 'true')
21
21
  }
22
22
  sessionStorage.setItem(SCROLL_POSITION, JSON.stringify(scrollData()))
@@ -28,7 +28,7 @@
28
28
  // invalidation,
29
29
  // 3. scroll to the persisted position if there, or to the top otherwise
30
30
  // 4. Remove the persisted information
31
- addEventListener('turbolinks:load', function (event) {
31
+ addEventListener('turbo:load', function (event) {
32
32
  var scrollPosition = JSON.parse(sessionStorage.getItem(SCROLL_POSITION))
33
33
 
34
34
  if (shouldScroll(scrollPosition)) {
@@ -26,7 +26,7 @@ Spree.loadsCarouselElements = function () {
26
26
  $('div[data-product-carousel-taxon-id]').each(function (_index, element) { Spree.loadCarousel(element, this) })
27
27
  }
28
28
 
29
- document.addEventListener('turbolinks:load', function () {
29
+ document.addEventListener('turbo:load', function () {
30
30
  var carouselPresent = $('div[data-product-carousel-taxon-id]')
31
31
 
32
32
  if (carouselPresent.length) {
@@ -9,7 +9,7 @@ Spree.fetchRelatedProducts = function (id, htmlContainer) {
9
9
  })
10
10
  }
11
11
 
12
- document.addEventListener('turbolinks:load', function () {
12
+ document.addEventListener('turbo:load', function () {
13
13
  var productDetailsPage = $('body#product-details')
14
14
 
15
15
  if (productDetailsPage.length) {
@@ -1,4 +1,4 @@
1
- //= require spree/api/storefront/cart
1
+ //= require spree/frontend/api/storefront/cart
2
2
  //= require ../shared/product_added_modal
3
3
  //= require ../shared/variant_select
4
4
 
@@ -89,7 +89,7 @@ function CartForm($, $cartForm) {
89
89
  this.selectedOptionValueIds.splice(
90
90
  optionTypeIndex,
91
91
  this.selectedOptionValueIds.length,
92
- parseInt($optionValue.val())
92
+ $optionValue.val().toString()
93
93
  )
94
94
  }
95
95
 
@@ -104,7 +104,7 @@ function CartForm($, $cartForm) {
104
104
  .find(OPTION_VALUE_SELECTOR)
105
105
  .each(function(_index, ov) {
106
106
  var $ov = $(ov)
107
- var id = parseInt($ov.val())
107
+ var id = $ov.val().toString()
108
108
 
109
109
  $ov.prop('checked', false)
110
110
  $ov.prop('disabled', !availableOptionValueIds.includes(id))
@@ -121,7 +121,7 @@ function CartForm($, $cartForm) {
121
121
 
122
122
  return this.variants.reduce(function(acc, variant) {
123
123
  var optionValues = variant.option_values.map(function(ov) {
124
- return ov.id
124
+ return ov.id.toString()
125
125
  })
126
126
 
127
127
  var isPossibleVariantFound = selectedOptionValueIds.every(function(ov) {
@@ -180,7 +180,7 @@ function CartForm($, $cartForm) {
180
180
 
181
181
  if (!this.withOptionValues) {
182
182
  return this.variants.find(function(variant) {
183
- return variant.id === parseInt(self.$variantIdInput.val())
183
+ return variant.id && self.$variantIdInput.val() && variant.id.toString() === self.$variantIdInput.val().toString()
184
184
  })
185
185
  }
186
186
 
@@ -190,7 +190,7 @@ function CartForm($, $cartForm) {
190
190
 
191
191
  return this.variants.find(function(variant) {
192
192
  var optionValueIds = variant.option_values.map(function(ov) {
193
- return ov.id
193
+ return ov.id.toString()
194
194
  })
195
195
 
196
196
  return self.areArraysEqual(optionValueIds, self.selectedOptionValueIds)
@@ -298,7 +298,7 @@ Spree.ready(function($) {
298
298
  quantity,
299
299
  options, // options hash - you can pass additional parameters here, your backend
300
300
  // needs to be aware of those, see API docs:
301
- // https://github.com/spree/spree/blob/master/api/docs/v2/storefront/index.yaml#L42
301
+ // https://github.com/spree/spree/blob/d894358e49b8c3a7f6944e838de7cd92510e31d0/api/docs/v2/storefront/index.yaml#L442
302
302
  function(response) {
303
303
  $addToCart.prop('disabled', false)
304
304
  Spree.fetchCart()
@@ -331,7 +331,7 @@ Spree.ready(function($) {
331
331
  CartForm($, $cartForm)
332
332
  })
333
333
 
334
- document.addEventListener('turbolinks:request-start', function () {
334
+ document.addEventListener('turbo:request-start', function () {
335
335
  Spree.hideProductAddedModal()
336
336
  })
337
337
  })
@@ -1,4 +1,4 @@
1
- document.addEventListener('turbolinks:load', function () {
1
+ document.addEventListener('turbo:load', function () {
2
2
  $('#product-description-arrow').click(function () {
3
3
  document.getElementById('product-description-long').classList.remove('d-none')
4
4
  document.getElementById('product-description-short').classList.add('d-none')
@@ -35,7 +35,7 @@ Spree.ready(function ($) {
35
35
  '?' +
36
36
  customEncodeURI(decodeURIComponent(searchParams.toString()))
37
37
  );
38
- Turbolinks.visit(location);
38
+ Turbo.visit(location);
39
39
  }
40
40
 
41
41
  function updateFilters(event, $this, removeValue) {
@@ -21,7 +21,7 @@ Spree.ready(function($) {
21
21
  this.closeAllCategories = this.closeAllCategories.bind(this);
22
22
 
23
23
  window.addEventListener('resize', this.onResize);
24
- window.addEventListener('turbolinks:request-start', this.onCloseClick);
24
+ window.addEventListener('turbo:request-start', this.onCloseClick);
25
25
 
26
26
  this.burgerButton.addEventListener('click', this.onBurgerClick, false);
27
27
  this.closeButton.addEventListener('click', this.onCloseClick, false);
@@ -77,7 +77,7 @@ Spree.ready(function($) {
77
77
 
78
78
  MobileNavigationManager.prototype.openCategory = function(category) {
79
79
  this.openedCategories.push(category);
80
- var subList = document.querySelector('ul[data-category=' + category + ']');
80
+ var subList = document.querySelector('ul[data-category="' + category + '"]');
81
81
  if (subList) {
82
82
  this.mobileNavigationList.classList.add('mobile-navigation-list-subcategory-shown');
83
83
  this.mobileNavigationList.scrollTop = 0
@@ -89,7 +89,7 @@ Spree.ready(function($) {
89
89
 
90
90
  MobileNavigationManager.prototype.closeCurrentCategory = function() {
91
91
  var category = this.openedCategories.pop();
92
- var subList = document.querySelector('ul[data-category=' + category + ']');
92
+ var subList = document.querySelector('ul[data-category="' + category + '"]');
93
93
  if (subList) {
94
94
  subList.classList.remove('shown');
95
95
  }
@@ -101,7 +101,7 @@ Spree.ready(function($) {
101
101
  }
102
102
 
103
103
  MobileNavigationManager.prototype.closeCategory = function(category) {
104
- var subList = document.querySelector('ul[data-category=' + category + ']');
104
+ var subList = document.querySelector('ul[data-category="' + category + '"]');
105
105
  subList.style.transition = 'none';
106
106
  subList.classList.remove('shown');
107
107
  setTimeout(function(){ subList.style.transition = ''; }, 500);
@@ -8,7 +8,7 @@ this.initializeQueryParamsCheck = function () {
8
8
 
9
9
  function verifyVariantIdMatch() {
10
10
  this.variants.forEach(function(variant) {
11
- if (parseInt(variant.id) === parseInt(variantIdFromUrl)) this.urlQueryMatchFound = true
11
+ if (variant.id.toString() === variantIdFromUrl.toString()) this.urlQueryMatchFound = true
12
12
  })
13
13
  }
14
14
 
@@ -23,7 +23,7 @@ this.setSelectedVariantFromUrl = function () {
23
23
 
24
24
  this.getVariantOptionsById = function(variantIdFromUrl) {
25
25
  this.variants.forEach(function(variant) {
26
- if (parseInt(variant.id) === parseInt(variantIdFromUrl)) this.sortOptionValues(variant.option_values)
26
+ if (variant.id.toString() === variantIdFromUrl.toString()) this.sortOptionValues(variant.option_values)
27
27
  })
28
28
  }
29
29
 
@@ -36,7 +36,7 @@ function buildArray(item) {
36
36
  var target = container.querySelectorAll('.product-variants-variant-values-radio')
37
37
 
38
38
  target.forEach(function(inputTag) {
39
- if (parseInt(inputTag.value) === item.id && inputTag.dataset.presentation === item.presentation) {
39
+ if (inputTag.value.toString() === item.id.toString() && inputTag.dataset.presentation === item.presentation) {
40
40
  this.selectedOptions.push(inputTag)
41
41
  }
42
42
  })
@@ -4,14 +4,13 @@
4
4
  //= require bootstrap
5
5
  //= require jquery.payment
6
6
  //= require cleave
7
- //= require spree
7
+ //= require spree/frontend/main
8
8
  //= require polyfill.min
9
9
  //= require fetch.umd
10
- //= require spree/api/main
10
+ //= require spree/frontend/api/main
11
11
  //= require ./lazysizes.config
12
12
  //= require lazysizes.min
13
13
  //= require accounting.min
14
- //= require turbolinks
15
14
  //= require spree/frontend/account
16
15
  //= require spree/frontend/api_tokens
17
16
  //= require spree/frontend/carousel-noconflict
@@ -40,31 +39,25 @@
40
39
  //= require spree/frontend/views/spree/shared/nav_bar
41
40
  //= require spree/frontend/views/spree/shared/product_added_modal
42
41
  //= require spree/frontend/views/spree/shared/quantity_select
43
- //= require spree/frontend/turbolinks_scroll_fix
42
+ //= require spree/frontend/turbo_scroll_fix
44
43
  //= require spree/frontend/main_nav_bar
45
44
  //= require spree/frontend/login
46
45
 
47
- Spree.routes.api_tokens = Spree.pathFor('api_tokens')
48
- Spree.routes.ensure_cart = Spree.pathFor('ensure_cart')
46
+ Spree.routes.api_tokens = Spree.localizedPathFor('api_tokens')
47
+ Spree.routes.ensure_cart = Spree.localizedPathFor('ensure_cart')
49
48
  Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.localizedPathFor('api/v2/storefront/cart/apply_coupon_code')
50
49
  Spree.routes.api_v2_storefront_cart_remove_coupon_code = function(couponCode) { return Spree.localizedPathFor('api/v2/storefront/cart/remove_coupon_code/' + couponCode) }
51
50
  Spree.routes.api_v2_storefront_destroy_credit_card = function(id) { return Spree.localizedPathFor('api/v2/storefront/account/credit_cards/' + id) }
52
51
  Spree.routes.product = function(id) { return Spree.localizedPathFor('products/' + id) }
53
52
  Spree.routes.product_related = function(id) { return Spree.localizedPathFor('products/' + id + '/related') }
54
53
  Spree.routes.product_carousel = function (taxonId) { return Spree.localizedPathFor('product_carousel/' + taxonId) }
55
- Spree.routes.set_locale = function(locale) { return Spree.pathFor('locale/set?switch_to_locale=' + locale) }
56
- Spree.routes.set_currency = function(currency) { return Spree.pathFor('currency/set?switch_to_currency=' + currency) }
57
-
58
- Spree.showProgressBar = function () {
59
- if (!Turbolinks.supported) { return }
60
- Turbolinks.controller.adapter.progressBar.setValue(0)
61
- Turbolinks.controller.adapter.progressBar.show()
62
- }
54
+ Spree.routes.set_locale = function(locale) { return Spree.localizedPathFor('locale/set?switch_to_locale=' + locale) }
55
+ Spree.routes.set_currency = function(currency) { return Spree.localizedPathFor('currency/set?switch_to_currency=' + currency) }
63
56
 
64
57
  Spree.clearCache = function () {
65
- if (!Turbolinks.supported) { return }
58
+ if (!window.Turbo) { return }
66
59
 
67
- Turbolinks.clearCache()
60
+ Turbo.clearCache()
68
61
  }
69
62
 
70
63
  Spree.setCurrency = function (currency) {
@@ -81,5 +74,5 @@ Spree.setCurrency = function (currency) {
81
74
 
82
75
  SPREE_CURRENCY = currency
83
76
 
84
- Turbolinks.visit(window.location.pathname + queryString, { action: 'replace' })
77
+ Turbo.visit(window.location.pathname + queryString, { action: 'replace' })
85
78
  }
@@ -10,7 +10,7 @@ module Spree
10
10
  flash[:notice] = I18n.t(:successfully_created, scope: :address_book)
11
11
  redirect_to spree.account_path
12
12
  else
13
- render action: 'new'
13
+ render action: 'new', status: :unprocessable_entity
14
14
  end
15
15
  end
16
16
 
@@ -27,7 +27,7 @@ module Spree
27
27
  flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
28
28
  redirect_back_or_default(addresses_path)
29
29
  else
30
- render :edit
30
+ render :edit, status: :unprocessable_entity
31
31
  end
32
32
  end
33
33
 
@@ -46,7 +46,7 @@ module Spree
46
46
  redirect_to spree.checkout_state_path(@order.state)
47
47
  end
48
48
  else
49
- render :edit
49
+ render :edit, status: :unprocessable_entity
50
50
  end
51
51
  end
52
52
 
@@ -190,7 +190,7 @@ module Spree
190
190
  def rescue_from_spree_gateway_error(exception)
191
191
  flash.now[:error] = Spree.t(:spree_gateway_error_flash_for_checkout)
192
192
  @order.errors.add(:base, exception.message)
193
- render :edit
193
+ render :edit, status: :unprocessable_entity
194
194
  end
195
195
 
196
196
  def check_authorization