effective_addresses 1.8.6 → 1.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/app/helpers/effective_addresses_helper.rb +11 -8
- data/app/models/concerns/acts_as_addressable.rb +1 -1
- data/app/models/effective/address.rb +14 -16
- 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 +19 -15
- 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 +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903de54494687e66176870441f7dbf08122086a9d1de3dae3a38da0cbd2cca99
|
4
|
+
data.tar.gz: 8535f034cd7392a7f9ee711386248618f2b8d647784e30dfc4fc726220ec55c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0601a1e879b7cdce8604dd836bd4d80bbca09c1606ff68523ef591b07925ad9b5aba9c679a060a82b7cc5b3e16fa8f2bd0a9a4301ca4e1ab399d9c610ee81b94
|
7
|
+
data.tar.gz: 0fc12952f62102c4f792a4c25f380daec74a862a5a6a1fab39edd1a2546d11aa44442ea41c60318b64d3773e4a1adb965e767f5b18ed6c50c079f0b8e29f0b45
|
data/MIT-LICENSE
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
module EffectiveAddressesHelper
|
2
|
-
@@use_geocoder = defined?(Geocoder)
|
3
|
-
|
4
2
|
def effective_address_fields(form, method = 'billing', options = {})
|
5
3
|
method = (method.to_s.include?('_address') ? method.to_s : "#{method}_address")
|
6
4
|
|
@@ -28,7 +26,7 @@ module EffectiveAddressesHelper
|
|
28
26
|
if EffectiveAddresses.pre_selected_country.present?
|
29
27
|
address.country = EffectiveAddresses.pre_selected_country
|
30
28
|
address.state = EffectiveAddresses.pre_selected_state if EffectiveAddresses.pre_selected_state.present?
|
31
|
-
elsif
|
29
|
+
elsif defined?(Geocoder) && request.location.present?
|
32
30
|
location = request.location
|
33
31
|
address.country = location.country_code
|
34
32
|
address.state = location.state_code
|
@@ -37,7 +35,7 @@ module EffectiveAddressesHelper
|
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
|
-
def effective_address_regions_collection(regions = nil)
|
38
|
+
def effective_address_regions_collection(regions = nil, resource: nil)
|
41
39
|
if regions.present?
|
42
40
|
countries = regions
|
43
41
|
elsif EffectiveAddresses.country_codes == :all
|
@@ -61,10 +59,15 @@ module EffectiveAddressesHelper
|
|
61
59
|
)
|
62
60
|
end
|
63
61
|
|
62
|
+
# Special behaviour if the address has CAN, we treat it as CA
|
63
|
+
if regions.blank? && resource.present? && resource.country_code == 'CAN'
|
64
|
+
ca = countries.index { |_, code| code == 'CA' }
|
65
|
+
|
66
|
+
if ca.present?
|
67
|
+
countries[ca] = ['Canada', 'CAN']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
64
71
|
countries
|
65
72
|
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
73
|
end
|
70
|
-
|
@@ -8,27 +8,25 @@ module Effective
|
|
8
8
|
|
9
9
|
belongs_to :addressable, polymorphic: true, touch: true
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
category :string
|
11
|
+
effective_resource do
|
12
|
+
category :string
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
full_name :string
|
15
|
+
address1 :string
|
16
|
+
address2 :string
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
if EffectiveAddresses.use_address3
|
19
|
+
address3 :string
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
city :string
|
23
|
+
state_code :string
|
24
|
+
country_code :string
|
25
|
+
postal_code :string
|
27
26
|
|
28
|
-
|
27
|
+
shipping_address_same_as_billing permitted: true
|
29
28
|
|
30
|
-
|
31
|
-
end
|
29
|
+
timestamps
|
32
30
|
end
|
33
31
|
|
34
32
|
validates :category, :address1, :city, :country_code, :postal_code, presence: true, if: Proc.new { |address| address.present? }
|
@@ -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
@@ -1,27 +1,31 @@
|
|
1
1
|
require 'carmen'
|
2
|
-
require '
|
2
|
+
require 'effective_resources'
|
3
3
|
require 'effective_addresses/engine'
|
4
4
|
require 'effective_addresses/version'
|
5
5
|
|
6
6
|
module EffectiveAddresses
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
yield self
|
8
|
+
def self.config_keys
|
9
|
+
[
|
10
|
+
:addresses_table_name,
|
11
|
+
:country_codes,
|
12
|
+
:country_codes_priority,
|
13
|
+
:use_full_name,
|
14
|
+
:use_address3,
|
15
|
+
:simple_form_options,
|
16
|
+
:validate_postal_code_format,
|
17
|
+
:pre_selected_country,
|
18
|
+
:pre_selected_state
|
19
|
+
]
|
21
20
|
end
|
22
21
|
|
22
|
+
include EffectiveGem
|
23
|
+
|
23
24
|
def self.permitted_params
|
24
|
-
[
|
25
|
+
[
|
26
|
+
:address1, :address2, :address3, :city, :country_code, :state_code, :postal_code,
|
27
|
+
:full_name, :shipping_address_same_as_billing
|
28
|
+
]
|
25
29
|
end
|
26
30
|
|
27
31
|
end
|
@@ -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.4
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -25,7 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: effective_resources
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: carmen
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -69,8 +83,6 @@ files:
|
|
69
83
|
- app/helpers/effective_addresses_helper.rb
|
70
84
|
- app/models/concerns/acts_as_addressable.rb
|
71
85
|
- 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
86
|
- app/views/effective/addresses/_address.html.haml
|
75
87
|
- app/views/effective/addresses/_form_with.html.haml
|
76
88
|
- app/views/effective/addresses/_formtastic.html.haml
|
@@ -84,11 +96,13 @@ files:
|
|
84
96
|
- lib/effective_addresses/engine.rb
|
85
97
|
- lib/effective_addresses/version.rb
|
86
98
|
- lib/generators/effective_addresses/install_generator.rb
|
99
|
+
- lib/validators/effective_address_full_name_presence_validator.rb
|
100
|
+
- lib/validators/effective_address_valid_validator.rb
|
87
101
|
homepage: https://github.com/code-and-effect/effective_addresses
|
88
102
|
licenses:
|
89
103
|
- MIT
|
90
104
|
metadata: {}
|
91
|
-
post_install_message:
|
105
|
+
post_install_message:
|
92
106
|
rdoc_options: []
|
93
107
|
require_paths:
|
94
108
|
- lib
|
@@ -103,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
117
|
- !ruby/object:Gem::Version
|
104
118
|
version: '0'
|
105
119
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
107
|
-
signing_key:
|
120
|
+
rubygems_version: 3.1.2
|
121
|
+
signing_key:
|
108
122
|
specification_version: 4
|
109
123
|
summary: Extend any ActiveRecord object to have one or more named addresses. Includes
|
110
124
|
a geographic region-aware custom form input backed by Carmen.
|