rondo_form 0.2.1 → 0.2.3

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: c3d9a9ef19130de5f6aa92adf1139711bd5faaae4ef20155579e6865f291b7d9
4
- data.tar.gz: 791d1fff3244853568a449b8b3c7a151dec19b45d2c3e2e79dd77cdec47ad891
3
+ metadata.gz: 86f07b4f93af7d78f2dcdedffbbe08adac02e2c9e5cb5f366fc3da28e941062e
4
+ data.tar.gz: bb7732b21d74698061d40289063caf50269b500a5291e78453a86560bacdc41c
5
5
  SHA512:
6
- metadata.gz: e511697842f4cebf817bf61108e0556281e0702b7acd9cb6b75c0ba62d18ae7ef33b3e2665ec240a595955d0d80c77d6297bd882a7de5148552997b1020e77d5
7
- data.tar.gz: b9d9ef124e278eef3de87275295783874535207bd4785cac54a84059f28cd350e96f6b301399a1080e3ac63ab855370983c8b3793a86daf7fdd75a1c083929c2
6
+ metadata.gz: ce5ed6ea6cb956aeaadbc3aaae94c8a7c9b3f8f74289e7fc154212e4a0257a97697837c1a95847990809d20da4e6012acdb5384b96e9f02e0a5248e2bef4508f
7
+ data.tar.gz: b060c7f8b3d64d1543a8c60330852c4365ceeb0e42e04f6cb419d6013e7ea020144233c6985ca39c4c235a5e5b5d9da1d2d67495712c0e72df056550849cb6ae
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RondoForm
2
2
 
3
- Handle nested forms, same as Cocoon, but using StimulusJS
3
+ Handle dynamic nested forms, same as Cocoon, but using StimulusJS
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,7 +10,7 @@ Install the gem and add to the application's Gemfile by executing:
10
10
 
11
11
  Or inside the Gemfile add the following
12
12
 
13
- $ gem 'rondo_form', '~> 0.2.0'
13
+ $ gem 'rondo_form', '~> 0.2.3'
14
14
 
15
15
  Run the installation task:
16
16
 
@@ -35,10 +35,12 @@ In your `projects/_form` partial:
35
35
  </div>
36
36
 
37
37
  <h3 class="text-xl mt-4">Tasks</h3>
38
- <div class="my-2" data-controller="cocoon">
39
- <%= f.simple_fields_for :tasks do |task| %>
40
- <%= render "task_fields", f: task %>
41
- <% end %>
38
+ <div class="my-2" data-controller="nested-rondo">
39
+ <div data-nested-rondo-target="fieldContain">
40
+ <%= f.simple_fields_for :tasks do |task| %>
41
+ <%= render "task_fields", f: task %>
42
+ <% end %>
43
+ </div>
42
44
  <div class="links">
43
45
  <%= link_to_add_association "Add Task", f, :tasks %>
44
46
  </div>
@@ -61,8 +63,9 @@ In your `_task_fields` partial:
61
63
 
62
64
  ```
63
65
 
64
- _Note_: You must add `data-controller="cocoon"` to an element, that wraps `fields_for` and `link_to_add_association` helper.
65
-
66
+ _Note_:
67
+ - Stimulus controller is `nested-rondo`, so you need to declare the element with `data-controller="nested-rondo"`.
68
+ - You must add `data-nested-rondo-target="fieldContain"` to an element, that wraps all nested fields, the new field will be appended to this element.
66
69
 
67
70
  ## Contributing
68
71
 
@@ -1,15 +1,14 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
- static targets = ["template"]
4
+ static targets = ["template", "fieldContain"]
5
5
 
6
6
  addField(e) {
7
7
  e.preventDefault();
8
8
 
9
9
  let assoc = e.target.dataset.association;
10
10
  let newField = this.buildNewAssociation(assoc);
11
- let insertionNode = this.templateTarget.parentElement;
12
- insertionNode.insertAdjacentHTML("beforebegin", newField);
11
+ this.fieldContainTarget.insertAdjacentHTML("beforeend", newField);
13
12
  }
14
13
 
15
14
  removeField(e) {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RondoForm
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
@@ -55,8 +55,8 @@ module RondoForm
55
55
  hidden_div = content_tag("template", id: "#{model_name}_fields_template", data: {'nested-rondo_target': 'template'}) do
56
56
  render_association(association, f, new_object)
57
57
  end
58
+ hidden_div.html_safe + link_to(name, '', html_options )
58
59
  end
59
- hidden_div.html_safe + link_to(name, '', html_options )
60
60
  end
61
61
 
62
62
  # :nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rondo_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hungle00
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-17 00:00:00.000000000 Z
11
+ date: 2023-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties