active_admin_map_index 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +168 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +6 -0
- data/active_admin_map_index.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/active_admin_map_index/configuration.rb +5 -0
- data/lib/active_admin_map_index/engine.rb +4 -0
- data/lib/active_admin_map_index/index_as_map.rb +54 -0
- data/lib/active_admin_map_index/version.rb +3 -0
- data/lib/active_admin_map_index.rb +17 -0
- data/vendor/assets/javascripts/active_admin_map_index.js +55 -0
- data/vendor/assets/stylesheets/active_admin_map_index.css +19 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 983772400b486105d88cbc6c893747ff81e09720
|
4
|
+
data.tar.gz: 99968a5aae675f167e156fb547e9c458090f9d2e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f215de875d8f09871063d790ca8fdb31156760193835c53ca77cfd9252c06060f10bb498428181836d8661069c042929a829c546118f905fb02ae75cf50102c7
|
7
|
+
data.tar.gz: fa76a2c71a7516ceb459c7bc8c021f1d728eaabb7c4f426abc09d4fd968bc53edaed3b1125cbfa0334beebadea1046560ca769b42c548074615271387d286527
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at fletch@fzf.me. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_admin_map_index (0.1.0)
|
5
|
+
activeadmin
|
6
|
+
mustache-js-rails
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (5.1.0)
|
12
|
+
actionview (= 5.1.0)
|
13
|
+
activesupport (= 5.1.0)
|
14
|
+
rack (~> 2.0)
|
15
|
+
rack-test (~> 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
18
|
+
actionview (5.1.0)
|
19
|
+
activesupport (= 5.1.0)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
24
|
+
activeadmin (1.2.0)
|
25
|
+
arbre (>= 1.1.1)
|
26
|
+
coffee-rails
|
27
|
+
formtastic (~> 3.1)
|
28
|
+
formtastic_i18n
|
29
|
+
inherited_resources (~> 1.7)
|
30
|
+
jquery-rails (>= 4.2.0)
|
31
|
+
kaminari (>= 0.15, < 2.0)
|
32
|
+
railties (>= 4.2, < 5.2)
|
33
|
+
ransack (~> 1.3)
|
34
|
+
sass (~> 3.1)
|
35
|
+
sprockets (< 4.1)
|
36
|
+
activemodel (5.1.0)
|
37
|
+
activesupport (= 5.1.0)
|
38
|
+
activerecord (5.1.0)
|
39
|
+
activemodel (= 5.1.0)
|
40
|
+
activesupport (= 5.1.0)
|
41
|
+
arel (~> 8.0)
|
42
|
+
activesupport (5.1.0)
|
43
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
|
+
i18n (~> 0.7)
|
45
|
+
minitest (~> 5.1)
|
46
|
+
tzinfo (~> 1.1)
|
47
|
+
arbre (1.1.1)
|
48
|
+
activesupport (>= 3.0.0)
|
49
|
+
arel (8.0.0)
|
50
|
+
builder (3.2.3)
|
51
|
+
coffee-rails (4.2.2)
|
52
|
+
coffee-script (>= 2.2.0)
|
53
|
+
railties (>= 4.0.0)
|
54
|
+
coffee-script (2.4.1)
|
55
|
+
coffee-script-source
|
56
|
+
execjs
|
57
|
+
coffee-script-source (1.12.2)
|
58
|
+
concurrent-ruby (1.0.5)
|
59
|
+
crass (1.0.3)
|
60
|
+
diff-lcs (1.3)
|
61
|
+
erubi (1.7.0)
|
62
|
+
execjs (2.7.0)
|
63
|
+
ffi (1.9.18)
|
64
|
+
formtastic (3.1.5)
|
65
|
+
actionpack (>= 3.2.13)
|
66
|
+
formtastic_i18n (0.6.0)
|
67
|
+
has_scope (0.7.1)
|
68
|
+
actionpack (>= 4.1, < 5.2)
|
69
|
+
activesupport (>= 4.1, < 5.2)
|
70
|
+
i18n (0.9.1)
|
71
|
+
concurrent-ruby (~> 1.0)
|
72
|
+
inherited_resources (1.8.0)
|
73
|
+
actionpack (>= 4.2, <= 5.2)
|
74
|
+
has_scope (~> 0.6)
|
75
|
+
railties (>= 4.2, <= 5.2)
|
76
|
+
responders
|
77
|
+
jquery-rails (4.3.1)
|
78
|
+
rails-dom-testing (>= 1, < 3)
|
79
|
+
railties (>= 4.2.0)
|
80
|
+
thor (>= 0.14, < 2.0)
|
81
|
+
kaminari (1.1.1)
|
82
|
+
activesupport (>= 4.1.0)
|
83
|
+
kaminari-actionview (= 1.1.1)
|
84
|
+
kaminari-activerecord (= 1.1.1)
|
85
|
+
kaminari-core (= 1.1.1)
|
86
|
+
kaminari-actionview (1.1.1)
|
87
|
+
actionview
|
88
|
+
kaminari-core (= 1.1.1)
|
89
|
+
kaminari-activerecord (1.1.1)
|
90
|
+
activerecord
|
91
|
+
kaminari-core (= 1.1.1)
|
92
|
+
kaminari-core (1.1.1)
|
93
|
+
loofah (2.1.1)
|
94
|
+
crass (~> 1.0.2)
|
95
|
+
nokogiri (>= 1.5.9)
|
96
|
+
method_source (0.9.0)
|
97
|
+
mini_portile2 (2.3.0)
|
98
|
+
minitest (5.10.3)
|
99
|
+
mustache-js-rails (2.0.6)
|
100
|
+
railties (>= 3.1, <= 5.1)
|
101
|
+
nokogiri (1.8.1)
|
102
|
+
mini_portile2 (~> 2.3.0)
|
103
|
+
polyamorous (1.3.1)
|
104
|
+
activerecord (>= 3.0)
|
105
|
+
rack (2.0.3)
|
106
|
+
rack-test (0.6.3)
|
107
|
+
rack (>= 1.0)
|
108
|
+
rails-dom-testing (2.0.3)
|
109
|
+
activesupport (>= 4.2.0)
|
110
|
+
nokogiri (>= 1.6)
|
111
|
+
rails-html-sanitizer (1.0.3)
|
112
|
+
loofah (~> 2.0)
|
113
|
+
railties (5.1.0)
|
114
|
+
actionpack (= 5.1.0)
|
115
|
+
activesupport (= 5.1.0)
|
116
|
+
method_source
|
117
|
+
rake (>= 0.8.7)
|
118
|
+
thor (>= 0.18.1, < 2.0)
|
119
|
+
rake (10.5.0)
|
120
|
+
ransack (1.8.4)
|
121
|
+
actionpack (>= 3.0)
|
122
|
+
activerecord (>= 3.0)
|
123
|
+
activesupport (>= 3.0)
|
124
|
+
i18n
|
125
|
+
polyamorous (~> 1.3)
|
126
|
+
rb-fsevent (0.10.2)
|
127
|
+
rb-inotify (0.9.10)
|
128
|
+
ffi (>= 0.5.0, < 2)
|
129
|
+
responders (2.4.0)
|
130
|
+
actionpack (>= 4.2.0, < 5.3)
|
131
|
+
railties (>= 4.2.0, < 5.3)
|
132
|
+
rspec (3.7.0)
|
133
|
+
rspec-core (~> 3.7.0)
|
134
|
+
rspec-expectations (~> 3.7.0)
|
135
|
+
rspec-mocks (~> 3.7.0)
|
136
|
+
rspec-core (3.7.0)
|
137
|
+
rspec-support (~> 3.7.0)
|
138
|
+
rspec-expectations (3.7.0)
|
139
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
140
|
+
rspec-support (~> 3.7.0)
|
141
|
+
rspec-mocks (3.7.0)
|
142
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
143
|
+
rspec-support (~> 3.7.0)
|
144
|
+
rspec-support (3.7.0)
|
145
|
+
sass (3.5.4)
|
146
|
+
sass-listen (~> 4.0.0)
|
147
|
+
sass-listen (4.0.0)
|
148
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
149
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
150
|
+
sprockets (3.7.1)
|
151
|
+
concurrent-ruby (~> 1.0)
|
152
|
+
rack (> 1, < 3)
|
153
|
+
thor (0.20.0)
|
154
|
+
thread_safe (0.3.6)
|
155
|
+
tzinfo (1.2.4)
|
156
|
+
thread_safe (~> 0.1)
|
157
|
+
|
158
|
+
PLATFORMS
|
159
|
+
ruby
|
160
|
+
|
161
|
+
DEPENDENCIES
|
162
|
+
active_admin_map_index!
|
163
|
+
bundler (~> 1.16)
|
164
|
+
rake (~> 10.0)
|
165
|
+
rspec (~> 3.0)
|
166
|
+
|
167
|
+
BUNDLED WITH
|
168
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Fletcher Fowler
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# ActiveAdminMapIndex
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'active_admin_map_index'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install active_admin_map_index
|
19
|
+
|
20
|
+
### Installation (JS/CSS)
|
21
|
+
|
22
|
+
Add the following to your `app/assets/javascripts/application.js`:
|
23
|
+
|
24
|
+
```
|
25
|
+
//= require active_admin_map_index
|
26
|
+
```
|
27
|
+
|
28
|
+
Add the following to your `app/assets/stylesheets/application.scss`:
|
29
|
+
|
30
|
+
```
|
31
|
+
@import "active_admin_map_index"
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
__Your model must have `latitude` and `longitude` columns__
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
ActiveAdmin.register MyModel do
|
41
|
+
index as: :map do
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
49
|
+
|
50
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/fzf/active_admin_map_index. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "active_admin_map_index/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "active_admin_map_index"
|
8
|
+
spec.version = ActiveAdminMapIndex::VERSION
|
9
|
+
spec.authors = ["Fletcher Fowler"]
|
10
|
+
spec.email = ["fletch@fzf.me"]
|
11
|
+
|
12
|
+
spec.summary = "Active Admin map view index"
|
13
|
+
spec.description = "Active Admin map view index"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'activeadmin'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "active_admin_map_index"
|
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__)
|
data/bin/setup
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class IndexAsMap < ActiveAdmin::Component
|
2
|
+
|
3
|
+
def build(page_presenter, collection)
|
4
|
+
@page_presenter = page_presenter
|
5
|
+
@collection = collection.to_a
|
6
|
+
add_class "index"
|
7
|
+
build_table
|
8
|
+
end
|
9
|
+
|
10
|
+
def number_of_columns
|
11
|
+
@page_presenter[:columns] || default_number_of_columns
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.index_name
|
15
|
+
"map"
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def build_table
|
21
|
+
script src: "https://maps.googleapis.com/maps/api/js?key=#{ActiveAdminMapIndex.config.google_key}"
|
22
|
+
script src: "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.11/handlebars.js"
|
23
|
+
table class: "index_map" do
|
24
|
+
div id: 'active_admin_index_map'
|
25
|
+
div class: 'map-data', 'data-collection' => collection_with_actions.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def collection_with_actions
|
30
|
+
@collection.collect do |element|
|
31
|
+
{attributes: element.attributes, actions: actions(element, css_class: :member_link)}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def actions(resource, options = {})
|
36
|
+
action_array = []
|
37
|
+
if controller.action_methods.include?('show') && authorized?(ActiveAdmin::Auth::READ, resource)
|
38
|
+
action_array << item(I18n.t('active_admin.view'), resource_path(resource), class: "view_link #{options[:css_class]}", title: I18n.t('active_admin.view'))
|
39
|
+
end
|
40
|
+
if controller.action_methods.include?('edit') && authorized?(ActiveAdmin::Auth::UPDATE, resource)
|
41
|
+
action_array << item(I18n.t('active_admin.edit'), edit_resource_path(resource), class: "edit_link #{options[:css_class]}", title: I18n.t('active_admin.edit'))
|
42
|
+
end
|
43
|
+
if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
|
44
|
+
action_array << item(I18n.t('active_admin.delete'), resource_path(resource), class: "delete_link #{options[:css_class]}", title: I18n.t('active_admin.delete'),
|
45
|
+
method: :delete, data: {confirm: I18n.t('active_admin.delete_confirmation')})
|
46
|
+
end
|
47
|
+
|
48
|
+
action_array
|
49
|
+
end
|
50
|
+
|
51
|
+
def item *args
|
52
|
+
link_to *args
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "activeadmin"
|
2
|
+
require "active_admin_map_index/version"
|
3
|
+
require "active_admin_map_index/configuration"
|
4
|
+
require "active_admin_map_index/engine"
|
5
|
+
require "active_admin_map_index/index_as_map"
|
6
|
+
|
7
|
+
module ActiveAdminMapIndex
|
8
|
+
class << self
|
9
|
+
def configure
|
10
|
+
yield config
|
11
|
+
end
|
12
|
+
|
13
|
+
def config
|
14
|
+
@config ||= ActiveAdminMapIndex::Configuration.new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
var infoTemplate = "<div class='panel'>" +
|
2
|
+
" <div class='panel_contents'>" +
|
3
|
+
" <div class='attributes_table'>" +
|
4
|
+
" <table border='0' cellspacing='0' cellpadding='0'>" +
|
5
|
+
" <tbody>" +
|
6
|
+
" {{#each attributes}}" +
|
7
|
+
" <tr class='row row-user'>" +
|
8
|
+
" <th>{{@key}}</th>" +
|
9
|
+
" <td>{{this}}</td>" +
|
10
|
+
" </tr>" +
|
11
|
+
" {{/each}}" +
|
12
|
+
" </tbody>" +
|
13
|
+
" </table>" +
|
14
|
+
" </div>" +
|
15
|
+
" </div>" +
|
16
|
+
"</div>" +
|
17
|
+
"<div class='actions'>" +
|
18
|
+
" {{#each actions}}" +
|
19
|
+
" {{{this}}}" +
|
20
|
+
" {{/each}}" +
|
21
|
+
"</div>"
|
22
|
+
|
23
|
+
|
24
|
+
function getContent(element) {
|
25
|
+
template = Handlebars.compile(infoTemplate);
|
26
|
+
return template(element)
|
27
|
+
}
|
28
|
+
|
29
|
+
function initMap() {
|
30
|
+
var map = new google.maps.Map(document.getElementById('active_admin_index_map'));
|
31
|
+
|
32
|
+
var infowindow = new google.maps.InfoWindow();
|
33
|
+
var bounds = new google.maps.LatLngBounds();
|
34
|
+
|
35
|
+
$('.map-data').data('collection').forEach(function(element, index) {
|
36
|
+
var marker = new google.maps.Marker({
|
37
|
+
position: new google.maps.LatLng(element["attributes"]["latitude"], element["attributes"]["longitude"]),
|
38
|
+
map: map
|
39
|
+
});
|
40
|
+
|
41
|
+
bounds.extend(marker.position);
|
42
|
+
google.maps.event.addListener(marker, 'click', (function (marker, index) {
|
43
|
+
return function () {
|
44
|
+
infowindow.setContent(getContent(element));
|
45
|
+
infowindow.open(map, marker);
|
46
|
+
}
|
47
|
+
})(marker, index));
|
48
|
+
});
|
49
|
+
|
50
|
+
map.fitBounds(bounds);
|
51
|
+
}
|
52
|
+
|
53
|
+
$(document).ready(function(){
|
54
|
+
initMap();
|
55
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
16
|
+
|
17
|
+
#active_admin_index_map {
|
18
|
+
height: 500px;
|
19
|
+
}
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_admin_map_index
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fletcher Fowler
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Active Admin map view index
|
70
|
+
email:
|
71
|
+
- fletch@fzf.me
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- active_admin_map_index.gemspec
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/active_admin_map_index.rb
|
89
|
+
- lib/active_admin_map_index/configuration.rb
|
90
|
+
- lib/active_admin_map_index/engine.rb
|
91
|
+
- lib/active_admin_map_index/index_as_map.rb
|
92
|
+
- lib/active_admin_map_index/version.rb
|
93
|
+
- vendor/assets/javascripts/active_admin_map_index.js
|
94
|
+
- vendor/assets/stylesheets/active_admin_map_index.css
|
95
|
+
homepage:
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.6.11
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Active Admin map view index
|
119
|
+
test_files: []
|