administrate-field-enum 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/LICENSE.md +21 -0
- data/README.md +33 -0
- data/administrate-field-enum.gemspec +21 -0
- data/app/views/fields/enum/_form.html.erb +28 -0
- data/app/views/fields/enum/_index.html.erb +17 -0
- data/app/views/fields/enum/_show.html.erb +17 -0
- data/lib/administrate/field/enum.rb +13 -0
- data/spec/lib/administrate/field/enum_spec.rb +14 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 552eaed63c3ac297836a314cf835091058abb5ad
|
4
|
+
data.tar.gz: a5b8d9e556869c7d48223b5d2946d7fac2c5db3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bb7384969d4663968c6af1853133543673cd65dd6b45a25dadfc3dcb92bd44cbbbb5e16cb2211ba922dcabd02c6624215aa17d0a59d46505d10030bfa11a2be
|
7
|
+
data.tar.gz: d6137138e083334a5cd3ca14fb2eddcfdf5ea4ee4a805db11b3053e162b3108bd5b855e50a0d2e37869b297f4e013985c0f0740d558795c9baa88b85ed970b0b
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 DisruptiveAngels
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Administrate::Field::Enum
|
2
|
+
|
3
|
+
A plugin to show enum attributes in [Administrate].
|
4
|
+
|
5
|
+
This repository is the first field plugin extracted out of Administrate.
|
6
|
+
Although its structure may change,
|
7
|
+
it's designed to act as a template for other Administrate field plugins.
|
8
|
+
|
9
|
+
## FAQs
|
10
|
+
|
11
|
+
**Q: How should I name my gem?**
|
12
|
+
|
13
|
+
A: Administrate field gems must be named according to the [Rubygems naming guidelines].
|
14
|
+
|
15
|
+
Essentially, name your gem after the field class that it defines.
|
16
|
+
If there's a namespace in the class name, that gets translated to a dash (`-`) in the gem name.
|
17
|
+
If the class name is CamelCased, that translates to an underscore (`_`) in the gem name.
|
18
|
+
|
19
|
+
Since all administrate field gems are under the namespace `Administrate::Field`,
|
20
|
+
every field gem name should start with the prefix `administrate-field-`.
|
21
|
+
|
22
|
+
Here are some examples (these don't correspond to actual gems):
|
23
|
+
|
24
|
+
| Gem Name | Field Name |
|
25
|
+
|----------------------------|------------------------------|
|
26
|
+
| `administrate-field-enum` | `Administrate::Field::Enum` |
|
27
|
+
| `administrate-field-file_upload` | `Administrate::Field::FileUpload` |
|
28
|
+
| `administrate-field-geocoding-region` | `Administrate::Field::Geocoding::Region` |
|
29
|
+
| `administrate-field-geocoding-geo_json` | `Administrate::Field::Geocoding::GeoJson` |
|
30
|
+
|
31
|
+
[Rubygems naming guidelines]: http://guides.rubygems.org/name-your-gem/
|
32
|
+
|
33
|
+
[Administrate]: https://github.com/thoughtbot/administrate
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'administrate/field/enum'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'administrate-field-enum'
|
7
|
+
s.version = Administrate::Field::Enum::VERSION
|
8
|
+
s.authors = ['Balbina Santana']
|
9
|
+
s.email = ['balbina@disruptiveangels.com']
|
10
|
+
s.homepage = 'https://github.com/DisruptiveAngels/administrate_field_enum'
|
11
|
+
s.summary = 'Enum field plugin for Administrate'
|
12
|
+
s.description = s.summary
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.require_paths = ['lib']
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
|
19
|
+
s.add_dependency 'administrate', '>= 0.2.2', '< 0.3.0'
|
20
|
+
s.add_dependency 'rails', '>= 4.0', '< 5.1'
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%#
|
2
|
+
# Enum Form Partial
|
3
|
+
|
4
|
+
This partial renders an input element for enum attributes.
|
5
|
+
By default, the input is a select field for the enum attributes.
|
6
|
+
|
7
|
+
## Local variables:
|
8
|
+
|
9
|
+
- `f`:
|
10
|
+
A Rails form generator, used to help create the appropriate input fields.
|
11
|
+
- `field`:
|
12
|
+
An instance of [Administrate::Field::Enum][1].
|
13
|
+
A wrapper around the enum attributes pulled from the model.
|
14
|
+
|
15
|
+
%>
|
16
|
+
|
17
|
+
<div class="field-unit__label">
|
18
|
+
<%= f.label field.attribute %>
|
19
|
+
</div>
|
20
|
+
<div class="field-unit__field">
|
21
|
+
<%= f.select(
|
22
|
+
field.attribute,
|
23
|
+
options_for_select(
|
24
|
+
f.object.class.public_send(field.attribute.to_s.pluralize)
|
25
|
+
.map { |k, v| [k.humanize, k] },
|
26
|
+
f.object.public_send(field.attribute.to_s)),
|
27
|
+
include_blank: false) %>
|
28
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%#
|
2
|
+
# Enum Index Partial
|
3
|
+
|
4
|
+
This partial renders an enum attribute
|
5
|
+
to be displayed on a resource's index page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered as a text tag.
|
8
|
+
|
9
|
+
## Local variables:
|
10
|
+
|
11
|
+
- `field`:
|
12
|
+
An instance of [Administrate::Field::Enum][1].
|
13
|
+
A wrapper around the enum attributes pulled from the model.
|
14
|
+
|
15
|
+
%>
|
16
|
+
|
17
|
+
<%= field.to_s %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%#
|
2
|
+
# Enum Show Partial
|
3
|
+
|
4
|
+
This partial renders an enum attribute,
|
5
|
+
to be displayed on a resource's show page.
|
6
|
+
|
7
|
+
By default, the attribute is rendered as a text tag.
|
8
|
+
|
9
|
+
## Local variables:
|
10
|
+
|
11
|
+
- `field`:
|
12
|
+
An instance of [Administrate::Field::Enum][1].
|
13
|
+
A wrapper around the enum attributes pulled from the model.
|
14
|
+
|
15
|
+
%>
|
16
|
+
|
17
|
+
<%= field.to_s %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'administrate/field/enum'
|
2
|
+
|
3
|
+
describe Administrate::Field::Enum do
|
4
|
+
describe '#to_partial_path' do
|
5
|
+
it 'returns a partial based on the page being rendered' do
|
6
|
+
page = :show
|
7
|
+
field = Administrate::Field::Enum.new(:status, 'status', page)
|
8
|
+
|
9
|
+
path = field.to_partial_path
|
10
|
+
|
11
|
+
expect(path).to eq('/fields/enum/#{page}')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: administrate-field-enum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Balbina Santana
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: administrate
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.2
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.3.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.2.2
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.3.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rails
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5.1'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '4.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '5.1'
|
53
|
+
description: Enum field plugin for Administrate
|
54
|
+
email:
|
55
|
+
- balbina@disruptiveangels.com
|
56
|
+
executables: []
|
57
|
+
extensions: []
|
58
|
+
extra_rdoc_files: []
|
59
|
+
files:
|
60
|
+
- Gemfile
|
61
|
+
- LICENSE.md
|
62
|
+
- README.md
|
63
|
+
- administrate-field-enum.gemspec
|
64
|
+
- app/views/fields/enum/_form.html.erb
|
65
|
+
- app/views/fields/enum/_index.html.erb
|
66
|
+
- app/views/fields/enum/_show.html.erb
|
67
|
+
- lib/administrate/field/enum.rb
|
68
|
+
- spec/lib/administrate/field/enum_spec.rb
|
69
|
+
homepage: https://github.com/DisruptiveAngels/administrate_field_enum
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.6.6
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Enum field plugin for Administrate
|
93
|
+
test_files:
|
94
|
+
- spec/lib/administrate/field/enum_spec.rb
|