simple_form_dependent_fields 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/.babelrc +3 -0
- data/.gitignore +11 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +238 -0
- data/Guardfile +8 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/assets/javascripts/lodash/4.17.10/index.js +17105 -0
- data/lib/assets/javascripts/simple_form_dependent_fields.coffee +123 -0
- data/lib/simple_form_dependent_fields.rb +13 -0
- data/lib/simple_form_dependent_fields/action_view_extension.rb +15 -0
- data/lib/simple_form_dependent_fields/dependent_fields_builder.rb +89 -0
- data/lib/simple_form_dependent_fields/railtie.rb +9 -0
- data/lib/simple_form_dependent_fields/version.rb +3 -0
- data/package.json +39 -0
- data/package/dist/index.js +17541 -0
- data/package/src/index.js +1 -0
- data/package/src/simple_form_dependent_fields.coffee +124 -0
- data/simple_form_dependent_fields.gemspec +37 -0
- data/webpack.config.js +44 -0
- data/yarn.lock +5172 -0
- metadata +297 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a7ad1c05a1cfcbfcae4bdac99c604774c6e04dd40ae9782d2c84d817e9a1779
|
4
|
+
data.tar.gz: 4b6a9583f6c0061855f823ad4520863b2fe84622243f93664b82410e8c2848a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: faf7a6ae8844aff3d435c4b3f19b292e2eb834ea2353aee8d46c1fa5fc83526044a54c3d1b4297220f99b92b95ee8624e5c161344873970e36e4e0b137d81e0c
|
7
|
+
data.tar.gz: 8a52aa92357dc082808ab37f52cbeee58e11bae31097bb7c3acf639725622a9ffe3a753df595bfd6751e9d578ff71096a297739540dff529ea61b35605742133
|
data/.babelrc
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: required
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.5.1
|
5
|
+
addons:
|
6
|
+
chrome: stable
|
7
|
+
apt:
|
8
|
+
packages:
|
9
|
+
- chromium-chromedriver
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v 1.16.1
|
12
|
+
before_script:
|
13
|
+
- ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,238 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
simple_form_dependent_fields (0.1.0)
|
5
|
+
coffee-rails
|
6
|
+
simple_form
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (5.2.1)
|
12
|
+
actionpack (= 5.2.1)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailer (5.2.1)
|
16
|
+
actionpack (= 5.2.1)
|
17
|
+
actionview (= 5.2.1)
|
18
|
+
activejob (= 5.2.1)
|
19
|
+
mail (~> 2.5, >= 2.5.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
actionpack (5.2.1)
|
22
|
+
actionview (= 5.2.1)
|
23
|
+
activesupport (= 5.2.1)
|
24
|
+
rack (~> 2.0)
|
25
|
+
rack-test (>= 0.6.3)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
28
|
+
actionview (5.2.1)
|
29
|
+
activesupport (= 5.2.1)
|
30
|
+
builder (~> 3.1)
|
31
|
+
erubi (~> 1.4)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
34
|
+
activejob (5.2.1)
|
35
|
+
activesupport (= 5.2.1)
|
36
|
+
globalid (>= 0.3.6)
|
37
|
+
activemodel (5.2.1)
|
38
|
+
activesupport (= 5.2.1)
|
39
|
+
activerecord (5.2.1)
|
40
|
+
activemodel (= 5.2.1)
|
41
|
+
activesupport (= 5.2.1)
|
42
|
+
arel (>= 9.0)
|
43
|
+
activestorage (5.2.1)
|
44
|
+
actionpack (= 5.2.1)
|
45
|
+
activerecord (= 5.2.1)
|
46
|
+
marcel (~> 0.3.1)
|
47
|
+
activesupport (5.2.1)
|
48
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
49
|
+
i18n (>= 0.7, < 2)
|
50
|
+
minitest (~> 5.1)
|
51
|
+
tzinfo (~> 1.1)
|
52
|
+
addressable (2.5.2)
|
53
|
+
public_suffix (>= 2.0.2, < 4.0)
|
54
|
+
ansi (1.5.0)
|
55
|
+
arel (9.0.0)
|
56
|
+
bson (4.3.0)
|
57
|
+
builder (3.2.3)
|
58
|
+
capybara (2.18.0)
|
59
|
+
addressable
|
60
|
+
mini_mime (>= 0.1.3)
|
61
|
+
nokogiri (>= 1.3.3)
|
62
|
+
rack (>= 1.0.0)
|
63
|
+
rack-test (>= 0.5.4)
|
64
|
+
xpath (>= 2.0, < 4.0)
|
65
|
+
capybara-screenshot (1.0.21)
|
66
|
+
capybara (>= 1.0, < 4)
|
67
|
+
launchy
|
68
|
+
childprocess (0.9.0)
|
69
|
+
ffi (~> 1.0, >= 1.0.11)
|
70
|
+
coderay (1.1.2)
|
71
|
+
coffee-rails (4.2.2)
|
72
|
+
coffee-script (>= 2.2.0)
|
73
|
+
railties (>= 4.0.0)
|
74
|
+
coffee-script (2.4.1)
|
75
|
+
coffee-script-source
|
76
|
+
execjs
|
77
|
+
coffee-script-source (1.12.2)
|
78
|
+
concurrent-ruby (1.0.5)
|
79
|
+
crass (1.0.4)
|
80
|
+
erubi (1.7.1)
|
81
|
+
execjs (2.7.0)
|
82
|
+
ffi (1.9.25)
|
83
|
+
formatador (0.2.5)
|
84
|
+
globalid (0.4.1)
|
85
|
+
activesupport (>= 4.2.0)
|
86
|
+
guard (2.14.2)
|
87
|
+
formatador (>= 0.2.4)
|
88
|
+
listen (>= 2.7, < 4.0)
|
89
|
+
lumberjack (>= 1.0.12, < 2.0)
|
90
|
+
nenv (~> 0.1)
|
91
|
+
notiffany (~> 0.0)
|
92
|
+
pry (>= 0.9.12)
|
93
|
+
shellany (~> 0.0)
|
94
|
+
thor (>= 0.18.1)
|
95
|
+
guard-compat (1.2.1)
|
96
|
+
guard-minitest (2.4.6)
|
97
|
+
guard-compat (~> 1.2)
|
98
|
+
minitest (>= 3.0)
|
99
|
+
i18n (1.1.0)
|
100
|
+
concurrent-ruby (~> 1.0)
|
101
|
+
jquery-rails (4.3.3)
|
102
|
+
rails-dom-testing (>= 1, < 3)
|
103
|
+
railties (>= 4.2.0)
|
104
|
+
thor (>= 0.14, < 2.0)
|
105
|
+
launchy (2.4.3)
|
106
|
+
addressable (~> 2.3)
|
107
|
+
listen (3.1.5)
|
108
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
109
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
110
|
+
ruby_dep (~> 1.2)
|
111
|
+
loofah (2.2.2)
|
112
|
+
crass (~> 1.0.2)
|
113
|
+
nokogiri (>= 1.5.9)
|
114
|
+
lumberjack (1.0.13)
|
115
|
+
mail (2.7.0)
|
116
|
+
mini_mime (>= 0.1.1)
|
117
|
+
marcel (0.3.3)
|
118
|
+
mimemagic (~> 0.3.2)
|
119
|
+
method_source (0.9.0)
|
120
|
+
mimemagic (0.3.2)
|
121
|
+
mini_mime (1.0.1)
|
122
|
+
mini_portile2 (2.3.0)
|
123
|
+
minitest (5.11.3)
|
124
|
+
minitest-capybara (0.8.2)
|
125
|
+
capybara (~> 2.2)
|
126
|
+
minitest (~> 5.0)
|
127
|
+
rake
|
128
|
+
minitest-metadata (0.6.0)
|
129
|
+
minitest (>= 4.7, < 6.0)
|
130
|
+
minitest-rails (3.0.0)
|
131
|
+
minitest (~> 5.8)
|
132
|
+
railties (~> 5.0)
|
133
|
+
minitest-rails-capybara (3.0.1)
|
134
|
+
capybara (~> 2.7)
|
135
|
+
minitest-capybara (~> 0.8)
|
136
|
+
minitest-metadata (~> 0.6)
|
137
|
+
minitest-rails (~> 3.0)
|
138
|
+
minitest-reporters (1.3.4)
|
139
|
+
ansi
|
140
|
+
builder
|
141
|
+
minitest (>= 5.0)
|
142
|
+
ruby-progressbar
|
143
|
+
mongo (2.6.2)
|
144
|
+
bson (>= 4.3.0, < 5.0.0)
|
145
|
+
mongoid (7.0.2)
|
146
|
+
activemodel (>= 5.1, < 6.0.0)
|
147
|
+
mongo (>= 2.5.1, < 3.0.0)
|
148
|
+
nenv (0.3.0)
|
149
|
+
nio4r (2.3.1)
|
150
|
+
nokogiri (1.8.4)
|
151
|
+
mini_portile2 (~> 2.3.0)
|
152
|
+
notiffany (0.1.1)
|
153
|
+
nenv (~> 0.1)
|
154
|
+
shellany (~> 0.0)
|
155
|
+
pry (0.11.3)
|
156
|
+
coderay (~> 1.1.0)
|
157
|
+
method_source (~> 0.9.0)
|
158
|
+
public_suffix (3.0.3)
|
159
|
+
rack (2.0.5)
|
160
|
+
rack-test (1.1.0)
|
161
|
+
rack (>= 1.0, < 3)
|
162
|
+
rails (5.2.1)
|
163
|
+
actioncable (= 5.2.1)
|
164
|
+
actionmailer (= 5.2.1)
|
165
|
+
actionpack (= 5.2.1)
|
166
|
+
actionview (= 5.2.1)
|
167
|
+
activejob (= 5.2.1)
|
168
|
+
activemodel (= 5.2.1)
|
169
|
+
activerecord (= 5.2.1)
|
170
|
+
activestorage (= 5.2.1)
|
171
|
+
activesupport (= 5.2.1)
|
172
|
+
bundler (>= 1.3.0)
|
173
|
+
railties (= 5.2.1)
|
174
|
+
sprockets-rails (>= 2.0.0)
|
175
|
+
rails-dom-testing (2.0.3)
|
176
|
+
activesupport (>= 4.2.0)
|
177
|
+
nokogiri (>= 1.6)
|
178
|
+
rails-html-sanitizer (1.0.4)
|
179
|
+
loofah (~> 2.2, >= 2.2.2)
|
180
|
+
railties (5.2.1)
|
181
|
+
actionpack (= 5.2.1)
|
182
|
+
activesupport (= 5.2.1)
|
183
|
+
method_source
|
184
|
+
rake (>= 0.8.7)
|
185
|
+
thor (>= 0.19.0, < 2.0)
|
186
|
+
rake (10.5.0)
|
187
|
+
rb-fsevent (0.10.3)
|
188
|
+
rb-inotify (0.9.10)
|
189
|
+
ffi (>= 0.5.0, < 2)
|
190
|
+
ruby-progressbar (1.10.0)
|
191
|
+
ruby_dep (1.5.0)
|
192
|
+
rubyzip (1.2.2)
|
193
|
+
selenium-webdriver (3.14.0)
|
194
|
+
childprocess (~> 0.5)
|
195
|
+
rubyzip (~> 1.2)
|
196
|
+
shellany (0.0.1)
|
197
|
+
simple_form (4.0.1)
|
198
|
+
actionpack (>= 5.0)
|
199
|
+
activemodel (>= 5.0)
|
200
|
+
sprockets (3.7.2)
|
201
|
+
concurrent-ruby (~> 1.0)
|
202
|
+
rack (> 1, < 3)
|
203
|
+
sprockets-rails (3.2.1)
|
204
|
+
actionpack (>= 4.0)
|
205
|
+
activesupport (>= 4.0)
|
206
|
+
sprockets (>= 3.0.0)
|
207
|
+
thor (0.20.0)
|
208
|
+
thread_safe (0.3.6)
|
209
|
+
tzinfo (1.2.5)
|
210
|
+
thread_safe (~> 0.1)
|
211
|
+
websocket-driver (0.7.0)
|
212
|
+
websocket-extensions (>= 0.1.0)
|
213
|
+
websocket-extensions (0.1.3)
|
214
|
+
xpath (3.1.0)
|
215
|
+
nokogiri (~> 1.8)
|
216
|
+
|
217
|
+
PLATFORMS
|
218
|
+
ruby
|
219
|
+
|
220
|
+
DEPENDENCIES
|
221
|
+
bundler (~> 1.12)
|
222
|
+
capybara (~> 2.1)
|
223
|
+
capybara-screenshot
|
224
|
+
guard
|
225
|
+
guard-minitest
|
226
|
+
jquery-rails
|
227
|
+
minitest (~> 5.0)
|
228
|
+
minitest-metadata
|
229
|
+
minitest-rails-capybara
|
230
|
+
minitest-reporters
|
231
|
+
mongoid
|
232
|
+
rails
|
233
|
+
rake (~> 10.0)
|
234
|
+
selenium-webdriver
|
235
|
+
simple_form_dependent_fields!
|
236
|
+
|
237
|
+
BUNDLED WITH
|
238
|
+
1.16.1
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Tomáš Celizna
|
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/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 asgerb
|
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,86 @@
|
|
1
|
+
# Simple Form Dependent Fields
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/tomasc/simple_form_dependent_fields.svg)](https://travis-ci.org/tomasc/simple_form_dependent_fields) [![Gem Version](https://badge.fury.io/rb/simple_form_dependent_fields.svg)](http://badge.fury.io/rb/simple_form_dependent_fields) [![Coverage Status](https://img.shields.io/coveralls/tomasc/simple_form_dependent_fields.svg)](https://coveralls.io/r/tomasc/simple_form_dependent_fields)
|
4
|
+
|
5
|
+
Dependent fields helper for [`simple_form`](https://github.com/plataformatec/simple_form).
|
6
|
+
|
7
|
+
Show or hide dependent fields in forms based on checkboxes, radios and selects.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'simple_form_dependent_fields'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install simple_form_dependent_fields
|
24
|
+
|
25
|
+
Then require the javascript in your `application.js` (if using Sprockets):
|
26
|
+
|
27
|
+
```
|
28
|
+
//= require simple_form_dependent_fields
|
29
|
+
```
|
30
|
+
|
31
|
+
and initialise the plugin like this:
|
32
|
+
|
33
|
+
```js
|
34
|
+
$(document).ready(
|
35
|
+
function() {
|
36
|
+
$(".simple_form_dependent_fields").SimpleFormDependentFields()
|
37
|
+
}
|
38
|
+
)
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
```ERB
|
44
|
+
<%= simple_form_for @my_doc do |f| %>
|
45
|
+
<%= f.input :doc_type, as: :select, collection: %w[text image video], include_blank: false %>
|
46
|
+
|
47
|
+
<%= f.dependent_fields depends_on_any: { doc_type: 'text' } do %>
|
48
|
+
<%= f.input :text %>
|
49
|
+
<%= f.input :has_title, as: :boolean %>
|
50
|
+
<% end %>
|
51
|
+
|
52
|
+
<%= f.dependent_fields depends_on_all: { doc_type: 'text', has_title: true } do %>
|
53
|
+
<%= f.input :title %>
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
<%= f.dependent_fields depends_on_none: { doc_type: 'text' } do %>
|
57
|
+
<%= f.input :caption %>
|
58
|
+
<% end %>
|
59
|
+
<% end %>
|
60
|
+
```
|
61
|
+
|
62
|
+
The `dependent_fields` helper accepts either of the following options:
|
63
|
+
|
64
|
+
```RUBY
|
65
|
+
depends_on_any: { field: value, other_field: value }
|
66
|
+
depends_on_all: { field: value, other_field: value }
|
67
|
+
depends_on_none: { field: value, other_field: value }
|
68
|
+
```
|
69
|
+
|
70
|
+
## Todo
|
71
|
+
|
72
|
+
* Multiple select field
|
73
|
+
|
74
|
+
## Development
|
75
|
+
|
76
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
77
|
+
|
78
|
+
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).
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tomasc/simple_form_dependent_fields. 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.
|
83
|
+
|
84
|
+
## License
|
85
|
+
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "simple_form_dependent_fields"
|
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__)
|