rails_admin_map 1.1.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bea6c7a39cc9f55b916e72f84ee04acfd2fb414395424a961fb27387fb21fe89
4
- data.tar.gz: 8b19317a2d73bd2a5060028225520390ca88d9429d62b92a9146e81895cd8d30
3
+ metadata.gz: '04783c69a8dfc3ba743913561d409b4c7d59c2d5a758e57eccbd1b088f63e755'
4
+ data.tar.gz: e30324e513c1cea84a77d93f743c99a73b188814cb1e19854ce66f66e85f3a18
5
5
  SHA512:
6
- metadata.gz: db22b31572fbc6926034b3e82ccb9279848483593358315e028273cfcdbd5e96d97b7c12bd8a3c9fa29b837138c105bdfd89410b4e1476ca4fc254a07423c932
7
- data.tar.gz: 146fe5259bb7319d6673f22f62c253d601ce2bb37a7cf257db1d5b005700aa6e50b7fb276f44707ca5fd7eab1fc209a98829ecc358d1953492dcbc9bdb0c866c
6
+ metadata.gz: 2ca14bc77056ed881d5d95a0a34616b9882c15727726afb512a7b0371663e2f9806b200dc2604b4a87352459aec13fb94236427fef1f9bd8a2b970aaeaa95538
7
+ data.tar.gz: 5e56d66f2106722a083706a65a3c755b23288d9fe5cd353a03f1962267f77b1c6efea2e8f61d76b92c53118fdc2bab778c34ce4a9dd0a073bdcfa5ebeefdd2a3
data/README.md CHANGED
@@ -7,11 +7,14 @@ A simple gem to work with [rails_admin](https://github.com/sferik/rails_admin) t
7
7
 
8
8
 
9
9
  ```ruby
10
- source 'http://gems.ixmedia.com:9292/'
11
-
12
10
  gem "rails_admin_map"
13
11
  ```
14
12
 
13
+ Run this
14
+ ```
15
+ rails generate rails_admin_map:install
16
+ ```
17
+
15
18
  Then add an ```attr_accessor :coordinates``` to your active record model
16
19
 
17
20
  ```ruby
@@ -0,0 +1,12 @@
1
+
2
+ module RailsAdminMap
3
+ class ServicesController < RailsAdmin::ApplicationController
4
+ def geocode()
5
+ require 'net/http'
6
+ url = "https://maps.googleapis.com/maps/api/geocode/json?key=#{Rails.application.config.geo_api_key}&address=#{params[:address]}"
7
+
8
+ response = Net::HTTP.get_response(URI.parse(url))
9
+ render json: response.body
10
+ end
11
+ end
12
+ end
@@ -1,4 +1,5 @@
1
1
  <script type="text/javascript">
2
+ window.geocodeRoute = "<%= admin_map.map_geocode_path %>"
2
3
  window.google_api_key = "<%= Rails.application.config.map_api_key %>"
3
4
  <% if Rails.application.config.respond_to?(:geo_api_key) %>
4
5
  window.google_geo_key = "<%= Rails.application.config.geo_api_key %>"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ RailsAdminMap::Engine.routes.draw do
2
+ post '/geocode' => 'services#geocode', as: 'map_geocode'
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'rails/generators'
2
+ module RailsAdminMap
3
+ module Generators
4
+ class InstallGenerator < Rails::Generators::Base
5
+
6
+ # desc "Installs RailsAdminMap into your app."
7
+
8
+ def setup_route
9
+ route "mount RailsAdminMap::Engine => '/rails-admin-map', as: 'admin_map'"
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  module RailsAdminMap
3
3
  class Engine < ::Rails::Engine
4
- isolate_namespace RailsAdmin
4
+ isolate_namespace RailsAdminMap
5
5
 
6
6
  initializer "RailsAdminJcrop precompile hook" do |app|
7
7
  app.config.assets.precompile += ['rails_admin/rails_admin_map.css', 'rails_admin/select2.js', 'rails_admin/rails_admin_map.js']
@@ -1,3 +1,3 @@
1
1
  module RailsAdminMap
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -113,12 +113,14 @@ googleMapsCoordinatesInputs = (function() {
113
113
  googleMapsCoordinatesInputs.prototype.ajaxCallToUpdateCity = function(value) {
114
114
  if (!window.google_geo_key) return;
115
115
  var api, request;
116
- api = 'https://maps.googleapis.com/maps/api/geocode/json?key='+window.google_geo_key+'&address=';
116
+
117
117
  request = $.ajax({
118
- url: api + value,
118
+ url: window.geocodeRoute,
119
119
  method: 'POST',
120
- dataType: 'json'
120
+ dataType: 'json',
121
+ data: { address: value }
121
122
  });
123
+
122
124
  request.done((function(_this) {
123
125
  return function(data) {
124
126
  var city;
@@ -150,11 +152,12 @@ googleMapsCoordinatesInputs = (function() {
150
152
  var _this = this;
151
153
  $('.js-geocoding-select').select2({
152
154
  ajax: {
153
- url: 'https://maps.googleapis.com/maps/api/geocode/json',
155
+ url: window.geocodeRoute,
154
156
  dataType: 'json',
157
+ method: 'POST',
155
158
  delay: 250,
156
159
  data: function (params) {
157
- return { address: params.term, key: window.google_geo_key };
160
+ return { address: params.term };
158
161
  },
159
162
  processResults: function (data) {
160
163
  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.1.1
4
+ version: 1.2.2
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-14 00:00:00.000000000 Z
12
+ date: 2018-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -18,9 +18,9 @@ dependencies:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '4.1'
21
- - - "<"
21
+ - - "<="
22
22
  - !ruby/object:Gem::Version
23
- version: '5.2'
23
+ version: 5.2.1
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,9 +28,9 @@ dependencies:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
30
  version: '4.1'
31
- - - "<"
31
+ - - "<="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.2'
33
+ version: 5.2.1
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rails_admin
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -38,9 +38,9 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.6'
41
- - - "<"
41
+ - - "<="
42
42
  - !ruby/object:Gem::Version
43
- version: '2.0'
43
+ version: 1.4.2
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -48,9 +48,9 @@ dependencies:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0.6'
51
- - - "<"
51
+ - - "<="
52
52
  - !ruby/object:Gem::Version
53
- version: '2.0'
53
+ version: 1.4.2
54
54
  description: Add a coordinate field with a google map handler to place markers auto
55
55
  updating the fields
56
56
  email:
@@ -61,7 +61,10 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - README.md
64
+ - app/controllers/rails_admin_map/services_controller.rb
64
65
  - app/views/rails_admin/main/_map.html.erb
66
+ - config/routes.rb
67
+ - lib/generators/rails_admin_map/install/install_generator.rb
65
68
  - lib/rails_admin_map.rb
66
69
  - lib/rails_admin_map/engine.rb
67
70
  - lib/rails_admin_map/map_field.rb