jt-rails-address 1.0.1 → 1.1.0
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/README.md +6 -2
- data/jt-rails-address.gemspec +1 -1
- data/lib/jt-rails-address.rb +11 -7
- data/lib/schema.rb +1 -0
- data/vendor/assets/javascripts/jt_address.js +2 -0
- 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: 34506b4145653ebd195bcaeb6f0928d5021f91bf
|
4
|
+
data.tar.gz: b3fe2c55f7070f74683c33392dac63bb5b6e7949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e097310c5d4b91676f962b184a3ff395566eca56c8aa9650eaaa8854ac7cb02cd908b328fb8d029a054a4e82027eb9ea7be8b347ec37fdcee7bf98f58a21df3
|
7
|
+
data.tar.gz: 53b0559a51445c219b27ee517c2923b343dff0f66126a87a7b9b5290f1db9b6b2d77e572c3b9cfef7ef7d6ebcd32e795a904032e75c8ebd0b32d3d79c9b1ddb9
|
data/README.md
CHANGED
@@ -27,6 +27,7 @@ class CreateUsers < ActiveRecord::Migration
|
|
27
27
|
t.string :email, null: false
|
28
28
|
t.string :password_digest
|
29
29
|
|
30
|
+
# Each field will be prefixed by 'address'
|
30
31
|
t.address :address
|
31
32
|
|
32
33
|
t.timestamps null: false
|
@@ -51,6 +52,7 @@ It will create all the fields you need for address management:
|
|
51
52
|
- `country_code`
|
52
53
|
- `lat`, GPS latitude
|
53
54
|
- `lng`, GPS longitude
|
55
|
+
- `google_id`, Google Place Id
|
54
56
|
|
55
57
|
In your model:
|
56
58
|
```ruby
|
@@ -73,8 +75,10 @@ In your HTML:
|
|
73
75
|
<%= form_for @user do |f| %>
|
74
76
|
|
75
77
|
<div class="jt-address-autocomplete">
|
78
|
+
<!-- This field is used to search the address on Google Maps -->
|
76
79
|
<%= f.text_field :address, class: 'jt-address-search' %>
|
77
80
|
|
81
|
+
<!-- All fields are hidden because the javascript will set their value automatically -->
|
78
82
|
<% for attr in JT::Rails::Address.fields %>
|
79
83
|
<%= f.hidden_field "address_#{attr}", class: "jt-address-field-#{attr}" %>
|
80
84
|
<% end %>
|
@@ -84,7 +88,7 @@ In your HTML:
|
|
84
88
|
|
85
89
|
<% end %>
|
86
90
|
|
87
|
-
<!-- Load Google Maps -->
|
91
|
+
<!-- Load Google Maps and call googleMapInitialize when it's done -->
|
88
92
|
<script async type="text/javascript" src="//maps.googleapis.com/maps/api/js?libraries=places&callback=googleMapInitialize"></script>
|
89
93
|
```
|
90
94
|
|
@@ -98,7 +102,7 @@ window.googleMapInitialize = function(){
|
|
98
102
|
// Simple usage
|
99
103
|
$('.jt-address-autocomplete').jt_address();
|
100
104
|
|
101
|
-
//
|
105
|
+
// Advanced usage
|
102
106
|
$('.jt-address-autocomplete').jt_address({
|
103
107
|
types: ['geocode'],
|
104
108
|
componentRestrictions: { country: 'fr' }
|
data/jt-rails-address.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.summary = "Postal addresses management in Ruby On Rails and Javascript"
|
4
4
|
s.description = "JTRailsAddress simplify postal addresses management and geocoding with Google Maps in Ruby On Rails and Javascript."
|
5
5
|
s.homepage = 'https://github.com/jonathantribouharet/jt-rails-address'
|
6
|
-
s.version = '1.0
|
6
|
+
s.version = '1.1.0'
|
7
7
|
s.files = `git ls-files`.split("\n")
|
8
8
|
s.require_paths = ['lib']
|
9
9
|
s.authors = ['Jonathan TRIBOUHARET']
|
data/lib/jt-rails-address.rb
CHANGED
@@ -74,13 +74,17 @@ module JT::Rails::Address
|
|
74
74
|
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
if !data['street_name'].blank?
|
78
|
+
if !data['street_number'].blank?
|
79
|
+
data['street'] = "#{data['street_number']} #{data['street_name']}"
|
80
|
+
else
|
81
|
+
data['street'] = data['street_name']
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
if !place['place_id'].blank?
|
86
|
+
data['google_id'] = place['place_id']
|
87
|
+
end
|
84
88
|
|
85
89
|
return data
|
86
90
|
rescue Exception => e
|
data/lib/schema.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jt-rails-address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan TRIBOUHARET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graticule
|