effective_addresses 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_addresses/address_fields.js.coffee +18 -2
- data/app/models/concerns/acts_as_addressable.rb +3 -1
- data/app/views/effective/addresses/_address_fields_formtastic.html.haml +13 -6
- data/app/views/effective/addresses/_address_fields_simple_form.html.haml +24 -7
- data/lib/effective_addresses/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ade1e6d3f8bf4f00965f7a1c3c98971538ed7b7e
|
4
|
+
data.tar.gz: 26251527f1b9a46efe20d0756b7c9eeb6cbc5c8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e935a846ef87ea09701d19bf05f191929d745a8d76cab0fca80e2e7f8b29ec03eb51e1a545900090ec5dea63aa00909d020b23ec6dea27c02abeb33be31939
|
7
|
+
data.tar.gz: 5a0ce0fdbc852880d554512eab90177ab177926cb077ea69931e5c6f463c49ff4f6bfd56b2440054feac6c3e7020e8bf0be71f8c77ba394c395ff8feb5faff5b
|
@@ -18,17 +18,33 @@ loadSubregions = ($countrySelect, clearPostalCode = false) ->
|
|
18
18
|
|
19
19
|
if countryCode.length == 0
|
20
20
|
$stateSelect.prop('disabled', true).addClass('disabled').parent('.form-group').addClass('disabled').find('label').addClass('disabled')
|
21
|
-
$stateSelect
|
21
|
+
reinitialize($stateSelect, 'Please choose a country first')
|
22
22
|
else
|
23
23
|
$stateSelect.removeAttr('disabled').parent('.form-group').removeClass('disabled').find('.disabled').removeClass('disabled')
|
24
|
-
$stateSelect
|
24
|
+
reinitialize($stateSelect, 'Loading...')
|
25
|
+
|
25
26
|
$stateSelect.load url, ->
|
26
27
|
stateSelectAvailable = $(@).find('option:last').val().length > 0
|
27
28
|
if stateSelectAvailable
|
28
29
|
$(@).prop('required', true)
|
29
30
|
$(@).removeAttr('disabled')
|
31
|
+
reinitialize($stateSelect, 'Please choose', true)
|
30
32
|
else
|
31
33
|
$(@).removeAttr('required')
|
32
34
|
$(@).prop('disabled', true)
|
35
|
+
reinitialize($stateSelect, 'None exist', true)
|
33
36
|
|
34
37
|
$(document).on 'change', 'select[data-effective-address-country]', -> loadSubregions($(@), true)
|
38
|
+
|
39
|
+
reinitialize = ($stateSelect, placeholder, keepOptions = false) ->
|
40
|
+
if $stateSelect.hasClass('effective_select') == false
|
41
|
+
$stateSelect.html("<option value=''>#{placeholder}</option>") unless keepOptions
|
42
|
+
return
|
43
|
+
|
44
|
+
$stateSelect.html('') unless keepOptions
|
45
|
+
|
46
|
+
opts = $stateSelect.data('input-js-options')
|
47
|
+
opts['placeholder'] = placeholder
|
48
|
+
$stateSelect.data('input-js-options', opts)
|
49
|
+
|
50
|
+
$stateSelect.select2().trigger('select2:reinitialize')
|
@@ -72,7 +72,9 @@ module ActsAsAddressable
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def set_effective_address(category, atts)
|
75
|
-
|
75
|
+
unless (atts.kind_of?(Effective::Address) || atts.kind_of?(Hash) || atts == nil)
|
76
|
+
raise ArgumentError.new("Effective::Address #{category}_address= expecting an Effective::Address or Hash of attributes")
|
77
|
+
end
|
76
78
|
|
77
79
|
atts = HashWithIndifferentAccess.new(atts.kind_of?(Effective::Address) ? atts.attributes : atts)
|
78
80
|
|
@@ -23,23 +23,30 @@
|
|
23
23
|
|
24
24
|
- when :country_code
|
25
25
|
= fa.input :country_code,
|
26
|
-
:as => :select,
|
26
|
+
:as => (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
27
27
|
:label => 'Country',
|
28
28
|
:prompt => 'Country...',
|
29
29
|
:collection => region_options_for_select(EffectiveAddresses.country_codes == :all ? Carmen::Country.all : Carmen::Country.all.select{ |c| EffectiveAddresses.country_codes.include?(c.code) rescue true}, fa.object.country_code, :priority => EffectiveAddresses.country_codes_priority),
|
30
|
-
:input_html => { 'data-effective-address-country' => uuid }
|
30
|
+
:input_html => { 'data-effective-address-country' => uuid },
|
31
|
+
:input_js => { placeholder: 'Please choose' }
|
31
32
|
|
32
33
|
- when :state_code
|
33
34
|
- if fa.object.country_code.present?
|
34
|
-
= fa.input :state_code,
|
35
|
+
= fa.input :state_code,
|
36
|
+
:as => (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
37
|
+
:label => 'Province / State',
|
35
38
|
:collection => region_options_for_select(Carmen::Country.coded(fa.object.country_code).subregions, fa.object.state_code),
|
36
39
|
:prompt => 'please select a country',
|
37
|
-
:input_html => { 'data-effective-address-state' => uuid }
|
40
|
+
:input_html => { 'data-effective-address-state' => uuid },
|
41
|
+
:input_js => { :placeholder => 'Please choose' }
|
38
42
|
- else
|
39
|
-
= fa.input :state_code,
|
43
|
+
= fa.input :state_code,
|
44
|
+
:as => (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
45
|
+
:label => 'Province / State',
|
40
46
|
:collection => [],
|
41
47
|
:prompt => 'please select a country',
|
42
|
-
:input_html => {:disabled => 'disabled', 'data-effective-address-state' => uuid}
|
48
|
+
:input_html => {:disabled => 'disabled', 'data-effective-address-state' => uuid},
|
49
|
+
:input_js => { :placeholder => 'Please choose a country first' }
|
43
50
|
|
44
51
|
- when :postal_code
|
45
52
|
= fa.input :postal_code, :label => 'Postal / Zip code', :placeholder => 'Postal / Zip code'
|
@@ -10,25 +10,42 @@
|
|
10
10
|
- case field
|
11
11
|
- when :full_name
|
12
12
|
- if use_full_name || fa.object.errors.include?(:full_name)
|
13
|
-
= fa.input :full_name, :
|
13
|
+
= fa.input :full_name, required: required
|
14
14
|
|
15
15
|
- when :address1
|
16
|
-
= fa.input :address1, :
|
16
|
+
= fa.input :address1, required: required
|
17
17
|
|
18
18
|
- when :address2
|
19
19
|
= fa.input :address2
|
20
20
|
|
21
21
|
- when :city
|
22
|
-
= fa.input :city, :input_html
|
22
|
+
= fa.input :city, required: required, input_html: { 'data-effective-address-city' => uuid }
|
23
23
|
|
24
24
|
- when :country_code
|
25
|
-
= fa.input :country_code,
|
25
|
+
= fa.input :country_code,
|
26
|
+
as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
27
|
+
required: required,
|
28
|
+
collection: region_options_for_simple_form_select(),
|
29
|
+
input_html: {'data-effective-address-country' => uuid}
|
26
30
|
|
27
31
|
- when :state_code
|
28
32
|
- if fa.object.try(:country_code).present?
|
29
|
-
= fa.input :state_code,
|
33
|
+
= fa.input :state_code,
|
34
|
+
as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
35
|
+
required: required,
|
36
|
+
collection: region_options_for_simple_form_select(Carmen::Country.coded(fa.object.country_code).subregions),
|
37
|
+
prompt: 'Please choose',
|
38
|
+
input_html: {'data-effective-address-state' => uuid},
|
39
|
+
input_js: { placeholder: 'Please choose' }
|
30
40
|
- else
|
31
|
-
= fa.input :state_code,
|
41
|
+
= fa.input :state_code,
|
42
|
+
as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
|
43
|
+
required: required,
|
44
|
+
disabled: true,
|
45
|
+
collection: [],
|
46
|
+
prompt: 'Please choose a country first',
|
47
|
+
input_html: { 'data-effective-address-state' => uuid },
|
48
|
+
input_js: { placeholder: 'Please choose a country first' }
|
32
49
|
|
33
50
|
- when :postal_code
|
34
|
-
= fa.input :postal_code, :input_html
|
51
|
+
= fa.input :postal_code, required: required, input_html: { 'data-effective-address-postal-code' => uuid }
|
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.5.0
|
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: 2016-03-
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|