rondo_form 0.2.3 → 0.2.4

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: 86f07b4f93af7d78f2dcdedffbbe08adac02e2c9e5cb5f366fc3da28e941062e
4
- data.tar.gz: bb7732b21d74698061d40289063caf50269b500a5291e78453a86560bacdc41c
3
+ metadata.gz: 7c5d3d9c7c5df1095b20d8473c0e6e6307161cbf4c8b7a27aa7e43db9cdd6050
4
+ data.tar.gz: 9aab5d1fff292c0e4c558aa3c37ef6954f52c82aeab2e8989e9751f744b29c7f
5
5
  SHA512:
6
- metadata.gz: ce5ed6ea6cb956aeaadbc3aaae94c8a7c9b3f8f74289e7fc154212e4a0257a97697837c1a95847990809d20da4e6012acdb5384b96e9f02e0a5248e2bef4508f
7
- data.tar.gz: b060c7f8b3d64d1543a8c60330852c4365ceeb0e42e04f6cb419d6013e7ea020144233c6985ca39c4c235a5e5b5d9da1d2d67495712c0e72df056550849cb6ae
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.3'
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="nested-fields">
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 %>
@@ -66,6 +66,7 @@ In your `_task_fields` partial:
66
66
  _Note_:
67
67
  - Stimulus controller is `nested-rondo`, so you need to declare the element with `data-controller="nested-rondo"`.
68
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
- let wrapperClass = this.data.get("wrapperClass") || "nested-fields";
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 {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RondoForm
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
5
5
  end
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.3
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-08-07 00:00:00.000000000 Z
11
+ date: 2023-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties