rails_admin_map 1.0.4 → 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
  SHA256:
3
- metadata.gz: 871632eda5b92aaa6f84e97a76c305ff9f99b038255e617174cbe95320719ec7
4
- data.tar.gz: 2c69064be8b05ec05e261193777072f0d2c39bd8640f218334e586d16d2ec164
3
+ metadata.gz: 77ff826db3933bc4d5d2f88e3becc7686cfe36d5f83bfae358356f4e1f68dcdc
4
+ data.tar.gz: af6a8121ab04198b64003f2f345a04caa1923ffebdd8f3414aa708ab38166953
5
5
  SHA512:
6
- metadata.gz: 5f8b98215b059b3beb39d08f72085d6279881952dd9b40630655350ec8840a71e684dae193393003779ece58c626baa7ebdbb1005820f0dbf447b246901bd596
7
- data.tar.gz: a628c223bef771e73a0307a948c9f3d08c1c48fd29de0fc9e5bfa8107b1b07fd428355cfd97735efe7a7dc82256c19e960ac5ce434b5cf7a0c6ee655755e66ff
6
+ metadata.gz: 2a80e62b4b9390d1c13c065e2c8ca44673e3ad078ed033ca8cb7a9dc7cb08e7f276aa00b8d814314c6d5c277d645696299742bec25db6ec125876e0d70698056
7
+ data.tar.gz: bf465699e9355e3ea0364c0a3a19740c8b7ef3007256bff08a1022102b54b249f169293e0cee902e751b74a38d1160865ee011c6aff20b363daec17998cb1106
data/README.md CHANGED
@@ -33,9 +33,13 @@ RailsAdmin.config do |config|
33
33
  end
34
34
  ```
35
35
 
36
- After, add you map api key to the `config/application.rb`
36
+ After, add you google map api key(s) to the `config/application.rb`
37
37
  ```ruby
38
+ # Map api key
38
39
  config.map_api_key = 'YOUR_KEY_HERE'
40
+
41
+ # Map geocoding key (optional)
42
+ config.geo_api_key = 'YOUR_KEY_HERE'
39
43
  ```
40
44
 
41
45
  ## Config
@@ -1,5 +1,8 @@
1
1
  <script type="text/javascript">
2
2
  window.google_api_key = "<%= Rails.application.config.map_api_key %>"
3
+ <% if Rails.application.config.respond_to?(:geo_api_key) %>
4
+ window.google_geo_key = "<%= Rails.application.config.geo_api_key %>"
5
+ <% end %>
3
6
  </script>
4
7
  <%= javascript_include_tag 'rails_admin/select2', 'rails_admin/rails_admin_map' %>
5
8
  <%= stylesheet_link_tag 'rails_admin/rails_admin_map' %>
@@ -8,9 +11,13 @@
8
11
  <div class="rails-admin-map__wrapper js-map-wrap <%= @object.latitude.present? && @object.longitude.present? ? 'active' : '' %>">
9
12
  <button type="button" class="rails-admin-map__remove-btn js-remove">Retirer</button>
10
13
  <span class="rails-admin-map__overlay js-map-overlay"><span class="rails-admin-map__overlay-label">Cliquer pour ajouter</span></span>
14
+
15
+ <% if Rails.application.config.respond_to?(:geo_api_key) %>
11
16
  <div style="margin-bottom: 10px;">
12
17
  <select style="min-width: 320px;" class="js-geocoding-select"><option value="">Choisir</option></select>
13
18
  </div>
19
+ <% end %>
20
+
14
21
  <div style="width: 600px; height: 320px;"
15
22
  data-inputs="<%= field.latitude_dom_name %>,<%= field.longitude_dom_name %>"
16
23
  data-default-coord="[<%= field.default_latitude %>, <%= field.default_longitude %>]"
@@ -1,3 +1,3 @@
1
1
  module RailsAdminMap
2
- VERSION = '1.0.4'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -111,8 +111,9 @@ googleMapsCoordinatesInputs = (function() {
111
111
  };
112
112
 
113
113
  googleMapsCoordinatesInputs.prototype.ajaxCallToUpdateCity = function(value) {
114
+ if (!window.google_geo_key) return;
114
115
  var api, request;
115
- api = 'https://maps.googleapis.com/maps/api/geocode/json?key='+window.google_api_key+'&address=';
116
+ api = 'https://maps.googleapis.com/maps/api/geocode/json?key='+window.google_geo_key+'&address=';
116
117
  request = $.ajax({
117
118
  url: api + value,
118
119
  method: 'POST',
@@ -145,6 +146,7 @@ googleMapsCoordinatesInputs = (function() {
145
146
  };
146
147
 
147
148
  googleMapsCoordinatesInputs.prototype.initAutoCompleteCityInput = function (mapinfo) {
149
+ if (!window.google_geo_key) return;
148
150
  var _this = this;
149
151
  $('.js-geocoding-select').select2({
150
152
  ajax: {
@@ -152,7 +154,7 @@ googleMapsCoordinatesInputs = (function() {
152
154
  dataType: 'json',
153
155
  delay: 250,
154
156
  data: function (params) {
155
- return { address: params.term, key: window.google_api_key };
157
+ return { address: params.term, key: window.google_geo_key };
156
158
  },
157
159
  processResults: function (data) {
158
160
  locations = [];
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Dumas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-09 00:00:00.000000000 Z
12
+ date: 2018-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails