spree_frontend 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/frontend.js +28 -5
- data/app/assets/javascripts/spree/frontend/coupon_manager.js +2 -2
- data/app/assets/javascripts/spree/frontend/currency.js +40 -8
- data/app/assets/javascripts/spree/frontend/locale.js +8 -6
- data/app/controllers/concerns/spree/locale_urls.rb +1 -3
- data/app/controllers/spree/currency_controller.rb +5 -1
- data/app/views/spree/shared/_currency_dropdown.html.erb +1 -1
- data/app/views/spree/shared/_head.html.erb +1 -4
- data/app/views/spree/shared/_locale_and_currency.html.erb +6 -0
- data/app/views/spree/shared/_locale_dropdown.html.erb +1 -1
- data/config/initializers/canonical_rails.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb44ce8a344e6b78adcb87064ed90e0ec7f3f02cfc474dda6d16d41e1077e733
|
4
|
+
data.tar.gz: 7febb328e551e0396decabb7e357c626c39ab573d71895dc6e55d115bb9d6e7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5453aa3218dbbedadfc27b7f3958b33560f0d8ec33d03aee58b1d22b3c255c6cded27469e2a1b6194fb73fd0e5c658545aeb90e6003dbc6355694457ec46be
|
7
|
+
data.tar.gz: 67815113708206d6f6bab183804c7005d8ccaa707005ff6392d38eebd4b9462951833d8507da6617011a6e4052c208c67bc3be49039f25c5b5cad9e3077b9c31
|
@@ -44,11 +44,11 @@
|
|
44
44
|
|
45
45
|
Spree.routes.api_tokens = Spree.pathFor('api_tokens')
|
46
46
|
Spree.routes.ensure_cart = Spree.pathFor('ensure_cart')
|
47
|
-
Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.
|
48
|
-
Spree.routes.api_v2_storefront_cart_remove_coupon_code = Spree.
|
49
|
-
Spree.routes.product = function(id) { return Spree.
|
50
|
-
Spree.routes.product_related = function(id) { return Spree.
|
51
|
-
Spree.routes.product_carousel = function (taxonId) { return Spree.
|
47
|
+
Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.localizedPathFor('api/v2/storefront/cart/apply_coupon_code')
|
48
|
+
Spree.routes.api_v2_storefront_cart_remove_coupon_code = function(couponCode) { return Spree.localizedPathFor('api/v2/storefront/cart/remove_coupon_code/' + couponCode) }
|
49
|
+
Spree.routes.product = function(id) { return Spree.localizedPathFor('products/' + id) }
|
50
|
+
Spree.routes.product_related = function(id) { return Spree.localizedPathFor('products/' + id + '/related') }
|
51
|
+
Spree.routes.product_carousel = function (taxonId) { return Spree.localizedPathFor('product_carousel/' + taxonId) }
|
52
52
|
Spree.routes.set_locale = function(locale) { return Spree.pathFor('locale/set?switch_to_locale=' + locale) }
|
53
53
|
Spree.routes.set_currency = function(currency) { return Spree.pathFor('currency/set?switch_to_currency=' + currency) }
|
54
54
|
|
@@ -57,3 +57,26 @@ Spree.showProgressBar = function () {
|
|
57
57
|
Turbolinks.controller.adapter.progressBar.setValue(0)
|
58
58
|
Turbolinks.controller.adapter.progressBar.show()
|
59
59
|
}
|
60
|
+
|
61
|
+
Spree.clearCache = function () {
|
62
|
+
if (!Turbolinks.supported) { return }
|
63
|
+
|
64
|
+
Turbolinks.clearCache()
|
65
|
+
}
|
66
|
+
|
67
|
+
Spree.setCurrency = function (currency) {
|
68
|
+
Spree.clearCache()
|
69
|
+
|
70
|
+
var params = (new URL(window.location)).searchParams
|
71
|
+
if (currency === SPREE_DEFAULT_CURRENCY) {
|
72
|
+
params.delete('currency')
|
73
|
+
} else {
|
74
|
+
params.set('currency', currency)
|
75
|
+
}
|
76
|
+
var queryString = params.toString()
|
77
|
+
if (queryString !== '') { queryString = '?' + queryString }
|
78
|
+
|
79
|
+
SPREE_CURRENCY = currency
|
80
|
+
|
81
|
+
Turbolinks.visit(window.location.pathname + queryString, { action: 'replace' })
|
82
|
+
}
|
@@ -49,7 +49,7 @@ CouponManager.prototype.sendRequest = function () {
|
|
49
49
|
return $.ajax({
|
50
50
|
async: false,
|
51
51
|
method: 'PATCH',
|
52
|
-
url: Spree.routes.api_v2_storefront_cart_apply_coupon_code
|
52
|
+
url: Spree.routes.api_v2_storefront_cart_apply_coupon_code,
|
53
53
|
dataType: 'json',
|
54
54
|
headers: {
|
55
55
|
'X-Spree-Order-Token': SpreeAPI.orderToken
|
@@ -74,7 +74,7 @@ CouponManager.prototype.sendRemoveRequest = function () {
|
|
74
74
|
return $.ajax({
|
75
75
|
async: false,
|
76
76
|
method: 'DELETE',
|
77
|
-
url: Spree.routes.api_v2_storefront_cart_remove_coupon_code
|
77
|
+
url: Spree.routes.api_v2_storefront_cart_remove_coupon_code(this.couponCode),
|
78
78
|
dataType: 'json',
|
79
79
|
headers: {
|
80
80
|
'X-Spree-Order-Token': SpreeAPI.orderToken
|
@@ -1,11 +1,43 @@
|
|
1
|
-
|
2
|
-
|
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) {
|
4
|
+
var currencySelect = document.querySelectorAll('select[name=switch_to_currency]')
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
if (currencySelect.length) {
|
7
|
+
currencySelect.forEach(function (element) {
|
8
|
+
element.addEventListener('change', function () {
|
9
|
+
Spree.showProgressBar()
|
10
|
+
var newCurrency = this.value
|
11
|
+
|
12
|
+
// we need to make AJAX call here to the backend to set currency in session
|
13
|
+
fetch(Spree.routes.set_currency(newCurrency), {
|
14
|
+
method: 'GET'
|
15
|
+
}).then(function (response) {
|
16
|
+
switch (response.status) {
|
17
|
+
case 200:
|
18
|
+
Spree.setCurrency(newCurrency)
|
19
|
+
document.getElementById('internationalization-options-desktop').classList.remove('show')
|
20
|
+
break
|
21
|
+
}
|
22
|
+
})
|
23
|
+
})
|
24
|
+
})
|
25
|
+
}
|
26
|
+
}
|
27
|
+
})
|
28
|
+
|
29
|
+
// fix back button issue with different currency set
|
30
|
+
// invalidate page if cached page has different currency then the current one
|
31
|
+
document.addEventListener('turbolinks:load', function(event) {
|
32
|
+
if (SPREE_CURRENCY === SPREE_DEFAULT_CURRENCY) {
|
33
|
+
var regexAnyCurrency = new RegExp('currency=')
|
34
|
+
if (event.data.url.match(regexAnyCurrency) && !event.data.url.match(SPREE_CURRENCY)) {
|
35
|
+
Spree.setCurrency(SPREE_CURRENCY)
|
36
|
+
}
|
37
|
+
} else {
|
38
|
+
var regex = new RegExp('currency=' + SPREE_CURRENCY)
|
39
|
+
if (!event.data.url.match(regex)) {
|
40
|
+
Spree.setCurrency(SPREE_CURRENCY)
|
41
|
+
}
|
10
42
|
}
|
11
43
|
})
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
var localeSelect =
|
1
|
+
document.addEventListener('turbolinks:load', function () {
|
2
|
+
var localeSelect = document.querySelectorAll('select[name=switch_to_locale]')
|
3
3
|
|
4
4
|
if (localeSelect.length) {
|
5
|
-
localeSelect.
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
localeSelect.forEach(function (element) {
|
6
|
+
element.addEventListener('change', function () {
|
7
|
+
Spree.clearCache()
|
8
|
+
Spree.showProgressBar()
|
9
|
+
this.form.submit()
|
10
|
+
})
|
9
11
|
})
|
10
12
|
}
|
11
13
|
})
|
@@ -7,7 +7,11 @@ module Spree
|
|
7
7
|
current_order&.update(currency: new_currency)
|
8
8
|
session[:currency] = new_currency
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html { redirect_back fallback_location: spree.root_path(currency: new_currency) }
|
13
|
+
format.json { head :ok }
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if defined?(should_render_currency_dropdown?) && should_render_currency_dropdown? %>
|
2
|
-
<%= form_tag spree.set_currency_path, method: :get, class: 'px-4 py-3 w-100
|
2
|
+
<%= form_tag spree.set_currency_path, method: :get, class: 'px-4 py-3 w-100 currency-select' do %>
|
3
3
|
<div class="form-group">
|
4
4
|
<label for="switch_to_currency" class="dropdown-header text-center">
|
5
5
|
<%= Spree.t(:choose_currency) %>
|
@@ -8,9 +8,6 @@
|
|
8
8
|
<%= stylesheet_link_tag 'spree/frontend/all', media: 'screen', 'data-turbolinks-track': 'reload' %>
|
9
9
|
<%= csrf_meta_tags %>
|
10
10
|
<%= render 'spree/shared/paths' %>
|
11
|
-
|
12
|
-
var SPREE_LOCALE = '<%= I18n.locale %>'
|
13
|
-
var SPREE_CURRENCY = '<%= current_currency %>'
|
14
|
-
</script>
|
11
|
+
<%= render 'spree/shared/locale_and_currency' %>
|
15
12
|
<%= javascript_include_tag 'spree/frontend/all', defer: true, 'data-turbolinks-track': 'reload' %>
|
16
13
|
<%= yield :head %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if should_render_locale_dropdown? %>
|
2
|
-
<%= form_tag spree.set_locale_path, method: :get, class: 'px-4 py-3 w-100
|
2
|
+
<%= form_tag spree.set_locale_path, method: :get, class: 'px-4 py-3 w-100 locale-select' do %>
|
3
3
|
<div class="form-group">
|
4
4
|
<label for="switch_to_locale" class="dropdown-header text-center">
|
5
5
|
<%= Spree.t('i18n.language') %>
|
@@ -10,5 +10,5 @@ CanonicalRails.setup do |config|
|
|
10
10
|
# Parameter spamming can cause index dilution by creating seemingly different URLs with identical or near-identical content.
|
11
11
|
# Unless whitelisted, these parameters will be omitted
|
12
12
|
|
13
|
-
config.allowed_parameters = [:keywords, :
|
13
|
+
config.allowed_parameters = [:keywords, :search, :taxon]
|
14
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_api
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 4.2.
|
20
|
+
version: 4.2.1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 4.2.
|
27
|
+
version: 4.2.1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: spree_core
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 4.2.
|
34
|
+
version: 4.2.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 4.2.
|
41
|
+
version: 4.2.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bootstrap
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -739,6 +739,7 @@ files:
|
|
739
739
|
- app/views/spree/shared/_line_item.html.erb
|
740
740
|
- app/views/spree/shared/_link_to_account.html.erb
|
741
741
|
- app/views/spree/shared/_link_to_cart.html.erb
|
742
|
+
- app/views/spree/shared/_locale_and_currency.html.erb
|
742
743
|
- app/views/spree/shared/_locale_dropdown.html.erb
|
743
744
|
- app/views/spree/shared/_login.html.erb
|
744
745
|
- app/views/spree/shared/_main_nav_bar.html.erb
|
@@ -792,9 +793,9 @@ licenses:
|
|
792
793
|
- BSD-3-Clause
|
793
794
|
metadata:
|
794
795
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
795
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.
|
796
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.1
|
796
797
|
documentation_uri: https://guides.spreecommerce.org/
|
797
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.2.
|
798
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.2.1
|
798
799
|
post_install_message:
|
799
800
|
rdoc_options: []
|
800
801
|
require_paths:
|
@@ -811,7 +812,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
811
812
|
version: '0'
|
812
813
|
requirements:
|
813
814
|
- none
|
814
|
-
rubygems_version: 3.
|
815
|
+
rubygems_version: 3.2.3
|
815
816
|
signing_key:
|
816
817
|
specification_version: 4
|
817
818
|
summary: Frontend e-commerce functionality for the Spree project.
|