abyme 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -10
- data/lib/abyme/version.rb +1 -1
- data/lib/abyme/view_helpers.rb +3 -3
- metadata +2 -3
- data/abyme-0.1.3.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 776eb1dba6863a03c497dffdb3661ea4da1f65bef529e13e405b7d93f5e815eb
|
4
|
+
data.tar.gz: 3b3109cd85a1f36cf3b105c1f6b615eebcd9a39420bfd61eec099735ede9f7e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 333f517957310246619b2ee2c99d3b0f23f8717225520e974905d0cb8164b5b75bfce832ea1a174f1e0baef0c256d4bad1342189191cd20c4e1689529c4a08b5
|
7
|
+
data.tar.gz: bb44bb23f4c9551a850d8f554af27578537a781023e905a2db391b64943b838f65fffb33a1b216df778b5a232570821567b9b4beacf4d5285dc32cc623d688f9
|
data/README.md
CHANGED
@@ -225,10 +225,10 @@ A few options can be passed to `abyme.records`:
|
|
225
225
|
<%= add_association %>
|
226
226
|
<% end %>
|
227
227
|
```
|
228
|
-
* `wrapper_html:` : gives you the possibility to add any HTML attribute you may want to the wrapper containing all fields.
|
228
|
+
* `wrapper_html:` : gives you the possibility to add any HTML attribute you may want to the wrapper containing all fields.
|
229
229
|
```ruby
|
230
230
|
<%= abymize(:tasks, f) do |abyme| %>
|
231
|
-
<%= abyme.records(
|
231
|
+
<%= abyme.records(wrapper_html: { class: "persisted-records" }) %>
|
232
232
|
# The wrapper containing all persisted task fields will have an id "abyme-tasks-wrapper" and a class "persisted-records"
|
233
233
|
<%= abyme.new_records %>
|
234
234
|
<%= add_association %>
|
@@ -282,7 +282,7 @@ This is the container for all your nested fields. It takes two parameters (the s
|
|
282
282
|
<%= add_association %>
|
283
283
|
<% end %>
|
284
284
|
```
|
285
|
-
* `limit:` : allows you to limit the number of fields that can be created through JS. If you need to limit the number of associations in database, you will need to add validations. You can also pass an option [in your model as well](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for).
|
285
|
+
* `limit:` : allows you to limit the number of new fields that can be created through JS. If you need to limit the number of associations in database, you will need to add validations. You can also pass an option [in your model as well](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for).
|
286
286
|
```ruby
|
287
287
|
<%= abymize(:tasks, f, limit: 5) do |abyme| %>
|
288
288
|
# Beyond 5 tasks, the add button won't add any more fields. See events section below to see how to handle the 'abyme:limit-reached' event
|
@@ -291,9 +291,9 @@ This is the container for all your nested fields. It takes two parameters (the s
|
|
291
291
|
<%= add_association %>
|
292
292
|
<% end %>
|
293
293
|
```
|
294
|
-
* `
|
294
|
+
* `min_count` : by default, there won't be any blank fields added on page load. By passing a `min_count` option, you can set how many empty fields should appear in the form.
|
295
295
|
```ruby
|
296
|
-
<%= abymize(:tasks, f,
|
296
|
+
<%= abymize(:tasks, f, min_count: 1) do |abyme| %>
|
297
297
|
# 1 blank task will automatically be added to the form.
|
298
298
|
<%= abyme.records %>
|
299
299
|
<%= abyme.new_records %>
|
@@ -302,7 +302,7 @@ This is the container for all your nested fields. It takes two parameters (the s
|
|
302
302
|
```
|
303
303
|
|
304
304
|
*When in auto mode*, the abymize method can take a few options:
|
305
|
-
* `
|
305
|
+
* `button_text:` : this will set the `add_association` button text to the string of your choice.
|
306
306
|
* All options that should be passed to either `records` or `new_records` can be passed here and will be passed down.
|
307
307
|
|
308
308
|
## Events
|
@@ -322,18 +322,19 @@ document.getElementById('abyme--tasks').addEventListener('abyme:before-add', you
|
|
322
322
|
### Other events
|
323
323
|
* `abyme:limit-reached`
|
324
324
|
```javascript
|
325
|
-
document.getElementById('abyme--tasks')
|
325
|
+
const tasksContainer = document.getElementById('abyme--tasks');
|
326
|
+
tasksContainer.addEventListener('abyme:limit-reached', () => {
|
327
|
+
alert('You reached the max number of tasks !')
|
328
|
+
});
|
326
329
|
```
|
327
330
|
|
328
331
|
## Development
|
329
332
|
|
330
333
|
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.
|
331
334
|
|
332
|
-
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).
|
333
|
-
|
334
335
|
## Contributing
|
335
336
|
|
336
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
337
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bear-in-mind/abyme.
|
337
338
|
|
338
339
|
## License
|
339
340
|
|
data/lib/abyme/version.rb
CHANGED
data/lib/abyme/view_helpers.rb
CHANGED
@@ -35,7 +35,7 @@ module Abyme
|
|
35
35
|
form.fields_for association, association.to_s.classify.constantize.new, child_index: 'NEW_RECORD' do |f|
|
36
36
|
content_tag(:div, build_attributes(fields_default, basic_fields_markup(options[:fields_html], association))) do
|
37
37
|
# Here, if a block is passed, we're passing the association fields to it, rather than the form itself
|
38
|
-
block_given? ? yield(f) : render("abyme/#{association.to_s.singularize}_fields", f: f)
|
38
|
+
block_given? ? yield(f) : render(options[:partial] || "abyme/#{association.to_s.singularize}_fields", f: f)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -57,8 +57,8 @@ module Abyme
|
|
57
57
|
content_tag(:div, options[:wrapper_html]) do
|
58
58
|
form.fields_for(association, records) do |f|
|
59
59
|
content_tag(:div, build_attributes(fields_default, basic_fields_markup(options[:fields_html], association))) do
|
60
|
-
block_given? ? yield(f) : render("abyme/#{association.to_s.singularize}_fields", f: f)
|
61
|
-
|
60
|
+
block_given? ? yield(f) : render(options[:partial] || "abyme/#{association.to_s.singularize}_fields", f: f)
|
61
|
+
endg
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abyme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain Sanson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-10-
|
12
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- LICENSE.txt
|
70
70
|
- README.md
|
71
71
|
- Rakefile
|
72
|
-
- abyme-0.1.3.gem
|
73
72
|
- abyme.gemspec
|
74
73
|
- bin/console
|
75
74
|
- bin/setup
|
data/abyme-0.1.3.gem
DELETED
Binary file
|