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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aefabdd57f0839a84d951c5cf2c1cbf8e515b9e6735ee4786cd867a81ef6817
4
- data.tar.gz: 7a54056dd25d3dd5783904ee2b54891040c3c614daa6e667c2eca4108e3e1aef
3
+ metadata.gz: 776eb1dba6863a03c497dffdb3661ea4da1f65bef529e13e405b7d93f5e815eb
4
+ data.tar.gz: 3b3109cd85a1f36cf3b105c1f6b615eebcd9a39420bfd61eec099735ede9f7e3
5
5
  SHA512:
6
- metadata.gz: 77880b3666f91e2c0f525ac89c25c74d98a12b89714068b3834e236d806f59b264679a24eb78f962f4f37899146de5f225664633d4ed1470a3827a2441e40a97
7
- data.tar.gz: 79f862ec2e13b4e491b7109a691742f8f986f1651c779ba2b8f56d283185a35116edc632b96df28347e772e56058b9321279e762a35915641e0d85c00306e640
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. By default, an `abyme-association-wrapper` class is already present.
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(html: { class: "persisted-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
- * `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.
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, min-count: 1) do |abyme| %>
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
- * `add-button-text:` : this will set the `add_association` button text to the string of your choice.
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').addEventListener('abyme:limit-reached', () => { alert('You reached the max number of 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/[USERNAME]/abyme.
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
 
@@ -2,7 +2,7 @@ module Abyme
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].join(".")
8
8
  end
@@ -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
- end
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.0
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-14 00:00:00.000000000 Z
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
Binary file