effective_addresses 1.9.8 → 1.9.11
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 +16 -8
- data/app/views/effective/addresses/_address.html.haml +1 -1
- data/app/views/effective/addresses/_form_with.html.haml +5 -3
- data/app/views/effective/addresses/_formtastic.html.haml +2 -2
- data/app/views/effective/addresses/_simple_form.html.haml +2 -2
- 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: 314234d1308d0c4490e47e3ea34cfcb3f040aa8fd6058324aa7632d2814c2a75
|
4
|
+
data.tar.gz: 1d4483aa861846e02ba59267b011b34bdf079eef4b68a9f47492a963935b186c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0809850d34e59c7a5314fa15ad4a5148ebdd6f00adac0ce55ba22ca322f485c221e1c20a771cf506c2edbc2bbd9d8d823555943293bba5cfbdbb312ba82ee91
|
7
|
+
data.tar.gz: 77a1f4d3dc70584ef8e5ed1cf1405f07249a47547a1bdb5da8df61656ebcd90d8484f5cc06a34fa17fc305cc12eba147edbcb9cb6e2776424a78cec885ddd06f
|
@@ -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,25 +25,32 @@ 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)
|
40
|
-
if regions.present?
|
41
|
-
|
48
|
+
countries = if regions.present?
|
49
|
+
regions
|
42
50
|
elsif EffectiveAddresses.country_codes == :all
|
43
|
-
|
51
|
+
Carmen::Country.all
|
44
52
|
else
|
45
|
-
|
53
|
+
Carmen::Country.all.select { |c| (EffectiveAddresses.country_codes || []).include?(c.code) }
|
46
54
|
end
|
47
55
|
|
48
56
|
if regions.blank? && EffectiveAddresses.country_codes_priority.present?
|
@@ -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,
|
@@ -49,8 +49,10 @@
|
|
49
49
|
wrapper: wrapper_options
|
50
50
|
|
51
51
|
.col-md-5
|
52
|
-
-
|
53
|
-
|
52
|
+
- subregions = Carmen::Country.coded(fa.object.country_code).try(:subregions) if fa.object.country_code.present?
|
53
|
+
|
54
|
+
- if subregions.present?
|
55
|
+
= fa.select :state_code, effective_address_regions_collection(subregions),
|
54
56
|
label: 'State / Province',
|
55
57
|
required: required,
|
56
58
|
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
|
@@ -38,7 +38,7 @@
|
|
38
38
|
= fa.input :state_code,
|
39
39
|
:as => (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
40
40
|
:label => 'Province / State',
|
41
|
-
:collection => options_for_select(effective_address_regions_collection(Carmen::Country.coded(fa.object.country_code).subregions)),
|
41
|
+
:collection => options_for_select(effective_address_regions_collection(Carmen::Country.coded(fa.object.country_code).try(:subregions))),
|
42
42
|
:prompt => 'please select a country',
|
43
43
|
:input_html => { 'data-effective-address-state' => uuid },
|
44
44
|
:input_js => { :placeholder => 'Please choose' }
|
@@ -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,
|
@@ -51,7 +51,7 @@
|
|
51
51
|
= fa.input :state_code,
|
52
52
|
as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
53
53
|
required: required,
|
54
|
-
collection: effective_address_regions_collection(Carmen::Country.coded(fa.object.country_code).subregions),
|
54
|
+
collection: effective_address_regions_collection(Carmen::Country.coded(fa.object.country_code).try(:subregions)),
|
55
55
|
prompt: 'Please choose',
|
56
56
|
input_html: {'data-effective-address-state' => uuid},
|
57
57
|
input_js: { placeholder: 'Please choose' },
|
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.9.
|
4
|
+
version: 1.9.11
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|