effective_addresses 1.9.6 → 1.9.9
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/helpers/effective_addresses_helper.rb +8 -6
- data/app/models/concerns/acts_as_addressable.rb +2 -0
- data/app/models/effective/address.rb +2 -0
- data/app/views/effective/addresses/_form_with.html.haml +4 -2
- data/app/views/effective/addresses/_formtastic.html.haml +1 -1
- data/app/views/effective/addresses/_simple_form.html.haml +1 -1
- data/config/routes.rb +2 -0
- 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: fd974c66e5bcdc5eaa644505a3cdc1dcad2aaa54de34597bb81d1bdef2c403f9
|
|
4
|
+
data.tar.gz: 215d02c276840271457e6322d979abb53ad27c996af3e748466d16fbed3c8179
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d365f1068f255e29cf975e5e88877519eb600c1238a5d53e85bd8a0a0411721f3e80d2c5d4af7770dd9dab34110b732d0826b7ca40d2be627ce37c35921c4f42
|
|
7
|
+
data.tar.gz: 2ccb92180c02b9ddd9251d8262d476845079c92ced8e475f2247015037009760925958d68fab710b81f5c8cd2f2fef912d3e2c2c8457e79bcc5400beb297a1ba
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module EffectiveAddressesHelper
|
|
2
4
|
def effective_address_fields(form, method = 'billing', options = {})
|
|
3
5
|
method = (method.to_s.include?('_address') ? method.to_s : "#{method}_address")
|
|
@@ -23,8 +25,8 @@ module EffectiveAddressesHelper
|
|
|
23
25
|
|
|
24
26
|
def effective_address_pre_select(address)
|
|
25
27
|
if EffectiveAddresses.pre_selected_country.present?
|
|
26
|
-
address.country
|
|
27
|
-
address.state
|
|
28
|
+
address.country ||= EffectiveAddresses.pre_selected_country
|
|
29
|
+
address.state ||= EffectiveAddresses.pre_selected_state if EffectiveAddresses.pre_selected_state.present?
|
|
28
30
|
elsif defined?(Geocoder) && request.location.present?
|
|
29
31
|
location = request.location
|
|
30
32
|
address.country = location.country_code
|
|
@@ -35,12 +37,12 @@ module EffectiveAddressesHelper
|
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def effective_address_regions_collection(regions = nil, resource: nil)
|
|
38
|
-
if regions.present?
|
|
39
|
-
|
|
40
|
+
countries = if regions.present?
|
|
41
|
+
regions
|
|
40
42
|
elsif EffectiveAddresses.country_codes == :all
|
|
41
|
-
|
|
43
|
+
Carmen::Country.all
|
|
42
44
|
else
|
|
43
|
-
|
|
45
|
+
Carmen::Country.all.select { |c| (EffectiveAddresses.country_codes || []).include?(c.code) }
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
if regions.blank? && EffectiveAddresses.country_codes_priority.present?
|
|
@@ -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,
|
|
@@ -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' }
|
|
@@ -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' },
|
data/config/routes.rb
CHANGED
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.9
|
|
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:
|
|
11
|
+
date: 2022-04-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|