spree_frontend 4.3.1 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +192 -0
- data/.codeclimate.yml +36 -0
- data/.deepsource.toml +19 -0
- data/.editorconfig +22 -0
- data/.eslintignore +7 -0
- data/.eslintrc +36 -0
- data/.gem_release.yml +7 -0
- data/.github/CONTRIBUTING.md +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/ISSUE_TEMPLATE.md +39 -0
- data/.github/dependabot.yml +32 -0
- data/.gitignore +58 -0
- data/.rubocop.yml +197 -0
- data/.solargraph.yml +20 -0
- data/.stylelintignore +4 -0
- data/.stylelintrc +6 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +58 -3
- data/LICENSE +1 -1
- data/README.md +88 -0
- data/SECURITY.md +1 -0
- data/app/assets/config/spree_frontend_manifest.js +1 -0
- data/app/assets/javascripts/spree/{api → frontend/api}/main.js +4 -4
- data/app/assets/javascripts/spree/{api → frontend/api}/storefront/cart.js +1 -1
- data/app/assets/javascripts/spree/frontend/checkout/address.js +3 -3
- data/app/assets/javascripts/spree/frontend/currency.js +6 -7
- data/app/assets/javascripts/spree/frontend/locale.es6 +1 -2
- data/app/assets/javascripts/{spree.js → spree/frontend/main.js} +5 -5
- data/app/assets/javascripts/spree/frontend/{turbolinks_scroll_fix.js → turbo_scroll_fix.js} +3 -3
- data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +1 -1
- data/app/assets/javascripts/spree/frontend/views/spree/product/related.js +1 -1
- data/app/assets/javascripts/spree/frontend/views/spree/products/cart_form.js +8 -8
- data/app/assets/javascripts/spree/frontend/views/spree/products/description.js +1 -1
- data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +1 -1
- data/app/assets/javascripts/spree/frontend/views/spree/shared/mobile_navigation.js +4 -4
- data/app/assets/javascripts/spree/frontend/views/spree/shared/variant_select.js +3 -3
- data/app/assets/javascripts/spree/frontend.js +10 -17
- data/app/controllers/spree/addresses_controller.rb +4 -4
- data/app/controllers/spree/checkout_controller.rb +2 -2
- data/app/controllers/spree/locale_controller.rb +3 -2
- data/app/controllers/spree/orders_controller.rb +1 -1
- data/app/controllers/spree/store_controller.rb +42 -1
- data/app/helpers/spree/frontend_helper.rb +32 -8
- data/app/helpers/spree/navigation_helper.rb +2 -2
- data/app/helpers/spree/products_filters_helper.rb +1 -1
- data/app/helpers/spree/store_helper.rb +1 -1
- data/app/services/spree/build_localized_redirect_url.rb +101 -0
- data/app/views/spree/checkout/_delivery.html.erb +1 -1
- data/app/views/spree/checkout/edit.html.erb +1 -1
- data/app/views/spree/checkout/registration.html.erb +1 -1
- data/app/views/spree/orders/_line_item.html.erb +1 -1
- data/app/views/spree/orders/_line_item_data.html.erb +1 -1
- data/app/views/spree/products/_color_option_type.html.erb +2 -2
- data/app/views/spree/products/_description.html.erb +1 -1
- data/app/views/spree/products/_filters_desktop.html.erb +3 -3
- data/app/views/spree/products/_filters_mobile.html.erb +2 -2
- data/app/views/spree/products/_thumbnails.html.erb +2 -2
- data/app/views/spree/shared/_head.html.erb +3 -2
- data/app/views/spree/shared/_line_item.html.erb +1 -1
- data/app/views/spree/shared/_link_to_account.html.erb +3 -1
- data/app/views/spree/shared/_login.html.erb +1 -1
- data/app/views/spree/shared/_main_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_order_details.html.erb +1 -1
- data/app/views/spree/shared/_paths.html.erb +1 -1
- data/app/views/spree/shared/_translations.html.erb +1 -1
- data/app/views/spree/shared/carousel/_single.html.erb +2 -2
- data/app/views/spree/shared/carousel/_thumbnails.html.erb +1 -1
- data/app/views/spree/shared/cms/sections/_hero_image.html.erb +9 -9
- data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +21 -21
- data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +14 -14
- data/app/views/spree/taxons/_header.html.erb +1 -1
- data/app/views/spree/users/_address_controls.html.erb +1 -1
- data/config/routes.rb +4 -4
- data/lib/generators/spree/frontend/install/install_generator.rb +1 -1
- data/lib/spree/frontend/configuration.rb +18 -0
- data/lib/spree/frontend/engine.rb +3 -7
- data/lib/spree/frontend/version.rb +9 -0
- data/lib/spree/frontend.rb +2 -1
- data/license.md +13 -0
- data/spree_frontend.gemspec +5 -4
- metadata +58 -22
- data/app/models/spree/frontend_configuration.rb +0 -10
- data/app/views/spree/shared/_taxonomies.html.erb +0 -16
data/.rubocop.yml
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
Exclude:
|
6
|
+
- '**/sandbox/**/*'
|
7
|
+
- '**/db/migrate/*'
|
8
|
+
- '**/Gemfile'
|
9
|
+
- '**/Gemfile.lock'
|
10
|
+
- '**/Rakefile'
|
11
|
+
- '**/rails'
|
12
|
+
- '**/*.gemspec'
|
13
|
+
- '**/dummy/**/*'
|
14
|
+
- '**/vendor/**/*'
|
15
|
+
- '**/spec_helper.rb'
|
16
|
+
- '**/templates/**/*'
|
17
|
+
|
18
|
+
Layout/MultilineOperationIndentation:
|
19
|
+
EnforcedStyle: indented
|
20
|
+
|
21
|
+
Layout/ParameterAlignment:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Metrics/ClassLength:
|
25
|
+
CountComments: false
|
26
|
+
Max: 150
|
27
|
+
|
28
|
+
Metrics/ModuleLength:
|
29
|
+
CountComments: false
|
30
|
+
Max: 250
|
31
|
+
Exclude:
|
32
|
+
- '**/spec/**/*'
|
33
|
+
|
34
|
+
Style/Documentation:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Layout/LineLength:
|
38
|
+
Max: 150
|
39
|
+
Exclude:
|
40
|
+
- '**/spec/**/*'
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
CountComments: false
|
44
|
+
Max: 50
|
45
|
+
|
46
|
+
Metrics/BlockLength:
|
47
|
+
CountComments: false
|
48
|
+
Max: 50
|
49
|
+
Exclude:
|
50
|
+
- '**/spec/**/*'
|
51
|
+
- '**/*.rake'
|
52
|
+
- '**/factories/**/*'
|
53
|
+
- '**/config/routes.rb'
|
54
|
+
|
55
|
+
Metrics/AbcSize:
|
56
|
+
Max: 45
|
57
|
+
|
58
|
+
Style/StringLiterals:
|
59
|
+
EnforcedStyle: single_quotes
|
60
|
+
|
61
|
+
Layout/DotPosition:
|
62
|
+
EnforcedStyle: trailing
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
66
|
+
Exclude:
|
67
|
+
- 'api/spec/integration/**/*.rb'
|
68
|
+
- 'api/lib/spree/api/testing_support/v2/platform_contexts.rb'
|
69
|
+
|
70
|
+
Style/FrozenStringLiteralComment:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/RegexpLiteral:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/WordArray:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Style/SymbolArray:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/SymbolProc:
|
83
|
+
Exclude:
|
84
|
+
- '**/app/serializers/**/*'
|
85
|
+
|
86
|
+
Style/GuardClause:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
Style/TrailingCommaInArrayLiteral:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
Style/TrailingCommaInHashLiteral:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
Style/BarePercentLiterals:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Style/MutableConstant:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
Style/PercentLiteralDelimiters:
|
102
|
+
Enabled: false
|
103
|
+
|
104
|
+
Style/IfUnlessModifier:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
Naming/VariableNumber:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
Style/RedundantPercentQ:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
Lint/ParenthesesAsGroupedExpression:
|
114
|
+
Enabled: false
|
115
|
+
|
116
|
+
Style/NumericPredicate:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
Metrics/PerceivedComplexity:
|
120
|
+
Max: 10
|
121
|
+
|
122
|
+
Metrics/CyclomaticComplexity:
|
123
|
+
Max: 10
|
124
|
+
|
125
|
+
Style/ClassAndModuleChildren:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
Style/AndOr:
|
129
|
+
Exclude:
|
130
|
+
- '**/*controller.rb'
|
131
|
+
|
132
|
+
Style/HashEachMethods:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Style/HashTransformKeys:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
Style/HashTransformValues:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
RSpec/NestedGroups:
|
142
|
+
Max: 7
|
143
|
+
|
144
|
+
Lint/AmbiguousBlockAssociation:
|
145
|
+
Exclude:
|
146
|
+
- '**/spec/**/*'
|
147
|
+
|
148
|
+
Style/NumericLiterals:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
RSpec/DescribeClass:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
RSpec/VerifiedDoubles:
|
155
|
+
Enabled: false
|
156
|
+
|
157
|
+
RSpec/MessageChain:
|
158
|
+
Enabled: false
|
159
|
+
|
160
|
+
RSpec/AnyInstance:
|
161
|
+
Enabled: false
|
162
|
+
|
163
|
+
RSpec/InstanceVariable:
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
RSpec/ContextWording:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
RSpec/ExpectInHook:
|
170
|
+
Enabled: false
|
171
|
+
|
172
|
+
RSpec/ExampleLength:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
RSpec/MessageSpies:
|
176
|
+
Enabled: false
|
177
|
+
|
178
|
+
RSpec/NamedSubject:
|
179
|
+
Enabled: false
|
180
|
+
|
181
|
+
RSpec/MultipleExpectations:
|
182
|
+
Enabled: false
|
183
|
+
|
184
|
+
RSpec/FilePath:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
RSpec/LetSetup:
|
188
|
+
Enabled: false
|
189
|
+
|
190
|
+
RSpec/SubjectStub:
|
191
|
+
Enabled: false
|
192
|
+
|
193
|
+
RSpec/VoidExpect:
|
194
|
+
Enabled: false
|
195
|
+
|
196
|
+
RSpec/BeforeAfterAll:
|
197
|
+
Enabled: false
|
data/.solargraph.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
include:
|
3
|
+
- "**/*.rb"
|
4
|
+
exclude:
|
5
|
+
- "*/spec/**/*"
|
6
|
+
- "*test/**/*"
|
7
|
+
- "*/vendor/**/*"
|
8
|
+
- vendor/**/*
|
9
|
+
- ".bundle/**/*"
|
10
|
+
- sample/**/*
|
11
|
+
- sandbox/**/*
|
12
|
+
- pkg/**/*
|
13
|
+
- cli/**/*.gemspec
|
14
|
+
require: []
|
15
|
+
domains: []
|
16
|
+
reporters:
|
17
|
+
- rubocop
|
18
|
+
- require_not_found
|
19
|
+
require_paths: []
|
20
|
+
max_files: 50_000
|
data/.stylelintignore
ADDED
data/.stylelintrc
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include:
|
8
|
+
|
9
|
+
* The use of sexualized language or imagery
|
10
|
+
* Personal attacks
|
11
|
+
* Trolling or insulting/derogatory comments
|
12
|
+
* Public or private harassment
|
13
|
+
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
|
14
|
+
* Other unethical or unprofessional conduct.
|
15
|
+
|
16
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
|
17
|
+
|
18
|
+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
19
|
+
|
20
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
21
|
+
|
22
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
data/Gemfile
CHANGED
@@ -1,6 +1,61 @@
|
|
1
|
-
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem '
|
4
|
-
|
3
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
4
|
+
|
5
|
+
%w[
|
6
|
+
actionmailer actionpack actionview activejob activemodel activerecord
|
7
|
+
activestorage activesupport railties
|
8
|
+
].each do |rails_gem|
|
9
|
+
gem rails_gem, ENV.fetch('RAILS_VERSION', '~> 7.0.0'), require: false
|
10
|
+
end
|
11
|
+
|
12
|
+
platforms :jruby do
|
13
|
+
gem 'jruby-openssl'
|
14
|
+
end
|
15
|
+
|
16
|
+
platforms :ruby do
|
17
|
+
if ENV['DB'] == 'mysql'
|
18
|
+
gem 'mysql2'
|
19
|
+
else
|
20
|
+
gem 'pg', '~> 1.1'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
group :test do
|
25
|
+
gem 'capybara', '~> 3.24'
|
26
|
+
gem 'capybara-screenshot', '~> 1.0'
|
27
|
+
gem 'capybara-select-2'
|
28
|
+
gem 'database_cleaner', '~> 2.0'
|
29
|
+
gem 'email_spec'
|
30
|
+
gem 'factory_bot_rails', '~> 6.0'
|
31
|
+
gem 'multi_json'
|
32
|
+
gem 'rspec-activemodel-mocks', '~> 1.0'
|
33
|
+
gem 'rspec-rails', '~> 5.0'
|
34
|
+
gem 'rspec-retry'
|
35
|
+
gem 'rspec_junit_formatter'
|
36
|
+
gem 'rswag-specs'
|
37
|
+
gem 'jsonapi-rspec'
|
38
|
+
gem 'simplecov', '0.17.1'
|
39
|
+
gem 'webmock', '~> 3.7'
|
40
|
+
gem 'timecop'
|
41
|
+
gem 'rails-controller-testing'
|
42
|
+
end
|
43
|
+
|
44
|
+
group :test, :development do
|
45
|
+
gem 'awesome_print'
|
46
|
+
gem 'gem-release'
|
47
|
+
gem 'redis'
|
48
|
+
gem 'rubocop', '~> 1.22.3', require: false # bumped
|
49
|
+
gem 'rubocop-rspec', require: false
|
50
|
+
gem 'pry-byebug'
|
51
|
+
gem 'webdrivers', '~> 4.1'
|
52
|
+
# Puma 6.0 causes issues in specs due to conflict with capybara version
|
53
|
+
gem 'puma', '< 6.0'
|
54
|
+
gem 'ffaker'
|
55
|
+
end
|
56
|
+
|
57
|
+
spree_opts = { github: 'spree/spree', branch: ENV.fetch('SPREE_BRANCH', 'main') }
|
58
|
+
gem 'spree_core', spree_opts
|
59
|
+
gem 'spree_api', spree_opts
|
5
60
|
|
6
61
|
gemspec
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2007-
|
1
|
+
Copyright (c) 2007-2021, Spree Commerce, Inc., Spark Solutions Sp. z o.o. and other contributors
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification,
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Spree (Legacy) Frontend
|
2
|
+
|
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)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'spree_frontend'
|
17
|
+
```
|
18
|
+
|
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.
|
22
|
+
|
23
|
+
Run:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
bundle install
|
27
|
+
bin/rails javascript:install:esbuild
|
28
|
+
bin/rails turbo:install
|
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'
|
73
|
+
```
|
74
|
+
|
75
|
+
## Maintanence policy
|
76
|
+
|
77
|
+
This gem is in maintainence mode.
|
78
|
+
|
79
|
+
We only accept bug fixes, Spree/Rails compatibility improvements & security patches.
|
80
|
+
|
81
|
+
For new project we recommend using [Storefront API](https://api.spreecommerce.org/) to create your own unique storefront or use one of the pre-built starters:
|
82
|
+
|
83
|
+
* [Next.js](https://dev-docs.spreecommerce.org/storefronts/next.js-commerce)
|
84
|
+
* [Vue Storefront](https://dev-docs.spreecommerce.org/storefronts/vue-storefront)
|
85
|
+
|
86
|
+
## Customization
|
87
|
+
|
88
|
+
[Developer documentation](https://dev-docs.spreecommerce.org/customization/storefront)
|
data/SECURITY.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Please see [Spree Guides Security section](https://dev-docs.spreecommerce.org/security/index).
|
@@ -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.
|
13
|
-
Spree.routes.api_v2_storefront_cart_add_item = Spree.
|
14
|
-
Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.
|
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 () {
|
@@ -69,11 +69,11 @@ Spree.ready(function($) {
|
|
69
69
|
var stateSpanRequired = statePara.find('abbr')
|
70
70
|
|
71
71
|
if (states.length > 0) {
|
72
|
-
selected =
|
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(
|
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('
|
2
|
-
// this condition checks if this is the first initial load of
|
3
|
-
if (!event.
|
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('
|
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.
|
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.
|
39
|
+
if (!event.detail.url.match(regex)) {
|
41
40
|
Spree.setCurrency(SPREE_CURRENCY)
|
42
41
|
}
|
43
42
|
}
|
@@ -1,11 +1,10 @@
|
|
1
|
-
document.addEventListener('
|
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
|
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 + '/' +
|
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.
|
71
|
+
states_search: Spree.localizedPathFor('api/v1/states'),
|
72
72
|
apply_coupon_code: function (orderId) {
|
73
|
-
return Spree.
|
73
|
+
return Spree.localizedPathFor('api/v1/orders/' + orderId + '/apply_coupon_code')
|
74
74
|
},
|
75
|
-
cart: Spree.
|
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('
|
19
|
-
if (event.
|
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('
|
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('
|
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('
|
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
|
-
|
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 =
|
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 ===
|
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/
|
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('
|
334
|
+
document.addEventListener('turbo:request-start', function () {
|
335
335
|
Spree.hideProductAddedModal()
|
336
336
|
})
|
337
337
|
})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener('
|
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')
|