effective_addresses 1.9.5 → 1.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/app/helpers/effective_addresses_helper.rb +1 -2
- data/app/models/concerns/acts_as_addressable.rb +8 -7
- 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 -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: 46461b09d7aa12fd73789e0d29640bac574d2b7295bb68ce8568cc64c0b52f30
|
4
|
+
data.tar.gz: 00b4f0c30fedc4ddaa7cf8a700a221768ad077322846494093850a575bf45d11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fb5fb6857f90e57e50fe17e4f28aa27732fb932dd57a9287041a8afb25b63ada63c6c8d870871026c4bbb51067b8ea6de7b33b68e6634a6c90141706358adc1
|
7
|
+
data.tar.gz: 61324d4eecfa40edc2c3b5cfc2957d59d96463e5bb3f55b2ad7d339a67c7cde1f849f4882f4167910311a6fc6e9788470015ce2acaa8b6edfaa96fa6fc080814
|
data/README.md
CHANGED
@@ -89,7 +89,7 @@ or
|
|
89
89
|
|
90
90
|
```ruby
|
91
91
|
class User
|
92
|
-
acts_as_addressable :billing => {:presence => true
|
92
|
+
acts_as_addressable :billing => {:presence => true}
|
93
93
|
end
|
94
94
|
```
|
95
95
|
|
@@ -110,11 +110,7 @@ This means when a User is created, it will not be valid unless a billing_address
|
|
110
110
|
|
111
111
|
Sometimes you want to collect a `full_name` field with your addresses, such as in the case of a mailing address; other times, it's an unnecessary field.
|
112
112
|
|
113
|
-
When you specify the config option `config.use_full_name = true` all `
|
114
|
-
|
115
|
-
This can be overridden on a per-address basis when declared in the model.
|
116
|
-
|
117
|
-
When `use_full_name == true`, any calls to `effective_address_fields` form helper will display the full_name input, and the model will `validate_presence_of :full_name`.
|
113
|
+
When you specify the config option `config.use_full_name = true` all, any calls to `effective_address_fields` form helper will display the full_name input, and the model will `validate_presence_of :full_name`.
|
118
114
|
|
119
115
|
|
120
116
|
### Address Validations
|
@@ -3,12 +3,11 @@ module EffectiveAddressesHelper
|
|
3
3
|
method = (method.to_s.include?('_address') ? method.to_s : "#{method}_address")
|
4
4
|
|
5
5
|
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)
|
6
|
-
use_full_name = form.object._validators[method.to_sym].any? { |v| v.kind_of?(EffectiveAddressFullNamePresenceValidator) }
|
7
6
|
|
8
7
|
address = form.object.send(method) || form.object.addresses.build(category: method.to_s.gsub('_address', ''))
|
9
8
|
effective_address_pre_select(address) if address.new_record?
|
10
9
|
|
11
|
-
opts = { required: required,
|
10
|
+
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})
|
12
11
|
|
13
12
|
case form.class.name
|
14
13
|
when 'Effective::FormBuilder'
|
@@ -23,7 +23,7 @@ module ActsAsAddressable
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Categories can be either:
|
26
|
-
# {'billing'=>{:singular=>true
|
26
|
+
# {'billing'=>{:singular=>true}, 'shipping'=>{:singular=>true}}
|
27
27
|
# or
|
28
28
|
# {'billing' => true, 'shipping' => true}
|
29
29
|
# or
|
@@ -46,11 +46,13 @@ module ActsAsAddressable
|
|
46
46
|
|
47
47
|
case options
|
48
48
|
when Hash
|
49
|
-
validates
|
50
|
-
validates
|
51
|
-
when TrueClass
|
52
|
-
validates "#{category}_address", presence:
|
53
|
-
validates "#{category}_address", effective_address_full_name_presence: EffectiveAddresses.use_full_name
|
49
|
+
validates("#{category}_address", presence: true) if options[:presence]
|
50
|
+
validates("#{category}_address", effective_address_full_name_presence: true) if options[:use_full_name]
|
51
|
+
when TrueClass
|
52
|
+
validates "#{category}_address", presence: true
|
53
|
+
validates "#{category}_address", effective_address_full_name_presence: true, if: -> { EffectiveAddresses.use_full_name }
|
54
|
+
when FalseClass
|
55
|
+
# Nothing to do
|
54
56
|
else
|
55
57
|
raise 'Unexpected options. Expected a Hash or Boolean'
|
56
58
|
end
|
@@ -133,4 +135,3 @@ module ActsAsAddressable
|
|
133
135
|
end
|
134
136
|
|
135
137
|
end
|
136
|
-
|
@@ -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 use_full_name || fa.object.errors.include?(:full_name)
|
11
|
+
- if 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 use_full_name || fa.object.errors.include?(:full_name)
|
12
|
+
- if 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 use_full_name || fa.object.errors.include?(:full_name)
|
13
|
+
- if 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,
|
@@ -81,4 +81,3 @@
|
|
81
81
|
label: 'Shipping address is same as billing address',
|
82
82
|
required: false,
|
83
83
|
input_html: { checked: shipping_address_same_as_billing }
|
84
|
-
|
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.6
|
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: 2021-10-
|
11
|
+
date: 2021-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|