effective_addresses 1.9.9 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_addresses_helper.rb +12 -4
- data/app/models/effective/address.rb +2 -1
- data/app/views/effective/addresses/_address.html.haml +1 -1
- data/app/views/effective/addresses/_form_with.html.haml +1 -1
- data/app/views/effective/addresses/_formtastic.html.haml +1 -1
- data/app/views/effective/addresses/_simple_form.html.haml +1 -1
- data/lib/effective_addresses/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eb87bcd5e2d0b539e5dc27eaaffda71ac6bae2c95742fbdd75269160ada6a32
|
4
|
+
data.tar.gz: c86451bdef0b5dc667ee0221ec10600bfcd5fd846ace0fbcfb3c5c6d2e4aa5b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6697c436d4d56e8e4b4454c4c3027247468fa59d9cf49572360b7a56d9fec28311c671c6af9f5d70196bac13a43f7b5e9f07c3cef68fbbb99be0c709ddb0faf
|
7
|
+
data.tar.gz: 47b035caafa985f7eec3b448329ac4b1ddbab54b9699ff9072f13bfc8abe4b333e59a1c3ff4b80794734012d9f68a26aca5df97bb81a1aadd99b1d99da67465e
|
@@ -7,6 +7,7 @@ module EffectiveAddressesHelper
|
|
7
7
|
required = (form.object._validators[method.to_sym].any? { |v| v.kind_of?(ActiveRecord::Validations::PresenceValidator) && (v.options[:if].blank? || (v.options[:if].respond_to?(:call) ? f.object.instance_exec(&v.options[:if]) : v.options[:if])) } rescue true)
|
8
8
|
|
9
9
|
address = form.object.send(method) || form.object.addresses.build(category: method.to_s.gsub('_address', ''))
|
10
|
+
|
10
11
|
effective_address_pre_select(address) if address.new_record?
|
11
12
|
|
12
13
|
opts = { required: required, field_order: [:full_name, :address1, :address2, :city, :country_code, :state_code, :postal_code] }.merge(options).merge({:f => form, :address => address, :method => method})
|
@@ -24,16 +25,23 @@ module EffectiveAddressesHelper
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def effective_address_pre_select(address)
|
27
|
-
if EffectiveAddresses.pre_selected_country.present?
|
28
|
-
address.country
|
29
|
-
|
30
|
-
|
28
|
+
if address.country.blank? && EffectiveAddresses.pre_selected_country.present?
|
29
|
+
address.country = EffectiveAddresses.pre_selected_country
|
30
|
+
end
|
31
|
+
|
32
|
+
if address.state.blank? && EffectiveAddresses.pre_selected_state.present?
|
33
|
+
address.state = EffectiveAddresses.pre_selected_state
|
34
|
+
end
|
35
|
+
|
36
|
+
if defined?(Geocoder) && request.try(:location).present?
|
31
37
|
location = request.location
|
32
38
|
address.country = location.country_code
|
33
39
|
address.state = location.state_code
|
34
40
|
address.postal_code = location.postal_code
|
35
41
|
address.city = location.city
|
36
42
|
end
|
43
|
+
|
44
|
+
address
|
37
45
|
end
|
38
46
|
|
39
47
|
def effective_address_regions_collection(regions = nil, resource: nil)
|
@@ -6,7 +6,7 @@ module Effective
|
|
6
6
|
attr_accessor :shipping_address_same_as_billing
|
7
7
|
|
8
8
|
POSTAL_CODE_CA = /\A[A-Z]{1}\d{1}[A-Z]{1}\ \d{1}[A-Z]{1}\d{1}\z/ # Matches 'T5Z 2B1'
|
9
|
-
POSTAL_CODE_US = /\A\d{5}
|
9
|
+
POSTAL_CODE_US = /\A\d{5}(-\d{4})?\z/ # matches 5 digits plus optional hyphen and 4 digits
|
10
10
|
|
11
11
|
belongs_to :addressable, polymorphic: true, touch: true
|
12
12
|
|
@@ -93,6 +93,7 @@ module Effective
|
|
93
93
|
code = code.insert(3, ' ') if code.length == 6
|
94
94
|
elsif country_code == 'US'
|
95
95
|
code = code.gsub(/[^0-9]/, '')
|
96
|
+
code = code.insert(5, '-') if code.length == 9
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
- if ((f.object.errors.include?(method) && !f.object.errors.include?(:addresses)) rescue false)
|
9
9
|
= f.errors method
|
10
10
|
|
11
|
-
- if EffectiveAddresses.use_full_name || fa.object.errors.include?(:full_name)
|
11
|
+
- if local_assigns[:use_full_name] || EffectiveAddresses.use_full_name || fa.object.errors.include?(:full_name)
|
12
12
|
= fa.text_field :full_name,
|
13
13
|
required: required,
|
14
14
|
disabled: same_as_billing,
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
- case field
|
11
11
|
- when :full_name
|
12
|
-
- if EffectiveAddresses.use_full_name || fa.object.errors.include?(:full_name)
|
12
|
+
- if local_assigns[:use_full_name] || EffectiveAddresses.use_full_name || fa.object.errors.include?(:full_name)
|
13
13
|
= fa.input :full_name, :required => true, :label => 'Full name', :placeholder => 'Full name'
|
14
14
|
|
15
15
|
- when :address1
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
- case field
|
12
12
|
- when :full_name
|
13
|
-
- if EffectiveAddresses.use_full_name || fa.object.errors.include?(:full_name)
|
13
|
+
- if local_assigns[:use_full_name] || EffectiveAddresses.use_full_name || fa.object.errors.include?(:full_name)
|
14
14
|
= fa.input :full_name,
|
15
15
|
required: required,
|
16
16
|
disabled: shipping_address_same_as_billing,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_addresses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|