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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e70b510250270acd9082dc67ac523220a86523f8
4
- data.tar.gz: b4c27824417033118fc347819326b5bfc9508d72
3
+ metadata.gz: 34506b4145653ebd195bcaeb6f0928d5021f91bf
4
+ data.tar.gz: b3fe2c55f7070f74683c33392dac63bb5b6e7949
5
5
  SHA512:
6
- metadata.gz: 7cbe29d2f25c500f4c43a44483bf1da076a626d6b2e0bfc29487c0d898030189f42e260f5176e4eb1a10c203b416ec80770f3d0f66af03bacf415ac9406aae5c
7
- data.tar.gz: 7dfbdafd15c5d903a70be4db53626eb4f4da8c20d4dbd9c3104f5acf9cbdae83c394b327e383b07a0b54a6cc770ecdfa05e1a4af984295f83ca5233ab9917a6c
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
- // Advacned usage
105
+ // Advanced usage
102
106
  $('.jt-address-autocomplete').jt_address({
103
107
  types: ['geocode'],
104
108
  componentRestrictions: { country: 'fr' }
@@ -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.1'
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']
@@ -74,13 +74,17 @@ module JT::Rails::Address
74
74
 
75
75
  end
76
76
 
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
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
@@ -15,6 +15,7 @@ module JT::Rails::Address::Schema
15
15
  country_code: :string,
16
16
  lat: :float,
17
17
  lng: :float,
18
+ google_id: :string,
18
19
  }
19
20
 
20
21
  module Statements
@@ -73,6 +73,8 @@
73
73
  }
74
74
  }
75
75
 
76
+ data['google_id'] = place.place_id;
77
+
76
78
  dataChanged($container, data);
77
79
  });
78
80
  }
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.1
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: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graticule