rondo_form 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c5d3d9c7c5df1095b20d8473c0e6e6307161cbf4c8b7a27aa7e43db9cdd6050
|
4
|
+
data.tar.gz: 9aab5d1fff292c0e4c558aa3c37ef6954f52c82aeab2e8989e9751f744b29c7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9494cd91916ad3ff074712e7d2b0c2acfa34ee425da35979f40a9fb5252269837589ae9eab8f802d68f7cb60fc2b9dc2e87001a9d16de6fde5152e59d0a5f39a
|
7
|
+
data.tar.gz: 768eca8ff0a7ba31f9661ea51b53551d8a79cd2a13bc29c960ade8827e638be36e8675ad98502d0f772f7f71962d911aa6cc35be895dbfaa983e59d14dd0c864
|
data/README.md
CHANGED
@@ -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.
|
13
|
+
$ gem 'rondo_form', '~> 0.2.4'
|
14
14
|
|
15
15
|
Run the installation task:
|
16
16
|
|
@@ -35,7 +35,7 @@ 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="nested-rondo">
|
38
|
+
<div class="my-2" data-controller="nested-rondo" data-nested-rondo-field-class-value="task-field">
|
39
39
|
<div data-nested-rondo-target="fieldContain">
|
40
40
|
<%= f.simple_fields_for :tasks do |task| %>
|
41
41
|
<%= render "task_fields", f: task %>
|
@@ -55,7 +55,7 @@ In your `projects/_form` partial:
|
|
55
55
|
|
56
56
|
In your `_task_fields` partial:
|
57
57
|
``` erb
|
58
|
-
<div class="
|
58
|
+
<div class="task-field">
|
59
59
|
<%= f.input :description %>
|
60
60
|
<%= f.input :done, as: :boolean %>
|
61
61
|
<%= link_to_remove_association "Remove Task", f %>
|
@@ -65,7 +65,8 @@ In your `_task_fields` partial:
|
|
65
65
|
|
66
66
|
_Note_:
|
67
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
|
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.
|
69
|
+
- `data-nested-rondo-field-class-value` is used to detect the element that needs to be removed. Its value must match the class name that wraps the partial. If you do not declare it, it will default remove the closest parent element.
|
69
70
|
|
70
71
|
## Contributing
|
71
72
|
|
@@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus"
|
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
4
|
static targets = ["template", "fieldContain"]
|
5
|
+
static values = { "fieldClass" : String }
|
5
6
|
|
6
7
|
addField(e) {
|
7
8
|
e.preventDefault();
|
@@ -13,9 +14,8 @@ export default class extends Controller {
|
|
13
14
|
|
14
15
|
removeField(e) {
|
15
16
|
e.preventDefault();
|
16
|
-
|
17
|
-
|
18
|
-
let wrapperField = e.target.closest("." + wrapperClass);
|
17
|
+
const wrapperField = this.hasFieldClassValue ? e.target.closest("." + this.fieldClassValue) : e.target.parentNode;
|
18
|
+
|
19
19
|
if(e.target.matches('.dynamic')) {
|
20
20
|
wrapperField.remove();
|
21
21
|
} else {
|
data/lib/rondo_form/version.rb
CHANGED
@@ -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.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hungle00
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|