rails_admin_countries 1.0.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 +7 -0
- data/.editorconfig +25 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +2 -0
- data/app/views/rails_admin/main/_form_country_select.html.haml +1 -0
- data/lib/rails_admin_countries/country_field.rb +23 -0
- data/lib/rails_admin_countries/engine.rb +4 -0
- data/lib/rails_admin_countries/mongoid.rb +22 -0
- data/lib/rails_admin_countries/version.rb +3 -0
- data/lib/rails_admin_countries.rb +11 -0
- data/rails_admin_countries.gemspec +28 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1496829e31c3e16cfcf004ab966ee735072bf92c
|
4
|
+
data.tar.gz: ef1f077a4356ca22e5e3ff0386d93bb8b29dfb0b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a25c6f6b3c532be90a409d7f6b683c33174cc5c3eb7abe427ad26c81907137424ba31c4cce5182b26c6c8455f70927a42519e178af9cdc71ea690365b445128
|
7
|
+
data.tar.gz: 3763b53189d3973f8964e417e258f90772a98d0dd4abb68be8806774de6d3183b11a5581cf3dc1855cfcc2420537352b53cb2ebcdd420500119d3c1af064f42d
|
data/.editorconfig
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
end_of_line = lf
|
5
|
+
insert_final_newline = true
|
6
|
+
trim_trailing_whitespace = true
|
7
|
+
tab_width = 2
|
8
|
+
indent_style = space
|
9
|
+
indent_size = 2
|
10
|
+
|
11
|
+
[**.bat]
|
12
|
+
end_of_line = crlf
|
13
|
+
|
14
|
+
[**.min.*]
|
15
|
+
indent_style = ignore
|
16
|
+
trim_trailing_whitespace = false
|
17
|
+
insert_final_newline = ignore
|
18
|
+
|
19
|
+
[*.slim]
|
20
|
+
insert_final_newline = false
|
21
|
+
trim_trailing_whitespace = false
|
22
|
+
|
23
|
+
[*.txt]
|
24
|
+
insert_final_newline = false
|
25
|
+
trim_trailing_whitespace = false
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rails_admin_countries
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.2
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Sergey Malykh
|
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,48 @@
|
|
1
|
+
# RailsAdminCountries
|
2
|
+
|
3
|
+
RailsAdmin support for the gem [countries](https://github.com/hexorx/countries/). It defines new ```country_field```.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rails_admin_countries'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rails_admin_countries
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Example usage with [Mongoid](https://github.com/mongoid/mongoid):
|
24
|
+
|
25
|
+
class Address
|
26
|
+
include Mongoid::Document
|
27
|
+
|
28
|
+
field :country, type: Country
|
29
|
+
|
30
|
+
rails_admin do
|
31
|
+
field :country
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
## Development
|
37
|
+
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
|
+
|
40
|
+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( https://github.com/[my-github-username]/rails_admin_countries/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
= form.select field.method_name, field.enum, { include_blank: true }.reverse_merge({ selected: field.form_value }), field.html_attributes.reverse_merge({ data: { enumeration: true }, placeholder: t('admin.misc.search') })
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RailsAdmin
|
2
|
+
module Config
|
3
|
+
module Fields
|
4
|
+
module Types
|
5
|
+
class CountryField < RailsAdmin::Config::Fields::Base
|
6
|
+
RailsAdmin::Config::Fields::Types.register(self)
|
7
|
+
|
8
|
+
register_instance_option :partial do
|
9
|
+
:form_country_select
|
10
|
+
end
|
11
|
+
|
12
|
+
register_instance_option :enum do
|
13
|
+
Country.all { |data| [ data.last['translations']["#{I18n.locale}"], data.first ] }.sort_by { |i| i.first.to_s }
|
14
|
+
end
|
15
|
+
|
16
|
+
register_instance_option :pretty_value do
|
17
|
+
value.blank? ? '-' : Country.search( value ).translations()["#{I18n.locale}"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails_admin/adapters/mongoid'
|
2
|
+
begin
|
3
|
+
require 'rails_admin/adapters/mongoid/property'
|
4
|
+
rescue Exception => e
|
5
|
+
end
|
6
|
+
|
7
|
+
module RailsAdmin
|
8
|
+
module Adapters
|
9
|
+
module Mongoid
|
10
|
+
class Property
|
11
|
+
alias_method :type_without_country_field, :type
|
12
|
+
def type
|
13
|
+
if property.type.to_s == 'Country' || property.type.class.name == 'Country'
|
14
|
+
:country_field
|
15
|
+
else
|
16
|
+
type_without_country_field
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "rails_admin_countries/version"
|
2
|
+
|
3
|
+
require "countries"
|
4
|
+
|
5
|
+
require "rails_admin_countries/engine"
|
6
|
+
require "rails_admin_countries/mongoid" if defined?(Mongoid)
|
7
|
+
require "rails_admin_countries/country_field"
|
8
|
+
|
9
|
+
module RailsAdminCountries
|
10
|
+
# Your code goes here...
|
11
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_admin_countries/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_admin_countries"
|
8
|
+
spec.version = RailsAdminCountries::VERSION
|
9
|
+
spec.authors = ["Sergey Malykh"]
|
10
|
+
spec.email = ["xronos.i.am@gmail.com"]
|
11
|
+
spec.authors = ["Sergey Malykh"]
|
12
|
+
spec.email = ["xronos.i.am@gmail.com"]
|
13
|
+
spec.description = %q{RailsAdmin support for the gem countries}
|
14
|
+
spec.summary = %q{RailsAdmin support for the gem countries}
|
15
|
+
spec.homepage = "https://github.com/xronos-i-am/rails_admin_authorized_fields"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "countries", "~> 0.11.0"
|
24
|
+
spec.add_dependency "rails_admin", "~> 0.6.0"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_admin_countries
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergey Malykh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: countries
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.11.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.11.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails_admin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.6.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: RailsAdmin support for the gem countries
|
70
|
+
email:
|
71
|
+
- xronos.i.am@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".editorconfig"
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".ruby-gemset"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- app/views/rails_admin/main/_form_country_select.html.haml
|
87
|
+
- lib/rails_admin_countries.rb
|
88
|
+
- lib/rails_admin_countries/country_field.rb
|
89
|
+
- lib/rails_admin_countries/engine.rb
|
90
|
+
- lib/rails_admin_countries/mongoid.rb
|
91
|
+
- lib/rails_admin_countries/version.rb
|
92
|
+
- rails_admin_countries.gemspec
|
93
|
+
homepage: https://github.com/xronos-i-am/rails_admin_authorized_fields
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.4.6
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: RailsAdmin support for the gem countries
|
117
|
+
test_files: []
|