effective_addresses 1.8.5 → 1.9.3
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 +5 -5
- data/app/helpers/effective_addresses_helper.rb +10 -5
- data/app/models/concerns/acts_as_addressable.rb +3 -1
- data/app/views/effective/addresses/_form_with.html.haml +1 -1
- data/app/views/effective/addresses/_formtastic.html.haml +2 -2
- data/app/views/effective/addresses/_simple_form.html.haml +1 -1
- data/app/views/effective/addresses/_subregions.html.haml +1 -1
- data/lib/effective_addresses.rb +0 -1
- data/lib/effective_addresses/engine.rb +3 -4
- data/lib/effective_addresses/version.rb +1 -1
- data/{app/models → lib}/validators/effective_address_full_name_presence_validator.rb +0 -0
- data/{app/models → lib}/validators/effective_address_valid_validator.rb +0 -0
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e41141e340c412a2e083dfb79792a86f102484fe61734eebf85963ba17c287c8
|
4
|
+
data.tar.gz: f0f60629f50f7f20e3e8ba6976e6ba9554b18ed6bb38870a4653ab1ad33b9c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934bf8000a28eb370e5f444d6f70610ea7b63f5c0d71c0e1da9f1ed0d83265b697b424489b732d2469e3a23edde57c603d11b2daf2aec9a4688635239e45ee4d
|
7
|
+
data.tar.gz: 170e98c482c1d99e3907864773762f487f0b61b0e5fc8399ffcac6c11f4d03655b547450d0c7a8ae856b97a7b13469bbe83f7a602ad8304b9ae32397f9f82179
|
@@ -37,7 +37,7 @@ module EffectiveAddressesHelper
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def effective_address_regions_collection(regions = nil)
|
40
|
+
def effective_address_regions_collection(regions = nil, resource: nil)
|
41
41
|
if regions.present?
|
42
42
|
countries = regions
|
43
43
|
elsif EffectiveAddresses.country_codes == :all
|
@@ -61,10 +61,15 @@ module EffectiveAddressesHelper
|
|
61
61
|
)
|
62
62
|
end
|
63
63
|
|
64
|
+
# Special behaviour if the address has CAN, we treat it as CA
|
65
|
+
if regions.blank? && resource.present? && resource.country_code == 'CAN'
|
66
|
+
ca = countries.index { |_, code| code == 'CA' }
|
67
|
+
|
68
|
+
if ca.present?
|
69
|
+
countries[ca] = ['Canada', 'CAN']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
64
73
|
countries
|
65
74
|
end
|
66
|
-
alias_method :effective_address_countries_collection, :effective_address_regions_collection
|
67
|
-
alias_method :region_options_for_simple_form_select, :effective_address_regions_collection
|
68
|
-
|
69
75
|
end
|
70
|
-
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ActsAsAddressable
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
module
|
6
|
+
module Base
|
7
7
|
def acts_as_addressable(*options)
|
8
8
|
@acts_as_addressable_opts = options || []
|
9
9
|
include ::ActsAsAddressable
|
@@ -91,6 +91,7 @@ module ActsAsAddressable
|
|
91
91
|
return effective_address(category) if address == effective_address(category)
|
92
92
|
|
93
93
|
(self.addresses.build).tap do |existing|
|
94
|
+
existing.addressable = self
|
94
95
|
existing.category = category.to_s
|
95
96
|
existing.full_name = address.full_name
|
96
97
|
existing.address1 = address.address1
|
@@ -117,6 +118,7 @@ module ActsAsAddressable
|
|
117
118
|
return effective_address(category) if address == effective_address(category)
|
118
119
|
|
119
120
|
(effective_address(category) || self.addresses.build).tap do |existing|
|
121
|
+
existing.addressable = self
|
120
122
|
existing.category = category.to_s
|
121
123
|
existing.full_name = address.full_name
|
122
124
|
existing.address1 = address.address1
|
@@ -29,7 +29,7 @@
|
|
29
29
|
:as => (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
30
30
|
:label => 'Country',
|
31
31
|
:prompt => 'Country...',
|
32
|
-
:collection =>
|
32
|
+
:collection => options_for_select(effective_address_regions_collection()),
|
33
33
|
:input_html => { 'data-effective-address-country' => uuid },
|
34
34
|
:input_js => { placeholder: 'Please choose' }
|
35
35
|
|
@@ -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 =>
|
41
|
+
:collection => options_for_select(effective_address_regions_collection(Carmen::Country.coded(fa.object.country_code).subregions)),
|
42
42
|
:prompt => 'please select a country',
|
43
43
|
:input_html => { 'data-effective-address-state' => uuid },
|
44
44
|
:input_js => { :placeholder => 'Please choose' }
|
@@ -41,7 +41,7 @@
|
|
41
41
|
= fa.input :country_code,
|
42
42
|
as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
43
43
|
required: required,
|
44
|
-
collection:
|
44
|
+
collection: effective_address_regions_collection(),
|
45
45
|
input_html: {'data-effective-address-country' => uuid},
|
46
46
|
disabled: shipping_address_same_as_billing,
|
47
47
|
wrapper_html: { style: ('display: none;' if shipping_address_same_as_billing) }
|
@@ -1 +1 @@
|
|
1
|
-
=
|
1
|
+
= options_for_select(effective_address_regions_collection(@subregions))
|
data/lib/effective_addresses.rb
CHANGED
@@ -2,13 +2,13 @@ module EffectiveAddresses
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
engine_name 'effective_addresses'
|
4
4
|
|
5
|
-
config.autoload_paths += Dir["#{config.root}/
|
6
|
-
config.
|
5
|
+
config.autoload_paths += Dir["#{config.root}/lib/validators"]
|
6
|
+
config.eager_load_paths += Dir["#{config.root}/lib/validators"]
|
7
7
|
|
8
8
|
# Include acts_as_addressable concern and allow any ActiveRecord object to call it
|
9
9
|
initializer 'effective_addresses.active_record' do |app|
|
10
10
|
ActiveSupport.on_load :active_record do
|
11
|
-
ActiveRecord::Base.extend(ActsAsAddressable::
|
11
|
+
ActiveRecord::Base.extend(ActsAsAddressable::Base)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -19,4 +19,3 @@ module EffectiveAddresses
|
|
19
19
|
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
File without changes
|
File without changes
|
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.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: carmen
|
28
|
+
name: carmen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -69,8 +69,6 @@ files:
|
|
69
69
|
- app/helpers/effective_addresses_helper.rb
|
70
70
|
- app/models/concerns/acts_as_addressable.rb
|
71
71
|
- app/models/effective/address.rb
|
72
|
-
- app/models/validators/effective_address_full_name_presence_validator.rb
|
73
|
-
- app/models/validators/effective_address_valid_validator.rb
|
74
72
|
- app/views/effective/addresses/_address.html.haml
|
75
73
|
- app/views/effective/addresses/_form_with.html.haml
|
76
74
|
- app/views/effective/addresses/_formtastic.html.haml
|
@@ -84,11 +82,13 @@ files:
|
|
84
82
|
- lib/effective_addresses/engine.rb
|
85
83
|
- lib/effective_addresses/version.rb
|
86
84
|
- lib/generators/effective_addresses/install_generator.rb
|
85
|
+
- lib/validators/effective_address_full_name_presence_validator.rb
|
86
|
+
- lib/validators/effective_address_valid_validator.rb
|
87
87
|
homepage: https://github.com/code-and-effect/effective_addresses
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata: {}
|
91
|
-
post_install_message:
|
91
|
+
post_install_message:
|
92
92
|
rdoc_options: []
|
93
93
|
require_paths:
|
94
94
|
- lib
|
@@ -103,9 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
107
|
-
|
108
|
-
signing_key:
|
106
|
+
rubygems_version: 3.1.2
|
107
|
+
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: Extend any ActiveRecord object to have one or more named addresses. Includes
|
111
110
|
a geographic region-aware custom form input backed by Carmen.
|