rails_admin_fields 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: eeb66f2b983d7e550f9eb122a7f805a9836090f8e732784584306ba6b9eaecf5
4
+ data.tar.gz: 8719d2b91362f40efb108cdd621fa7fd31ec43c8f4cbeb7767db15e6bb769888
5
+ SHA512:
6
+ metadata.gz: 441846d71e4b10e6e8ed6dbf9fe58368aa129fdc015c06f3807b111bb554e4d881d195bfad44734e918ea6e567ffbace1fd909dc9089f34107cab495f93cc853
7
+ data.tar.gz: 50824ff7456977d12eee0e3282c0c44b437aa7de01006cd0555e010c481f5f1177339ee726b7b45f874db24e20aaec353f6ce5cf7f02a63e6abc03cf7f43ba73
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Alex M
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,39 @@
1
+ # RailsAdminFields
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_admin_fields`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rails_admin_fields'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rails_admin_fields
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_admin_fields.
36
+
37
+ ## License
38
+
39
+ 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,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,69 @@
1
+ - map_id = "#{field.method_name}_map_position_input"
2
+
3
+ = form.hidden_field field.method_name, { id: map_id }
4
+
5
+ - map_url = 'https://maps.googleapis.com/maps/api/js?callback=initMap&key='
6
+ - map_url += ENV['GOOGLE_MAP_API_KEY']
7
+
8
+ %script{ async: '', defer: 'defer', src: map_url }
9
+
10
+ #map{style: 'height: 300px;'}
11
+
12
+ :javascript
13
+
14
+ window.ActiveAdminMapPosition = function() {
15
+ this.longitude = 0;
16
+ this.latitude = 0;
17
+
18
+ this.setLonLat = function(lon, lat) {
19
+ this.longitude = lon;
20
+ this.latitude = lat;
21
+ };
22
+
23
+ this.inputValue = function(input_id) {
24
+ document.getElementById(input_id).value = "POINT("+ this.latitude + " " + this.longitude +")"
25
+ }
26
+
27
+ };
28
+
29
+ function initMap() {
30
+ var myLatlng, newObj = #{!@object.persisted?};
31
+ var geoPoint = new ActiveAdminMapPosition();
32
+
33
+ if (navigator.geolocation) {
34
+ navigator.geolocation.getCurrentPosition(function (position) {
35
+
36
+ console.log(newObj);
37
+ if (newObj) {
38
+ myLatlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
39
+ geoPoint.setLonLat(position.coords.latitude, position.coords.longitude);
40
+ } else {
41
+ myLatlng = new google.maps.LatLng(#{@object.send(field.method_name)&.y || 0}, #{@object.send(field.method_name)&.x || 0});
42
+ geoPoint.setLonLat(#{@object.try(field.method_name)&.y || 0}, #{@object.try(field.method_name)&.x || 0});
43
+ }
44
+
45
+
46
+ geoPoint.inputValue("#{map_id}");
47
+
48
+
49
+ var map = new google.maps.Map(document.getElementById("map"), {
50
+ zoom: 15,
51
+ center: myLatlng
52
+ });
53
+
54
+ // Place a draggable marker on the map
55
+ var marker = new google.maps.Marker({
56
+ position: myLatlng,
57
+ map: map,
58
+ draggable:true,
59
+ title:"Drag me!"
60
+ });
61
+
62
+ //get marker position and store in hidden input
63
+ google.maps.event.addListener(marker, 'dragend', function (evt) {;
64
+ geoPoint.setLonLat(evt.latLng.lat(), evt.latLng.lng());
65
+ geoPoint.inputValue("#{map_id}");
66
+ });
67
+ });
68
+ }
69
+ }
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAdmin
4
+ module Config
5
+ module Fields
6
+ module Types
7
+ # Geography
8
+ class Citext < RailsAdmin::Config::Fields::Types::Text
9
+ RailsAdmin::Config::Fields::Types.register(self)
10
+
11
+ # def length
12
+ # nil
13
+ # end
14
+ #
15
+ # def input_size
16
+ # 100
17
+ # end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAdmin
4
+ module Config
5
+ module Fields
6
+ module Types
7
+ # MapPosition
8
+ class GeoMap < RailsAdmin::Config::Fields::Types::String
9
+ RailsAdmin::Config::Fields::Types.register(self)
10
+
11
+ def length
12
+ nil
13
+ end
14
+
15
+ def input_size
16
+ 100
17
+ end
18
+
19
+ register_instance_option :partial do
20
+ :geo_map
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAdmin
4
+ module Config
5
+ module Fields
6
+ module Types
7
+ # Geography
8
+ class Geography < RailsAdmin::Config::Fields::Types::String
9
+ RailsAdmin::Config::Fields::Types.register(self)
10
+
11
+ def length
12
+ nil
13
+ end
14
+
15
+ def input_size
16
+ 100
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_admin_fields/version'
4
+ require 'rails_admin_fields/all'
5
+
6
+ # Pretty rails_admin fields
7
+ module RailsAdminFields
8
+ class Engine < Rails::Engine; end
9
+ end
10
+
11
+ # Add new method => config_model
12
+ RailsAdmin.module_eval do
13
+ def self.config_model(name, &block)
14
+ RailsAdmin.config { |c| c.model(name, &block) }
15
+ end
16
+ end
17
+
18
+ # Add new config method => config_model
19
+ RailsAdmin::Config.class_eval do
20
+ def self.enable_fields_gem
21
+ # Load files from [app/rails_admin] folder
22
+ Dir["#{Rails.root.join('app', 'rails_admin')}/**/*.rb"].each do |file|
23
+ require file
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # require all fields
4
+ require 'rails_admin/config/fields/types/geography'
5
+ require 'rails_admin/config/fields/types/citext'
6
+ require 'rails_admin/config/fields/types/geo_map'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAdminFields
4
+ VERSION = '0.0.2'.freeze
5
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_admin_fields
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Alex M
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails_admin
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.0
69
+ description:
70
+ email:
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - LICENSE.txt
76
+ - README.md
77
+ - Rakefile
78
+ - app/views/rails_admin/main/_geo_map.haml
79
+ - lib/rails_admin/config/fields/types/citext.rb
80
+ - lib/rails_admin/config/fields/types/geo_map.rb
81
+ - lib/rails_admin/config/fields/types/geography.rb
82
+ - lib/rails_admin_fields.rb
83
+ - lib/rails_admin_fields/all.rb
84
+ - lib/rails_admin_fields/version.rb
85
+ homepage: https://github.com/bit-forge-org/rails_admin_fields
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.7.6
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: rails_admin fields
109
+ test_files: []