base_editing_bootstrap 1.13.0 → 1.14.0
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +23 -5
- data/app/assets/config/base_editing_bootstrap_manifest.js +1 -0
- data/app/assets/javascripts/nested_form_controller.js +48 -0
- data/app/views/base_editing/_nested_row_form.html.erb +1 -1
- data/app/views/base_editing/form_field/_accept_has_many_nested_field.html.erb +21 -1
- data/config/importmap.rb +2 -0
- data/lib/base_editing_bootstrap/VERSION +1 -1
- data/lib/base_editing_bootstrap/engine.rb +8 -0
- data/lib/generators/base_editing_bootstrap/install/install_generator.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74db6610e2c8ab5c7f25de60eb6fb1c7ba1fa83570cd552a3356674356f02518
|
|
4
|
+
data.tar.gz: 8aea6970cecd4fa8623711b21d9ec77e2b2657757dfa94c91e94028b687a074e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5713323d93896548db8ee7fd75b187e5b7b6b61efb76c3855a92c79139eaa993af1a480a6cc1fe85c84a95e9b8af1f2c0dabe615ce14815728450bbd4390b10e
|
|
7
|
+
data.tar.gz: 1a6068cc2a7b296c4f8d0a3a20097efd9dddb1752bb6e5e4844053ec8f6997eac49183af26d6873949c44d4bce05235ebfb655f171d7c0d2e203a48bef8988ae
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
|
3
3
|
|
|
4
4
|
- - -
|
|
5
|
+
## 1.14.0 - 2026-03-19
|
|
6
|
+
#### Features
|
|
7
|
+
- Nested elements with limit from rails config (#24) - (f003ce4) - Marino Bonetti
|
|
8
|
+
#### Bug Fixes
|
|
9
|
+
- Correct nested_form when elements are marked for destruction - (9fd6544) - Marino Bonetti
|
|
10
|
+
|
|
11
|
+
- - -
|
|
12
|
+
|
|
5
13
|
## 1.13.0 - 2026-02-03
|
|
6
14
|
#### Features
|
|
7
15
|
- Form submit button inheritance value - (00b04b1) - Marino Bonetti
|
data/README.md
CHANGED
|
@@ -35,16 +35,34 @@ $ bundle exec rails g base_editing_bootstrap:install
|
|
|
35
35
|
|
|
36
36
|
**Si presume quindi che ActiveStorage sia correttamente installato, completo del javascript per il direct upload**
|
|
37
37
|
|
|
38
|
+
### Upgrade Notes
|
|
39
|
+
- From <= 1.13:
|
|
40
|
+
In `app/javascript/controllers/application.js` replace:
|
|
41
|
+
```js
|
|
42
|
+
import RailsNestedForm from '@stimulus-components/rails-nested-form'
|
|
43
|
+
application.register('nested-form', RailsNestedForm)
|
|
44
|
+
```
|
|
45
|
+
with:
|
|
46
|
+
```js
|
|
47
|
+
import NestedForm from 'nested_form_controller';
|
|
48
|
+
application.register('nested-form', NestedForm);
|
|
49
|
+
```
|
|
50
|
+
in `config/importmap.rb` remove:
|
|
51
|
+
```ruby
|
|
52
|
+
pin "@stimulus-components/rails-nested-form"
|
|
53
|
+
```
|
|
54
|
+
and finaly remove in vendor/javascript the `@stimulus-components/rails-nested-form` downloaded dependencies
|
|
55
|
+
|
|
38
56
|
### Note for NestedAttributes
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
Il controller nested attributes viene importato da importmaps dell'engine.
|
|
59
|
+
E' necessagio registrare il nuovo controller in app/javascript/application.js
|
|
41
60
|
|
|
42
|
-
```
|
|
43
|
-
|
|
61
|
+
```js
|
|
62
|
+
import NestedForm from 'nested_form_controller'; // Mappato con import maps locale
|
|
63
|
+
application.register('nested-form', NestedForm); // Utilizzato nell'interfaccia della form.
|
|
44
64
|
```
|
|
45
65
|
|
|
46
|
-
e seguire installazione https://www.stimulus-components.com/docs/stimulus-rails-nested-form
|
|
47
|
-
|
|
48
66
|
### Generators
|
|
49
67
|
|
|
50
68
|
Then Install dependency (if you run base_editing_bootstrap:install you are good to go):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= link nested_form_controller.js
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import NestedForm from "@stimulus-components/rails-nested-form"
|
|
2
|
+
|
|
3
|
+
// Connects to data-controller="nested-form"
|
|
4
|
+
export default class extends NestedForm {
|
|
5
|
+
|
|
6
|
+
static values = {
|
|
7
|
+
limit: Number,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
add(e) {
|
|
11
|
+
super.add(e);
|
|
12
|
+
this.check_for_enabling_add_button(e);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
remove(e) {
|
|
16
|
+
super.remove(e);
|
|
17
|
+
this.check_for_enabling_add_button(e);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Elenco elementi presenti visibili (e quindi non settati per essere cancellati)
|
|
21
|
+
total_active_elements() {
|
|
22
|
+
let count = 0;
|
|
23
|
+
|
|
24
|
+
this.targetTarget.parentElement.querySelectorAll(this.wrapperSelectorValue).forEach((ele) => {
|
|
25
|
+
if (ele.checkVisibility()) {
|
|
26
|
+
count += 1;
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
return count;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
check_for_enabling_add_button(e) {
|
|
33
|
+
if (this.hasLimitValue) {
|
|
34
|
+
if (this.total_active_elements() >= this.limitValue) {
|
|
35
|
+
// Aggiungiamo classe disable sull'elemento che ha lanciato questo evento
|
|
36
|
+
this.add_button().disabled = "disabled";
|
|
37
|
+
} else {
|
|
38
|
+
this.add_button().removeAttribute("disabled");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
add_button() {
|
|
44
|
+
return this.element.querySelector('[data-action="nested-form#add"]')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<tr class="nested-form-wrapper" data-new-record="<%= form.object.new_record? %>" id="<%= dom_id(form.object) %>">
|
|
1
|
+
<tr class="nested-form-wrapper <%= (form.object.marked_for_destruction? ? "d-none" : "") %>" data-new-record="<%= form.object.new_record? %>" id="<%= dom_id(form.object) %>">
|
|
2
2
|
|
|
3
3
|
<% policy(form.object).editable_attributes.each do |field| %>
|
|
4
4
|
<td>
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
<%# locals: (form:, field:,new_object:) -%>
|
|
2
|
-
|
|
2
|
+
<%
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# Costruisco le opzioni per limitare tramite interfaccia (ricevuta da configurazione di Rails nested_attributes_for)
|
|
6
|
+
# il numero di nested elements
|
|
7
|
+
controller_data = {controller: 'nested-form'}
|
|
8
|
+
if (limit = form.object.class.nested_attributes_options[field].dig(:limit))
|
|
9
|
+
controller_data["nested-form-limit-value"] = \
|
|
10
|
+
case limit
|
|
11
|
+
when Symbol #TODO add tests
|
|
12
|
+
form.object.class.send(limit)
|
|
13
|
+
when Proc #TODO add tests
|
|
14
|
+
limit.call
|
|
15
|
+
else
|
|
16
|
+
limit
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
%>
|
|
21
|
+
|
|
22
|
+
<%= content_tag :table, class: "table", data: controller_data do %>
|
|
3
23
|
|
|
4
24
|
<thead>
|
|
5
25
|
<tr>
|
data/config/importmap.rb
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.14.0
|
|
@@ -5,5 +5,13 @@ module BaseEditingBootstrap
|
|
|
5
5
|
app.deprecators[:base_editing_bootstrap] = BaseEditingBootstrap.deprecator
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
+
initializer "base_editing_bootstrap.importmap", before: "importmap" do |app|
|
|
9
|
+
app.config.importmap.paths << Engine.root.join("config/importmap.rb")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
initializer "base_editing_bootstrap.assets.precompile" do |app|
|
|
13
|
+
app.config.assets.precompile << "nested_form_controller.js"
|
|
14
|
+
end
|
|
15
|
+
|
|
8
16
|
end
|
|
9
17
|
end
|
|
@@ -35,9 +35,9 @@ module BaseEditingBootstrap
|
|
|
35
35
|
# attualmente penso sia più sensato semplicemente scrivere a video i passaggi necessari, dato che
|
|
36
36
|
# potrebbe essere già presente importmap, nested_attribute_controller e le varie configurazioni
|
|
37
37
|
|
|
38
|
-
say "Install
|
|
39
|
-
say "
|
|
40
|
-
|
|
38
|
+
say "Install nested attributes controller, add to application.js:"
|
|
39
|
+
say " import NestedForm from 'nested_form_controller' \n
|
|
40
|
+
application.register('nested-form', NestedForm)"
|
|
41
41
|
|
|
42
42
|
end
|
|
43
43
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: base_editing_bootstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marino Bonetti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -320,6 +320,7 @@ files:
|
|
|
320
320
|
- README.md
|
|
321
321
|
- Rakefile
|
|
322
322
|
- app/assets/config/base_editing_bootstrap_manifest.js
|
|
323
|
+
- app/assets/javascripts/nested_form_controller.js
|
|
323
324
|
- app/controllers/.keep
|
|
324
325
|
- app/controllers/base_editing_controller.rb
|
|
325
326
|
- app/controllers/restricted_area_controller.rb
|
|
@@ -389,6 +390,7 @@ files:
|
|
|
389
390
|
- app/views/kaminari/_paginator.html.erb
|
|
390
391
|
- app/views/kaminari/_prev_page.html.erb
|
|
391
392
|
- base_editing_bootstrap.gemspec
|
|
393
|
+
- config/importmap.rb
|
|
392
394
|
- config/initializers/base_field_error_proc.rb
|
|
393
395
|
- config/locales/it.yml
|
|
394
396
|
- config/routes.rb
|