administrate-field-collection_select 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 +13 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/administrate-field-collection_select.gemspec +32 -0
- data/app/views/fields/collection_select/_form.html.erb +13 -0
- data/app/views/fields/collection_select/_index.html.erb +1 -0
- data/app/views/fields/collection_select/_show.html.erb +1 -0
- data/lib/administrate/field/collection_select.rb +60 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4de53883cbc0846f874604132408469c2a0a0af7
|
4
|
+
data.tar.gz: '0874bd312f8ec473e9f414d7d4abf2ebf929f1a2'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23e0aee36d3ecf0d9212e22ac6bdf58524e8a2f290bdde409adff00cef1a398a225fc18f3f2346e8f77dbe2db7caf21d53671df095634dd2c3c3c3b24660b914
|
7
|
+
data.tar.gz: 774faa432f14094106c8a5d068ad6e5007588ca2964a145f5f1c7945b54b36321b5283a95ea5e1270b4c65350f6b6c91a9016c185238310572482cb292c45a5a
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
administrate_gems
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Headway, LLC
|
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,40 @@
|
|
1
|
+
# Administrate::Field::CollectionSelect
|
2
|
+
|
3
|
+
A plugin for [Administrate](https://github.com/thoughtbot/administrate)
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'administrate-field-collection_select'
|
11
|
+
```
|
12
|
+
|
13
|
+
Run:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
**NOTE:** Make sure you don't `.freeze` your `ATTRIBUTE_TYPES` constant if you specify a collection query otherwise new items from the db won't show up in your drop down until you reboot the server.
|
20
|
+
|
21
|
+
Add to your `FooDashboard`:
|
22
|
+
|
23
|
+
Supports all of the options that a normal Rails collection_select does including `multiple: true`
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ATTRIBUTE_TYPES = [
|
27
|
+
bars: Field::CollectionSelect.with_options(
|
28
|
+
collection: Bar.all,
|
29
|
+
value_method: :id,
|
30
|
+
text_method: :name,
|
31
|
+
options: {
|
32
|
+
include_blank: 'Please Select A/Some Bars',
|
33
|
+
include_hidden: false,
|
34
|
+
},
|
35
|
+
multiple: true,
|
36
|
+
label: 'Good Bars',
|
37
|
+
),
|
38
|
+
]
|
39
|
+
```
|
40
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
GEM_NAME = 'collection_select'
|
6
|
+
GEM_NAME_CLASS = GEM_NAME.split('_').map(&:capitalize).join
|
7
|
+
FULL_GEM_NAME = "administrate-field-#{GEM_NAME}"
|
8
|
+
|
9
|
+
Gem::Specification.new do |gem|
|
10
|
+
gem.name = FULL_GEM_NAME
|
11
|
+
gem.version = '0.1.0'
|
12
|
+
gem.authors = ['Jon Kinney']
|
13
|
+
gem.email = ['jon@headway.io']
|
14
|
+
|
15
|
+
gem.summary = %(Custom Administrate field #{GEM_NAME})
|
16
|
+
gem.description = gem.summary
|
17
|
+
gem.homepage = "http://github.com/headwayio/#{FULL_GEM_NAME}"
|
18
|
+
gem.license = 'MIT'
|
19
|
+
|
20
|
+
gem.files = `git ls-files -z`.split("\x0").reject do |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
end
|
23
|
+
gem.bindir = 'exe'
|
24
|
+
gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
gem.require_paths = ['lib']
|
26
|
+
|
27
|
+
gem.add_development_dependency 'bundler', '~> 1.14'
|
28
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
gem.add_dependency 'administrate', '~> 0.7'
|
31
|
+
gem.add_dependency 'rails', '~> 5.0'
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class='field-unit__label'>
|
2
|
+
<%= f.label field.label %>
|
3
|
+
</div>
|
4
|
+
<div class='field-unit__field'>
|
5
|
+
<%= f.collection_select(
|
6
|
+
field.attribute,
|
7
|
+
field.selectable_collection,
|
8
|
+
field.selectable_value,
|
9
|
+
field.selectable_text,
|
10
|
+
field.selectable_options,
|
11
|
+
{ multiple: field.multiple }
|
12
|
+
) %>
|
13
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= field.to_s %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= field.to_s %>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'administrate/field/base'
|
2
|
+
|
3
|
+
module Administrate
|
4
|
+
module Field
|
5
|
+
class CollectionSelect < Base
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
@show_text ||= options.fetch(:show_text, data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def selectable_collection
|
14
|
+
collection
|
15
|
+
end
|
16
|
+
|
17
|
+
def selectable_value
|
18
|
+
value_method
|
19
|
+
end
|
20
|
+
|
21
|
+
def selectable_text
|
22
|
+
text_method
|
23
|
+
end
|
24
|
+
|
25
|
+
def selectable_options
|
26
|
+
options_method
|
27
|
+
end
|
28
|
+
|
29
|
+
def multiple
|
30
|
+
multiple_method
|
31
|
+
end
|
32
|
+
|
33
|
+
def label
|
34
|
+
@label ||= options.fetch(:label, attribute)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def collection
|
40
|
+
@collection ||= options.fetch(:collection, [])
|
41
|
+
end
|
42
|
+
|
43
|
+
def value_method
|
44
|
+
@value_method ||= options.fetch(:value_method, nil)
|
45
|
+
end
|
46
|
+
|
47
|
+
def text_method
|
48
|
+
@text_method ||= options.fetch(:text_method, nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
def options_method
|
52
|
+
@options_method ||= options.fetch(:options, nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
def multiple_method
|
56
|
+
@multiple_method ||= options.fetch(:multiple, nil)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: administrate-field-collection_select
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jon Kinney
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-04 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.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
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: administrate
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
description: Custom Administrate field collection_select
|
84
|
+
email:
|
85
|
+
- jon@headway.io
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".ruby-gemset"
|
92
|
+
- ".ruby-version"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- administrate-field-collection_select.gemspec
|
99
|
+
- app/views/fields/collection_select/_form.html.erb
|
100
|
+
- app/views/fields/collection_select/_index.html.erb
|
101
|
+
- app/views/fields/collection_select/_show.html.erb
|
102
|
+
- lib/administrate/field/collection_select.rb
|
103
|
+
homepage: http://github.com/headwayio/administrate-field-collection_select
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.6.11
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Custom Administrate field collection_select
|
127
|
+
test_files: []
|