activeadmin_google_places 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4214647ecc687d6ddd4f07b22335dee812ce8d0eff15b1ed4df2a32320036674
4
+ data.tar.gz: 8589a7f4d97a27d56de31f893ade44ba29ad043f926148a9a3e62c287288dce2
5
+ SHA512:
6
+ metadata.gz: fce226cba7c3fcc0ea885e4494bf27855ab744879e708a63219e66788d0599f315f9da815acf681f5ef9b1d71af48cdb40bcc3e7d1ff6a0f01f01745d7bbbcd3
7
+ data.tar.gz: d99bf4ef0548b5f8dd9e06be6594cc0ad100e55081d92a6150169e993c7783c61d467f2ebd51d591eab55d334c800ad95f88637122859efd5f1aac38ab14261e
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in activeadmin_google_places.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activeadmin_google_places (0.1.0)
5
+ activeadmin (>= 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (6.0.3.2)
11
+ actionview (= 6.0.3.2)
12
+ activesupport (= 6.0.3.2)
13
+ rack (~> 2.0, >= 2.0.8)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
+ actionview (6.0.3.2)
18
+ activesupport (= 6.0.3.2)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
+ activeadmin (2.7.0)
24
+ arbre (~> 1.2, >= 1.2.1)
25
+ formtastic (~> 3.1)
26
+ formtastic_i18n (~> 0.4)
27
+ inherited_resources (~> 1.7)
28
+ jquery-rails (~> 4.2)
29
+ kaminari (~> 1.0, >= 1.0.1)
30
+ railties (>= 5.2, < 6.1)
31
+ ransack (~> 2.1, >= 2.1.1)
32
+ sassc-rails (~> 2.1)
33
+ sprockets (>= 3.0, < 4.1)
34
+ activemodel (6.0.3.2)
35
+ activesupport (= 6.0.3.2)
36
+ activerecord (6.0.3.2)
37
+ activemodel (= 6.0.3.2)
38
+ activesupport (= 6.0.3.2)
39
+ activesupport (6.0.3.2)
40
+ concurrent-ruby (~> 1.0, >= 1.0.2)
41
+ i18n (>= 0.7, < 2)
42
+ minitest (~> 5.1)
43
+ tzinfo (~> 1.1)
44
+ zeitwerk (~> 2.2, >= 2.2.2)
45
+ arbre (1.2.1)
46
+ activesupport (>= 3.0.0)
47
+ builder (3.2.4)
48
+ concurrent-ruby (1.1.6)
49
+ crass (1.0.6)
50
+ diff-lcs (1.4.2)
51
+ erubi (1.9.0)
52
+ ffi (1.13.1)
53
+ formtastic (3.1.5)
54
+ actionpack (>= 3.2.13)
55
+ formtastic_i18n (0.6.0)
56
+ has_scope (0.7.2)
57
+ actionpack (>= 4.1)
58
+ activesupport (>= 4.1)
59
+ i18n (1.8.3)
60
+ concurrent-ruby (~> 1.0)
61
+ inherited_resources (1.11.0)
62
+ actionpack (>= 5.0, < 6.1)
63
+ has_scope (~> 0.6)
64
+ railties (>= 5.0, < 6.1)
65
+ responders (>= 2, < 4)
66
+ jquery-rails (4.4.0)
67
+ rails-dom-testing (>= 1, < 3)
68
+ railties (>= 4.2.0)
69
+ thor (>= 0.14, < 2.0)
70
+ kaminari (1.2.1)
71
+ activesupport (>= 4.1.0)
72
+ kaminari-actionview (= 1.2.1)
73
+ kaminari-activerecord (= 1.2.1)
74
+ kaminari-core (= 1.2.1)
75
+ kaminari-actionview (1.2.1)
76
+ actionview
77
+ kaminari-core (= 1.2.1)
78
+ kaminari-activerecord (1.2.1)
79
+ activerecord
80
+ kaminari-core (= 1.2.1)
81
+ kaminari-core (1.2.1)
82
+ loofah (2.6.0)
83
+ crass (~> 1.0.2)
84
+ nokogiri (>= 1.5.9)
85
+ method_source (1.0.0)
86
+ mini_portile2 (2.4.0)
87
+ minitest (5.14.1)
88
+ nokogiri (1.10.9)
89
+ mini_portile2 (~> 2.4.0)
90
+ polyamorous (2.3.2)
91
+ activerecord (>= 5.2.1)
92
+ rack (2.2.3)
93
+ rack-test (1.1.0)
94
+ rack (>= 1.0, < 3)
95
+ rails-dom-testing (2.0.3)
96
+ activesupport (>= 4.2.0)
97
+ nokogiri (>= 1.6)
98
+ rails-html-sanitizer (1.3.0)
99
+ loofah (~> 2.3)
100
+ railties (6.0.3.2)
101
+ actionpack (= 6.0.3.2)
102
+ activesupport (= 6.0.3.2)
103
+ method_source
104
+ rake (>= 0.8.7)
105
+ thor (>= 0.20.3, < 2.0)
106
+ rake (12.3.3)
107
+ ransack (2.3.2)
108
+ activerecord (>= 5.2.1)
109
+ activesupport (>= 5.2.1)
110
+ i18n
111
+ polyamorous (= 2.3.2)
112
+ responders (3.0.1)
113
+ actionpack (>= 5.0)
114
+ railties (>= 5.0)
115
+ rspec (3.9.0)
116
+ rspec-core (~> 3.9.0)
117
+ rspec-expectations (~> 3.9.0)
118
+ rspec-mocks (~> 3.9.0)
119
+ rspec-core (3.9.2)
120
+ rspec-support (~> 3.9.3)
121
+ rspec-expectations (3.9.2)
122
+ diff-lcs (>= 1.2.0, < 2.0)
123
+ rspec-support (~> 3.9.0)
124
+ rspec-mocks (3.9.1)
125
+ diff-lcs (>= 1.2.0, < 2.0)
126
+ rspec-support (~> 3.9.0)
127
+ rspec-support (3.9.3)
128
+ sassc (2.4.0)
129
+ ffi (~> 1.9)
130
+ sassc-rails (2.1.2)
131
+ railties (>= 4.0.0)
132
+ sassc (>= 2.0)
133
+ sprockets (> 3.0)
134
+ sprockets-rails
135
+ tilt
136
+ sprockets (4.0.2)
137
+ concurrent-ruby (~> 1.0)
138
+ rack (> 1, < 3)
139
+ sprockets-rails (3.2.1)
140
+ actionpack (>= 4.0)
141
+ activesupport (>= 4.0)
142
+ sprockets (>= 3.0.0)
143
+ thor (1.0.1)
144
+ thread_safe (0.3.6)
145
+ tilt (2.0.10)
146
+ tzinfo (1.2.7)
147
+ thread_safe (~> 0.1)
148
+ zeitwerk (2.3.0)
149
+
150
+ PLATFORMS
151
+ ruby
152
+
153
+ DEPENDENCIES
154
+ activeadmin_google_places!
155
+ rake (~> 12.0)
156
+ rspec (~> 3.0)
157
+
158
+ BUNDLED WITH
159
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # ActiveadminGooglePlaces
2
+
3
+ Plugin for adding google places search autocomplete to activeadmin
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'activeadmin_google_places'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ And then add these javascript files to the activeadmin.js file:
18
+
19
+ ```js
20
+ //= require activeadmin/google_places/google_places
21
+ //= require activeadmin/google_places_input
22
+ ```
23
+
24
+ Please generate the activeadmin_google_places initializer:
25
+
26
+ $ rails generate activeadmin_google_places:install
27
+
28
+ This will create a initializer file that you can add your Google API key.
29
+ This will be used for the fields that you want to add google places autocomplete.
30
+ Unless you configure this api key google will refuse to show any places results.
31
+
32
+ In activeadmin you can basic add google places search by doing ```as: :google_places``` to
33
+ your inputs.
34
+
35
+ ## Examples
36
+
37
+ ```ruby
38
+
39
+ form do |f|
40
+ f.inputs 'Event' do
41
+ f.input :name
42
+ f.input :date
43
+ f.input :location, as: :google_places
44
+ f.input :active
45
+ end
46
+ f.actions
47
+ end
48
+ ```
49
+
50
+ ## Do you like it? Star it!
51
+
52
+ If you use this component just star it. A developer is more motivated to improve a project when there is some interest.
53
+
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/randikabanura/activeadmin_google_places.
58
+
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ require_relative 'lib/activeadmin/google_places/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "activeadmin_google_places"
5
+ spec.version = ActiveAdmin::GooglePlaces::VERSION
6
+ spec.authors = ["Banura Randika"]
7
+ spec.email = ["randika.banura@gmail.com"]
8
+
9
+ spec.summary = "Google places search autocomplete to activeadmin"
10
+ spec.description = "Google places search autocomplete to activeadmin"
11
+ spec.homepage = "https://github.com/randikabanura/activeadmin_google_places"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency 'activeadmin', '>= 1.0'
23
+ end
@@ -0,0 +1,3 @@
1
+ var imported = document.createElement('script');
2
+ imported.src = 'https://maps.googleapis.com/maps/api/js?key=<%= ActiveadminGooglePlaces.config.google_api_key %>&libraries=places';
3
+ document.head.appendChild(imported);
@@ -0,0 +1,34 @@
1
+ window.onload = function() {
2
+ initGooglePlaces();
3
+ }
4
+
5
+ function initGooglePlaces() {
6
+ google_places_inputs = document.querySelectorAll('.google-places-field');
7
+ autocompletes = [];
8
+ google_places_hidden_inputs = []
9
+ google_places_label_inputs = []
10
+ for(var i = 0; i < google_places_inputs.length; i++) {
11
+ google_places_hidden_inputs.push(google_places_inputs[i].parentNode.firstChild)
12
+ google_places_label_inputs.push(google_places_inputs[i].nextSibling)
13
+ }
14
+
15
+ for(var i = 0; i < google_places_inputs.length; i++) {
16
+ initAutocomplete(google_places_inputs[i], i)
17
+ }
18
+
19
+ function initAutocomplete(element, i) {
20
+ // Create the autocomplete object, restricting the search to geographical
21
+ // location types.
22
+ autocomplete = new google.maps.places.Autocomplete(
23
+ /** @type {!HTMLInputElement} */(element));
24
+ autocomplete.inputId = i;
25
+ autocomplete.addListener('place_changed', fillInAddress);
26
+ autocompletes.push(autocomplete);
27
+ }
28
+
29
+ function fillInAddress() {
30
+ var place = this.getPlace();
31
+ google_places_label_inputs[this.inputId].value = place.formatted_address
32
+ google_places_hidden_inputs[this.inputId].value = place.formatted_address
33
+ }
34
+ }
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "activeadmin_google_places"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ require 'activeadmin/google_places/engine'
@@ -0,0 +1,9 @@
1
+ require 'active_admin'
2
+
3
+ module ActiveAdmin
4
+ module GooglePlaces
5
+ class Engine < ::Rails::Engine
6
+ engine_name 'activeadmin_google_places'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveAdmin
2
+ module GooglePlaces
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ require 'activeadmin/google_places'
2
+ require 'formtastic/inputs/google_places_input'
3
+
4
+ module ActiveadminGooglePlaces
5
+
6
+ class << self
7
+ attr_accessor :config
8
+ end
9
+
10
+ def self.config
11
+ @config ||= Configuration.new
12
+ end
13
+
14
+ def self.configure
15
+ yield(config)
16
+ end
17
+
18
+ class Configuration
19
+ attr_accessor :google_api_key
20
+
21
+ def initialize
22
+ @google_api_key = 'YOUR_APT_KEY'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Formtastic
2
+ module Inputs
3
+ class GooglePlacesInput < Formtastic::Inputs::TextInput
4
+ def to_html
5
+ input_wrapping do
6
+ label_html <<
7
+ template.content_tag(:div, input_html_options.merge(class: 'google-places')) do
8
+ builder.hidden_field(input_name, input_html_options.merge(class: 'google-places-hidden-field')) <<
9
+ template.content_tag(:input, input_html_options.merge(class: 'google-places-field', type: 'text')) do
10
+ template.content_tag(:input, input_html_options.merge(class: 'google-places-label-field', type: 'text', disabled: true, style: 'margin: auto;margin-top: 15px;', value: (object.send(method)))) do
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ module ActiveadminGooglePlaces
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../template', __FILE__)
5
+
6
+ def copy_initializer_file
7
+ copy_file 'initializer.rb', 'config/initializers/activeadmin_google_places.rb'
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,4 @@
1
+ ActiveadminGooglePlaces.configure do |config|
2
+ # Your google api key
3
+ # config.google_api_key = 'YOUR_API_KEY'
4
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeadmin_google_places
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Banura Randika
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activeadmin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: Google places search autocomplete to activeadmin
28
+ email:
29
+ - randika.banura@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - activeadmin_google_places.gemspec
43
+ - app/assets/javascript/activeadmin/google_places/google_places.js.erb
44
+ - app/assets/javascript/activeadmin/google_places_input.js
45
+ - bin/console
46
+ - bin/setup
47
+ - lib/activeadmin/google_places.rb
48
+ - lib/activeadmin/google_places/engine.rb
49
+ - lib/activeadmin/google_places/version.rb
50
+ - lib/activeadmin_google_places.rb
51
+ - lib/formtastic/inputs/google_places_input.rb
52
+ - lib/generators/activeadmin_google_places/install/install_generator.rb
53
+ - lib/generators/activeadmin_google_places/install/template/initializer.rb
54
+ homepage: https://github.com/randikabanura/activeadmin_google_places
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.3.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.1.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Google places search autocomplete to activeadmin
77
+ test_files: []