spree_frontend 4.2.0.rc2 → 4.2.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38163d04925f22790f12bdbbeb77beac79cdbd366c6ea04e065009b2fd9b82d1
4
- data.tar.gz: b53af71727410e46e99acbbf972e13580fb3c41977508e41125c6b5718c8bfc4
3
+ metadata.gz: 5f81a05d74462180d47969190cd9b0ba32eeb896e776706f89f288b1e52167d0
4
+ data.tar.gz: f0d37b65f1b4a1bef39162049cc07f7201a9ba5b7417114867530c2f86a61c23
5
5
  SHA512:
6
- metadata.gz: b8b342aa804b56453c2c7bc447cf52d664f097c16b04de44e5d0bd3c153314e9450806b167b3372b2483ebcd5ab312eac3c868ee6b852b03106aaa094e69794f
7
- data.tar.gz: 2c2d42c10cbbd8e2dedd374693255c9c24044c84dcf2a3e641fe0aa57cadfe3552134139af193c35cd78b4f9ba2749072803d78bfc67775a8c6a4ecddccf1f58
6
+ metadata.gz: caa243750a89dcb5ee49b389c30b1dda7594e2ce46cbb98d3c83c558c6af5af4e3dfc07f33b4fcca9f21bbb21af8dfef2a8a8b61264f1939a4ce262273045ae0
7
+ data.tar.gz: 5853f04c6518d154deaffa26eff36966fe4a8486076cbf1143c03974cabc3502a9134239a439d8537a5254bf9cb934743a5692ba4b8486fb19f900429d95a028
@@ -1,16 +1,24 @@
1
- Spree.ready(function ($) {
2
- Spree.onAddress = function () {
1
+ Spree.ready(function($) {
2
+ Spree.onAddress = function() {
3
3
  if ($('#checkout_form_address').length) {
4
- Spree.updateState = function (region) {
4
+ Spree.updateState = function(region) {
5
5
  var countryId = getCountryId(region)
6
6
  if (countryId != null) {
7
7
  if (Spree.Checkout[countryId] == null) {
8
8
  $.ajax({
9
- async: false, method: 'GET', url: Spree.pathFor('/api/v2/storefront/countries/' + countryId + '?include=states'), dataType: 'json'
10
- }).done(function (data) {
11
- var json = data.included; var xStates = []
9
+ async: false,
10
+ method: 'GET',
11
+ url: Spree.pathFor('/api/v2/storefront/countries/' + countryId + '?include=checkout_zone_applicable_states'),
12
+ dataType: 'json'
13
+ }).done(function(data) {
14
+ var json = data.included;
15
+ var xStates = [];
12
16
  for (var i = 0; i < json.length; i++) {
13
- var obj = json[i]; xStates.push({ 'id': obj.id, 'name': obj.attributes.name })
17
+ var obj = json[i];
18
+ xStates.push({
19
+ id: obj.id,
20
+ name: obj.attributes.name
21
+ })
14
22
  }
15
23
  Spree.Checkout[countryId] = {
16
24
  states: xStates,
@@ -27,7 +35,7 @@ Spree.ready(function ($) {
27
35
  }
28
36
  }
29
37
 
30
- Spree.toggleZipcode = function (data, region) {
38
+ Spree.toggleZipcode = function(data, region) {
31
39
  var requiredIndicator = $('span#required_marker').first().text()
32
40
  var zipcodeRequired = data.zipcode_required
33
41
  var zipcodePara = $('#' + region + 'zipcode')
@@ -49,7 +57,7 @@ Spree.ready(function ($) {
49
57
  }
50
58
  }
51
59
 
52
- Spree.fillStates = function (data, region) {
60
+ Spree.fillStates = function(data, region) {
53
61
  var selected
54
62
  var statesRequired = data.states_required
55
63
  var states = data.states
@@ -63,64 +71,72 @@ Spree.ready(function ($) {
63
71
  if (states.length > 0) {
64
72
  selected = parseInt(stateSelect.val())
65
73
  stateSelect.html('')
66
- $.each(states, function (idx, state) {
74
+ $.each(states, function(idx, state) {
67
75
  var opt = $(document.createElement('option')).attr('value', state.id).html(state.name)
68
76
  if (selected.toString(10) === state.id.toString(10)) {
69
77
  opt.prop('selected', true)
70
78
  }
71
79
  stateSelect.append(opt)
72
80
  })
73
- stateSelect.prop('required', false)
74
- stateSelect.prop('disabled', false).show()
75
- stateLabel.addClass('state-select-label')
76
- stateInput.hide().prop('disabled', true)
77
- statePara.show()
78
- stateSpanRequired.hide()
79
- stateSelect.removeClass('required')
81
+ // If States are listed for the Country selected kill the input field
82
+ stateInput.hide()
83
+ .prop('disabled', true)
84
+ .prop('required', false)
85
+ .val('')
80
86
 
81
- if (statesRequired) {
82
- stateSelect.addClass('required')
83
- stateSelectImg.show()
84
- stateSpanRequired.show()
85
- stateSelect.prop('required', true)
86
- }
87
- stateSelect.removeClass('hidden')
88
- stateInput.removeClass('required')
87
+ // Activate the State select dropdown.
88
+ statePara.show()
89
+ stateSelect.prop('required', statesRequired)
90
+ .prop('disabled', false)
91
+ .show()
92
+ stateSelectImg.show()
93
+ stateLabel.addClass('state-select-label')
94
+ stateSpanRequired.toggle(statesRequired)
89
95
  } else {
90
- stateSelect.hide().prop('disabled', true)
91
- stateLabel.removeClass('state-select-label')
96
+ // If no States are listed in the database for the country selected
97
+ // and a State is not required => (United Kingdom).
98
+ // Kill the State selector and input field.
92
99
  stateSelectImg.hide()
93
- stateInput.show()
100
+ stateSelect.hide()
101
+ .prop('disabled', true)
102
+ .prop('required', false)
103
+ .find('option').remove()
104
+
105
+ stateInput.prop('disabled', true)
106
+ .prop('required', false)
107
+ .hide()
108
+
109
+ // Toggle visibility of States parent element based on State required.
110
+ statePara.toggle(statesRequired)
111
+
94
112
  if (statesRequired) {
113
+ // If a State is required, but none are listed in the database
114
+ // for the country selected => (Hong Kong)
115
+ // Enable the State input field, set it to required.
116
+ stateInput.show()
117
+ .prop('disabled', false)
118
+ .prop('required', true)
95
119
  stateSpanRequired.show()
96
- stateLabel.removeClass('state-select-label')
97
- stateInput.addClass('required form-control')
98
- } else {
99
- stateInput.val('')
100
- stateSpanRequired.hide()
101
- stateInput.removeClass('required')
120
+ stateLabel.removeClass('state-select-label') // required for floating label
102
121
  }
103
- statePara.toggle(!!statesRequired)
104
- stateInput.prop('disabled', !statesRequired)
105
- stateInput.removeClass('hidden')
106
- stateSelect.removeClass('required')
107
122
  }
108
123
  }
109
- $('#bcountry select').change(function () {
124
+ $('#bcountry select').change(function() {
110
125
  Spree.updateState('b')
111
126
  })
112
- $('#scountry select').change(function () {
127
+ $('#scountry select').change(function() {
113
128
  Spree.updateState('s')
114
129
  })
115
130
  Spree.updateState('b')
116
131
 
117
132
  var orderUseBilling = $('input#order_use_billing')
118
- orderUseBilling.change(function () {
133
+ orderUseBilling.change(function() {
119
134
  updateShippingFormState(orderUseBilling)
120
135
  })
121
136
  updateShippingFormState(orderUseBilling)
122
137
  }
123
- function updateShippingFormState (orderUseBilling) {
138
+
139
+ function updateShippingFormState(orderUseBilling) {
124
140
  if (orderUseBilling.is(':checked')) {
125
141
  $('#shipping .inner').hide()
126
142
  $('#shipping .inner input, #shipping .inner select').prop('disabled', true)
@@ -130,7 +146,8 @@ Spree.ready(function ($) {
130
146
  Spree.updateState('s')
131
147
  }
132
148
  }
133
- function getCountryId (region) {
149
+
150
+ function getCountryId(region) {
134
151
  return $('#' + region + 'country select').val()
135
152
  }
136
153
  }
@@ -255,7 +255,7 @@ function CartForm($, $cartForm) {
255
255
 
256
256
  this.$price.html(variant.display_price)
257
257
 
258
- var compareAtPriceContent = shouldDisplayCompareAtPrice ? '<span class="mr-3">' + variant.display_compare_at_price + '</span>' : ''
258
+ var compareAtPriceContent = shouldDisplayCompareAtPrice ? variant.display_compare_at_price : ''
259
259
  this.$compareAtPrice.html(compareAtPriceContent)
260
260
  }
261
261
 
@@ -1,4 +1,5 @@
1
1
  $font-size-base-px: 16px; //assuming 16px is 1rem ($font-size-base: 1rem in Bootstrap 4)
2
+ $x1: null;
2
3
 
3
4
  @function font-px-to-rem($target-font-size-px: $font-size-base-px) {
4
5
  @return $font-size-base * ( $target-font-size-px / $font-size-base-px );
@@ -35,6 +35,5 @@ $grid-breakpoints: (
35
35
  $container-max-widths: (
36
36
  sm: 768px,
37
37
  md: 992px,
38
- lg: 1200px,
39
- xl: 1200px
38
+ lg: 1200px
40
39
  );
@@ -3,7 +3,7 @@ module Spree
3
3
  def set
4
4
  @currency = supported_currencies.find { |currency| currency.iso_code == params[:currency] }
5
5
  # Make sure that we update the current order, so the currency change is reflected.
6
- current_order&.update_attributes!(currency: @currency.iso_code)
6
+ current_order&.update(currency: @currency.iso_code)
7
7
  session[:currency] = params[:currency] if Spree::Config[:show_store_currency_selector]
8
8
  respond_to do |format|
9
9
  format.json { render json: !@currency.nil? }
@@ -16,7 +16,7 @@ module Spree
16
16
  def product_carousel
17
17
  if stale?(etag: carousel_etag, last_modified: last_modified, public: true)
18
18
  load_products
19
- if @products.any?
19
+ if @products.reload.any?
20
20
  render template: 'spree/taxons/product_carousel', layout: false
21
21
  else
22
22
  head :no_content
@@ -10,7 +10,7 @@ module Spree
10
10
  method_name = I18n.t("activerecord.attributes.spree/address.#{method}")
11
11
  required = Spree.t(:required)
12
12
  form.text_field(method,
13
- class: [is_required ? 'required' : nil, 'spree-flat-input'].compact,
13
+ class: ['spree-flat-input'].compact,
14
14
  required: is_required,
15
15
  placeholder: is_required ? "#{method_name} #{required}" : method_name,
16
16
  aria: { label: method_name }) +
@@ -27,7 +27,7 @@ module Spree
27
27
  method_name = Spree.t(:zipcode)
28
28
  required = Spree.t(:required)
29
29
  form.text_field(:zipcode,
30
- class: [is_required ? 'required' : nil, 'spree-flat-input'].compact,
30
+ class: ['spree-flat-input'].compact,
31
31
  required: is_required,
32
32
  placeholder: is_required ? "#{method_name} #{required}" : method_name,
33
33
  aria: { label: Spree.t(:zipcode) }) +
@@ -41,14 +41,14 @@ module Spree
41
41
  country ||= Spree::Country.find(Spree::Config[:default_country_id])
42
42
  have_states = country.states.any?
43
43
  state_elements = [
44
- form.collection_select(:state_id, country.states.order(:name),
44
+ form.collection_select(:state_id, checkout_zone_applicable_states_for(country).sort_by(&:name),
45
45
  :id, :name,
46
46
  { prompt: Spree.t(:state) },
47
- class: [have_states ? 'required' : 'hidden', 'spree-flat-select'].compact,
47
+ class: ['spree-flat-select'].compact,
48
48
  aria: { label: Spree.t(:state) },
49
49
  disabled: !have_states) +
50
50
  form.text_field(:state_name,
51
- class: [!have_states ? 'required' : 'hidden', 'spree-flat-input'].compact,
51
+ class: ['spree-flat-input'].compact,
52
52
  aria: { label: Spree.t(:state) },
53
53
  disabled: have_states,
54
54
  placeholder: Spree.t(:state) + " #{Spree.t(:required)}") +
@@ -60,7 +60,7 @@ module Spree
60
60
  class: [!have_states ? 'hidden' : nil, 'position-absolute spree-flat-select-arrow'].compact)
61
61
  ].join.tr('"', "'").delete("\n")
62
62
 
63
- content_tag(:noscript, form.text_field(:state_name, class: 'required')) +
63
+ content_tag(:noscript, form.text_field(:state_name)) +
64
64
  javascript_tag("document.write(\"<span class='d-block position-relative'>#{state_elements.html_safe}</span>\");")
65
65
  end
66
66
 
@@ -69,5 +69,9 @@ module Spree
69
69
 
70
70
  try_spree_current_user.addresses.where(country: available_countries)
71
71
  end
72
+
73
+ def checkout_zone_applicable_states_for(country)
74
+ current_store.states_available_for_checkout(country)
75
+ end
72
76
  end
73
77
  end
@@ -6,7 +6,7 @@
6
6
  <div id="<%= "#{address_id}country-selection" %>" class="d-block position-relative has-float-label">
7
7
  <%= address_form.collection_select :country_id, available_countries, :id, :name,
8
8
  { prompt: Spree.t(:country).upcase },
9
- { class: 'required form-control spree-flat-select',
9
+ { class: 'form-control spree-flat-select',
10
10
  aria: { label: Spree.t(:country) } } %>
11
11
  <%= image_tag 'arrow.svg', class: 'position-absolute spree-flat-select-arrow' %>
12
12
  <%= address_form.label(Spree.t(:country), Spree.t(:country).upcase, class:'text-uppercase') %>
@@ -28,11 +28,9 @@
28
28
  <div id="inside-product-cart-form" data-hook="inside_product_cart_form">
29
29
  <% if is_product_available_in_currency %>
30
30
  <div id="product-price" class="mb-2 text-center text-md-left add-to-cart-form-price" data-hook="product_price">
31
- <span class="compare-at-price">
32
- <% if should_display_compare_at_price %>
33
- <span class="mr-3"><%= display_compare_at_price(default_variant) %></span>
34
- <% end %>
35
- </span>
31
+ <% if should_display_compare_at_price %>
32
+ <span class="compare-at-price mr-3"><%= display_compare_at_price(default_variant) %></span>
33
+ <% end %>
36
34
  <span class="price selling" content="<%= @product_price.to_d %>">
37
35
  <%= display_price(default_variant) %>
38
36
  </span>
@@ -1,5 +1,5 @@
1
1
  <% if Spree::Config.show_store_currency_selector && stores.size > 1 %>
2
- <li class="change-store">
2
+ <li class="d-none d-xl-block change-store">
3
3
  <div class="dropdown navbar-right-dropdown">
4
4
  <button id="stores-button" type="button" data-toggle="dropdown" class="navbar-right-dropdown-toggle" aria-label="<%= Spree.t('nav_bar.change_country')%>">
5
5
  <%= icon(name: 'global',
@@ -41,8 +41,8 @@
41
41
  <% if current_store.contact_phone&.present? %>
42
42
  <div><%= Spree.t(:call_us_now) %><%= current_store.contact_phone %></div>
43
43
  <% end %>
44
- <% if current_store.contact_email&.present? %>
45
- <div><%= Spree.t(:email) %>: <%= current_store.contact_email %></div>
44
+ <% if current_store.customer_support_email&.present? %>
45
+ <div><%= Spree.t(:email) %>: <%= current_store.customer_support_email %></div>
46
46
  <% end %>
47
47
  </div>
48
48
  </div>
@@ -9,7 +9,7 @@
9
9
  <%= "#{address.address1} #{address.address2}" %>,
10
10
  </div>
11
11
  <div>
12
- <%= "#{address.city}, #{address.state&.abbr} #{address.zipcode}" %>,
12
+ <%= "#{address.city}, #{address.state_text} #{address.zipcode}" %>,
13
13
  </div>
14
14
  <div>
15
15
  <%= address.country.name %>
@@ -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.whitelisted_parameters = [:keywords, :page, :search, :taxon]
13
+ config.allowed_parameters = [:keywords, :page, :search, :taxon]
14
14
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
 
31
31
  s.add_dependency 'bootstrap', '>= 4.3.1', '< 4.6.0'
32
32
  s.add_dependency 'glyphicons', '~> 1.0.2'
33
- s.add_dependency 'canonical-rails', '~> 0.2.5'
33
+ s.add_dependency 'canonical-rails', '~> 0.2.10'
34
34
  s.add_dependency 'inline_svg', '~> 1.5'
35
35
  s.add_dependency 'jquery-rails', '~> 4.3'
36
36
  s.add_dependency 'turbolinks', '~> 5.2.0'
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.0.rc2
4
+ version: 4.2.0.rc3
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: 2020-11-10 00:00:00.000000000 Z
12
+ date: 2021-01-18 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.0.rc2
20
+ version: 4.2.0.rc3
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.0.rc2
27
+ version: 4.2.0.rc3
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.0.rc2
34
+ version: 4.2.0.rc3
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.0.rc2
41
+ version: 4.2.0.rc3
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bootstrap
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -79,14 +79,14 @@ dependencies:
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.5
82
+ version: 0.2.10
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.2.5
89
+ version: 0.2.10
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: inline_svg
92
92
  requirement: !ruby/object:Gem::Requirement
@@ -783,9 +783,9 @@ licenses:
783
783
  - BSD-3-Clause
784
784
  metadata:
785
785
  bug_tracker_uri: https://github.com/spree/spree/issues
786
- changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.rc2
786
+ changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.rc3
787
787
  documentation_uri: https://guides.spreecommerce.org/
788
- source_code_uri: https://github.com/spree/spree/tree/v4.2.0.rc2
788
+ source_code_uri: https://github.com/spree/spree/tree/v4.2.0.rc3
789
789
  post_install_message:
790
790
  rdoc_options: []
791
791
  require_paths:
@@ -802,7 +802,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
802
802
  version: 1.3.1
803
803
  requirements:
804
804
  - none
805
- rubygems_version: 3.1.2
805
+ rubygems_version: 3.1.4
806
806
  signing_key:
807
807
  specification_version: 4
808
808
  summary: Frontend e-commerce functionality for the Spree project.