base_editing_bootstrap 1.9.0 → 1.11.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 +14 -0
- data/README.md +107 -51
- data/app/helpers/utilities/form_helper.rb +16 -2
- data/app/views/base_editing/_form.html.erb +1 -9
- data/app/views/base_editing/_form_full_components.html.erb +14 -0
- data/app/views/base_editing/_nested_row_form.html.erb +16 -0
- data/app/views/base_editing/form_field/_accept_has_many_nested_field.html.erb +48 -0
- data/app/views/base_editing/form_field/_accept_has_one_nested_field.html.erb +4 -0
- data/lib/base_editing_bootstrap/VERSION +1 -1
- data/lib/generators/base_editing_bootstrap/install/install_generator.rb +10 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a94db145cbc0c8225a28489ba2c163a53d576e6baae96e294fc3b9d1db7e606
|
4
|
+
data.tar.gz: 5e7f937da0131bb04457475ccaf2885a524faf002ec4917200957e6481bdccf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f4e4df8738595c80519a96149dddced30cbb21cbffb3b606cc3d7f90c30ba7c1eff81d00fcaf763759be06d738a906c4d37af7ba67d16668e3bf8b1537522b
|
7
|
+
data.tar.gz: 7e2f175ed20a1cc3e80f5f23c3c66b9bc0fd7ebf32b6acecb1a7e06876a39c401e878c1318bf761c64b52ec65c597979a95c5e07c9196682f0bf5f561a4ffc61
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
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.11.0 - 2025-09-15
|
6
|
+
#### Bug Fixes
|
7
|
+
- Simplify gem push command in cog.toml - (ab70061) - Marino Bonetti
|
8
|
+
#### Features
|
9
|
+
- Add nested_attributes for has_one - (d76422c) - Marino Bonetti
|
10
|
+
|
11
|
+
- - -
|
12
|
+
|
13
|
+
## 1.10.0 - 2025-09-12
|
14
|
+
#### Features
|
15
|
+
- Automatic Nested attributes - (dad38de) - Marino Bonetti
|
16
|
+
|
17
|
+
- - -
|
18
|
+
|
5
19
|
## 1.9.0 - 2025-07-30
|
6
20
|
#### Bug Fixes
|
7
21
|
- Correct add is-invalid class on relation fields - (21e4a92) - Marino Bonetti
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# BaseEditingBootstrap
|
2
|
+
|
2
3
|
[](https://badge.fury.io/rb/base_editing_bootstrap)
|
3
4
|
|
4
5
|
### Active tested on:
|
6
|
+
|
5
7
|
* rails: 7.x,8.x
|
6
8
|
* ruby: 3.x
|
7
9
|
|
8
10
|
## Installation
|
11
|
+
|
9
12
|
Add this line to your application's Gemfile:
|
10
13
|
|
11
14
|
```ruby
|
@@ -13,29 +16,46 @@ gem "base_editing_bootstrap"
|
|
13
16
|
```
|
14
17
|
|
15
18
|
And then execute:
|
19
|
+
|
16
20
|
```bash
|
17
21
|
$ bundle
|
18
22
|
```
|
19
23
|
|
20
24
|
Or install it yourself as:
|
25
|
+
|
21
26
|
```bash
|
22
27
|
$ gem install base_editing_bootstrap
|
23
28
|
```
|
24
29
|
|
25
30
|
Then run installer:
|
31
|
+
|
26
32
|
```bash
|
27
33
|
$ bundle exec rails g base_editing_bootstrap:install
|
28
34
|
```
|
29
35
|
|
30
36
|
**Si presume quindi che ActiveStorage sia correttamente installato, completo del javascript per il direct upload**
|
31
37
|
|
38
|
+
### Note for NestedAttributes
|
39
|
+
|
40
|
+
Seguire le istruzioni per installare anche NestedAttributeForm Controller per stimulus:
|
41
|
+
|
42
|
+
```shell
|
43
|
+
bin/importmap pin @stimulus-components/rails-nested-form
|
44
|
+
```
|
45
|
+
|
46
|
+
e seguire installazione https://www.stimulus-components.com/docs/stimulus-rails-nested-form
|
47
|
+
|
32
48
|
### Generators
|
49
|
+
|
33
50
|
Then Install dependency (if you run base_editing_bootstrap:install you are good to go):
|
51
|
+
|
34
52
|
```bash
|
35
53
|
|
36
54
|
bundle exec rails g pundit:install
|
37
55
|
```
|
38
|
-
|
56
|
+
|
57
|
+
Aggiungere ad ApplicationController
|
58
|
+
|
39
59
|
```ruby
|
40
60
|
include Pundit::Authorization
|
41
61
|
```
|
@@ -48,40 +68,43 @@ documentazione e avrete la vostra versione di boostrap installata.
|
|
48
68
|
Installare `gem "factory_bot_rails"`
|
49
69
|
|
50
70
|
### Initializers
|
71
|
+
|
51
72
|
E' possibile configurare BaseEditingBootstrap con alcune impostazioni:
|
73
|
+
|
52
74
|
```ruby
|
53
75
|
BaseEditingBootstrap.configure do |config|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
##
|
77
|
+
# Controller da cui derivare poi il BaseEditingController da cui derivano
|
78
|
+
# tutti i controller sottostanti
|
79
|
+
# @default "ApplicationController"
|
80
|
+
# config.inherited_controller = 'ApplicationController'
|
81
|
+
|
82
|
+
##
|
83
|
+
# Configurazione per alterare lo standard di azione post aggiornamento record
|
84
|
+
# il default è andare nella pagina di editing del record
|
85
|
+
# possibili valori :edit , :index
|
86
|
+
# config_accessor :after_success_update_redirect, default: :edit
|
87
|
+
|
88
|
+
##
|
89
|
+
# Configurazione per alterare lo standard di azione post creazione record
|
90
|
+
# il default è andare nella pagina di editing del record
|
91
|
+
# possibili valori :edit , :index
|
92
|
+
# config_accessor :after_success_create_redirect, default: :edit
|
93
|
+
|
94
|
+
end
|
73
95
|
|
74
96
|
```
|
75
97
|
|
76
98
|
## Usage
|
99
|
+
|
77
100
|
Utilizzo per modello base, in questo esempio prendiamo come modello Post come esempio del dummy.
|
78
101
|
|
79
|
-
- Creare il Modello ed includere
|
102
|
+
- Creare il Modello ed includere
|
80
103
|
```ruby
|
81
104
|
include BaseEditingBootstrap::BaseModel
|
82
105
|
```
|
83
106
|
- La factory nelle spec deve contenere il trait `with_invalid_attributes` per definire la situazione di dati per record
|
84
|
-
non valido. ES:
|
107
|
+
non valido. ES:
|
85
108
|
```ruby
|
86
109
|
trait :with_invalid_attributes do
|
87
110
|
name {nil} # name dovrebbe essere obbligatorio nel modello
|
@@ -126,13 +149,13 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
|
|
126
149
|
```shell
|
127
150
|
rails g base_editing_bootstrap:field_override ModelName field1 field2:type
|
128
151
|
```
|
129
|
-
- è possibile customizzare
|
130
|
-
- un text help per ogni campo andando ad aggiungere nelle traduzioni la relativa
|
152
|
+
- è possibile customizzare
|
153
|
+
- un text help per ogni campo andando ad aggiungere nelle traduzioni la relativa
|
131
154
|
traduzione nella posizione: `it.activerecord.attributes.MODEL.FIELD/help_text` oppure `help_text_html` in caso di
|
132
155
|
contenuto con html
|
133
|
-
- un blocco per l'unità di misura accanto al campo aggiungendo alle traduzioni:
|
156
|
+
- un blocco per l'unità di misura accanto al campo aggiungendo alle traduzioni:
|
134
157
|
`it.activerecord.attributes.MODEL.FIELD/unit`
|
135
|
-
|
158
|
+
|
136
159
|
- [OPTIONAL] la medesima cosa è possibile fare con il rendering dei campi
|
137
160
|
delle celle della tabella
|
138
161
|
```shell
|
@@ -148,48 +171,55 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
|
|
148
171
|
**Cell Field**:
|
149
172
|
- created_at => timestamps.html.erb
|
150
173
|
- updated_at => timestamps.html.erb
|
151
|
-
- Enum
|
174
|
+
- Enum => _enum.html.erb
|
152
175
|
Per gli enum, le traduzioni dei labels di ogni valore provengono da i18n
|
153
176
|
attraverso l'helper: `Utilities::EnumHelper#enum_translation` con variant `:cell_field`
|
154
177
|
il quale sfrutta human_attribute_name del modello con 'attributo.enum_value',
|
155
178
|
quindi ad esempio per un modello `Post` con enum `categoria` e un enum `importante`, la ricerca nelle traduzioni
|
156
179
|
saranno così composte:
|
157
180
|
- it.activerecord.attributes.post/categoria.importante_cell_field
|
158
|
-
- it.activerecord.attributes.categoria.importante_cell_field
|
181
|
+
- it.activerecord.attributes.categoria.importante_cell_field
|
159
182
|
- it.attributes.importante_cell_field
|
160
183
|
- it.activerecord.attributes.post/categoria.importante
|
161
184
|
- it.activerecord.attributes.categoria.importante
|
162
185
|
- it.attributes.importante => nil
|
163
|
-
- default
|
164
|
-
|
186
|
+
- default => base.html.erb
|
187
|
+
|
165
188
|
**Form Field**
|
166
|
-
- Integer
|
167
|
-
- Float
|
168
|
-
- Decimal
|
169
|
-
- DateTime
|
170
|
-
- Date
|
171
|
-
- Boolean
|
172
|
-
- Enum
|
189
|
+
- Integer => _integer.html.erb
|
190
|
+
- Float => _decimal.html.erb
|
191
|
+
- Decimal => _decimal.html.erb
|
192
|
+
- DateTime => _datetime.html.erb
|
193
|
+
- Date => _date.html.erb
|
194
|
+
- Boolean => _boolean.html.erb
|
195
|
+
- Enum => _enum.html.erb
|
173
196
|
Per gli enum, le traduzioni dei labels di ogni valore provengono da i18n
|
174
197
|
attraverso l'helper: `Utilities::EnumHelper#enum_translation`" con variante `:form_field`
|
175
|
-
il quale sfrutta human_attribute_name del modello con 'attributo.enum_value',
|
198
|
+
il quale sfrutta human_attribute_name del modello con 'attributo.enum_value',
|
176
199
|
quindi ad esempio per un modello `Post` con enum `categoria` e un enum `importante`, la ricerca nelle traduzioni
|
177
|
-
saranno così composte:
|
200
|
+
saranno così composte:
|
178
201
|
- it.activerecord.attributes.post/categoria.importante_form_field
|
179
202
|
- it.activerecord.attributes.categoria.importante_form_field
|
180
203
|
- it.attributes.importante_form_field
|
181
204
|
- it.activerecord.attributes.post/categoria.importante
|
182
205
|
- it.activerecord.attributes.categoria.importante
|
183
206
|
- it.attributes.importante => nil
|
184
|
-
- belongs_to
|
207
|
+
- belongs_to => _belongs_to_select.html.erb
|
185
208
|
Come si può leggere dal partial, il modello che viene utilizzato come base dati per la collection deve
|
186
209
|
avere come metodo `option_label` che deve ritornare la label da utilizzare nelle options.
|
187
210
|
Di default questo metodo utilizza il semplice #to_s
|
188
211
|
Ha anche un metodo per il valore da utilizzare come chiave, di default viene dedotto dalla reflection
|
189
212
|
come anche il nome della classe da utilizzare come sorgente dei dati della collection
|
190
|
-
-
|
191
|
-
|
192
|
-
|
213
|
+
- accept_nested_attributes
|
214
|
+
- has_many => _accept_has_many_nested_field.html.erb
|
215
|
+
Questo partial renderizza una tabella per i campi associati al modello.
|
216
|
+
Più informazioni nelle note per il [nested attributes](#nested-attributes)
|
217
|
+
- has_one => _accept_has_one_nested_field.html.erb
|
218
|
+
Questo partial renderizza una nested form che si comporta come una form normale renderizzando i vari campi del
|
219
|
+
nested attraverso quanto elencato nella policy dell'oggetto padre.
|
220
|
+
- Default/String => _base.html.erb
|
221
|
+
|
222
|
+
In futuro si prevede di aggiungere automatismi per renderizzare senza
|
193
223
|
l'intervento dell'utente dei campi.
|
194
224
|
- [OPTIONAL] Search Form:
|
195
225
|
Per poter aggiungere una form di ricerca basta aggiungere alla policy
|
@@ -205,22 +235,41 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
|
|
205
235
|
#...
|
206
236
|
```
|
207
237
|
|
238
|
+
### Nested Attributes
|
239
|
+
|
240
|
+
Il funzionamento si basa completamente sul sistema di NestedAttributes
|
241
|
+
di [Rails](https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html)
|
242
|
+
Note:
|
243
|
+
|
244
|
+
- Nelle policy bisogna definire come campo da editare il nome della relazione/nested_attribute
|
245
|
+
- Nella policy bisogna inoltre definire per i permitted_attributes anche:
|
246
|
+
- nel caso di has_many: `XXXXX_attributes => [Array attributi da editare] + [:id,:_destroy]`
|
247
|
+
- nel caso di has_one: `XXXXX_attributes => [Array attributi da editare]`
|
248
|
+
- Il permitted _destroy vale solamente nel caso in cui si definisca nei nested_attributes che debba essere cancellabile.
|
249
|
+
- I campi visualizzati del modello sono presi dalla relativa policy.
|
250
|
+
|
251
|
+
Fai riferimento all'implementazione di esempio del dummy `Company->addresses`
|
252
|
+
|
208
253
|
### Translations
|
254
|
+
|
209
255
|
Traduzioni disponibili:
|
210
|
-
Per i bottoni della index, è possibile eseguire l'override del testo presente nel bottone.
|
256
|
+
Per i bottoni della index, è possibile eseguire l'override del testo presente nel bottone.
|
211
257
|
Leggere la documentazione nel file `app/helpers/base_editing_helper.rb#translate_with_controller_scoped`
|
212
258
|
|
213
|
-
|
214
259
|
## Testing helpers
|
215
260
|
|
216
261
|
### Requirements(installed with generators)
|
262
|
+
|
217
263
|
```ruby
|
218
264
|
group :test do
|
219
265
|
gem 'rails-controller-testing'
|
220
266
|
end
|
221
267
|
```
|
222
|
-
|
268
|
+
|
269
|
+
### Usage
|
270
|
+
|
223
271
|
Controllers:
|
272
|
+
|
224
273
|
```ruby
|
225
274
|
require 'rails_helper'
|
226
275
|
RSpec.describe "ServiceControllers", type: :request do
|
@@ -229,7 +278,9 @@ RSpec.describe "ServiceControllers", type: :request do
|
|
229
278
|
end
|
230
279
|
end
|
231
280
|
```
|
281
|
+
|
232
282
|
Model:
|
283
|
+
|
233
284
|
```ruby
|
234
285
|
require 'rails_helper'
|
235
286
|
RSpec.describe Service, type: :model do
|
@@ -238,7 +289,9 @@ RSpec.describe Service, type: :model do
|
|
238
289
|
ransack_permitted_associations: []
|
239
290
|
end
|
240
291
|
```
|
292
|
+
|
241
293
|
Policy
|
294
|
+
|
242
295
|
```ruby
|
243
296
|
require 'rails_helper'
|
244
297
|
##
|
@@ -264,10 +317,11 @@ end
|
|
264
317
|
```
|
265
318
|
|
266
319
|
## Message translations
|
320
|
+
|
267
321
|
I messaggi di generati per il flash provengono dal metodo BaseEditingBootstrap::ActionTranslation.human_action_message
|
268
322
|
e seguono una logica simile ad human_attribute_name.
|
269
323
|
Sono già presenti i messaggi di default, a cui viene passato il nome del modello,
|
270
|
-
ma è possibile fare override del messaggio con la classe:
|
324
|
+
ma è possibile fare override del messaggio con la classe:
|
271
325
|
|
272
326
|
```yaml
|
273
327
|
LANG:
|
@@ -281,22 +335,24 @@ LANG:
|
|
281
335
|
created: "customized %{model} created"
|
282
336
|
unsuccessful:
|
283
337
|
messages:
|
284
|
-
created:
|
338
|
+
created:
|
285
339
|
updated:
|
286
340
|
```
|
287
341
|
|
342
|
+
## Contributing
|
288
343
|
|
344
|
+
1. Setup env with:
|
289
345
|
|
290
|
-
## Contributing
|
291
|
-
1. Setup env with:
|
292
346
|
```shell
|
293
347
|
docker compose run app spec/dummy/bin/setup
|
294
348
|
```
|
295
349
|
|
296
|
-
2. Start environment with:
|
350
|
+
2. Start environment with:
|
351
|
+
|
297
352
|
```shell
|
298
353
|
docker compose up
|
299
354
|
```
|
300
355
|
|
301
356
|
## License
|
357
|
+
|
302
358
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -24,14 +24,28 @@ module Utilities
|
|
24
24
|
type = :enum
|
25
25
|
generic_field = "enum"
|
26
26
|
elsif form.object.class.respond_to?(:reflect_on_association) &&
|
27
|
-
|
28
|
-
|
27
|
+
form.object.class.reflect_on_association(field.to_s).is_a?(ActiveRecord::Reflection::BelongsToReflection) &&
|
28
|
+
!form.object.class.reflect_on_association(field.to_s).polymorphic? # non deve essere polymorphic
|
29
29
|
# Abbiamo una relazione belongs_to da gestire
|
30
30
|
reflection = form.object.class.reflect_on_association(field.to_s)
|
31
31
|
type = :belongs_to
|
32
32
|
generic_field = "belongs_to_select"
|
33
33
|
locals[:relation_class] = reflection.klass
|
34
34
|
locals[:foreign_key] = reflection.foreign_key
|
35
|
+
elsif form.object.class.respond_to?(:nested_attributes_options) &&
|
36
|
+
form.object.class.nested_attributes_options.key?(field.to_sym)
|
37
|
+
type = :nested_attributes
|
38
|
+
reflection = form.object.class.reflect_on_association(field.to_s)
|
39
|
+
case reflection
|
40
|
+
when ActiveRecord::Reflection::HasManyReflection
|
41
|
+
locals[:new_object] = reflection.klass.new(reflection.foreign_key => form.object)
|
42
|
+
generic_field = "accept_has_many_nested_field"
|
43
|
+
when ActiveRecord::Reflection::HasOneReflection
|
44
|
+
form.object.send(:"build_#{field}") unless form.object.send(field).present?
|
45
|
+
generic_field = "accept_has_one_nested_field"
|
46
|
+
else
|
47
|
+
raise "Unknown reflection for nested attributes #{field}->#{reflection.class}"
|
48
|
+
end
|
35
49
|
else
|
36
50
|
if form.object.class.respond_to?(:type_for_attribute)
|
37
51
|
type = form.object.class.type_for_attribute(field).type
|
@@ -1,15 +1,7 @@
|
|
1
1
|
<%= render layout: "form_container" do %>
|
2
2
|
<%= form_for @object, builder: form_builder do |form| %>
|
3
3
|
|
4
|
-
<%= render
|
5
|
-
<%= render partial: "form_field_header", locals: {form:} %>
|
6
|
-
<%= render partial: "form_base_errors", locals: {form:} if form.object.errors.key?(:base) %>
|
7
|
-
<%= render layout: "form_fields_container" do %>
|
8
|
-
<%= render collection: form_attributes(form.object),
|
9
|
-
layout: "form_field_container",
|
10
|
-
partial: "form_field", locals: {form:} %>
|
11
|
-
<% end %>
|
12
|
-
<% end %>
|
4
|
+
<%= render partial: "form_full_components", locals: {form: form} %>
|
13
5
|
|
14
6
|
<%= render layout: "form_footer_container" do %>
|
15
7
|
<%= render partial: "form_footer", locals: {form: form} %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%#
|
2
|
+
Questo partial è il raggruppamento di tutti gli elementi tranne il footer del form.
|
3
|
+
Serve per riutilizzarlo anche nel nested attributes come base per costruire tutti gli elementi
|
4
|
+
%>
|
5
|
+
<%# locals: (form:) -%>
|
6
|
+
<%= render layout: "form_body_container" do %>
|
7
|
+
<%= render partial: "form_field_header", locals: {form:} %>
|
8
|
+
<%= render partial: "form_base_errors", locals: {form:} if form.object.errors.key?(:base) %>
|
9
|
+
<%= render layout: "form_fields_container" do %>
|
10
|
+
<%= render collection: form_attributes(form.object),
|
11
|
+
layout: "form_field_container",
|
12
|
+
partial: "form_field", locals: {form:} %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<tr class="nested-form-wrapper" data-new-record="<%= form.object.new_record? %>" id="<%= dom_id(form.object) %>">
|
2
|
+
|
3
|
+
<% policy(form.object).editable_attributes.each do |field| %>
|
4
|
+
<td>
|
5
|
+
<%= form_print_field(form, field) %>
|
6
|
+
<%= error_messages_for(form.object, field) %>
|
7
|
+
</td>
|
8
|
+
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<td class="d-flex justify-content-end">
|
12
|
+
<button type="button" class="btn btn-outline-danger" data-action="nested-form#remove"><%= icon("trash") %></button>
|
13
|
+
<%= form.hidden_field :_destroy %>
|
14
|
+
</td>
|
15
|
+
|
16
|
+
</tr>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%# locals: (form:, field:,new_object:) -%>
|
2
|
+
<%= content_tag :table, class: "table", data: {controller: 'nested-form'} do %>
|
3
|
+
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<% policy(new_object).editable_attributes.each do |field| %>
|
7
|
+
<th>
|
8
|
+
<%= new_object.class.human_attribute_name(field) %>
|
9
|
+
</th>
|
10
|
+
<% end %>
|
11
|
+
<th class="text-end">
|
12
|
+
<button type="button" data-action="nested-form#add" class="btn btn-outline-success"><%= icon("plus-lg") %></button>
|
13
|
+
</th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
|
17
|
+
<template data-nested-form-target="template">
|
18
|
+
<%= form.fields_for field, new_object, child_index: 'NEW_RECORD' do |form_for_sections| %>
|
19
|
+
<%= render "nested_row_form", form: form_for_sections %>
|
20
|
+
<% end %>
|
21
|
+
</template>
|
22
|
+
|
23
|
+
<tbody>
|
24
|
+
|
25
|
+
<%= form.fields_for field do |form_for_sections| %>
|
26
|
+
<%= render "nested_row_form", form: form_for_sections %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<!-- Inserted elements will be injected before that target. -->
|
30
|
+
<tr data-nested-form-target="target"></tr>
|
31
|
+
|
32
|
+
</tbody>
|
33
|
+
|
34
|
+
|
35
|
+
<% end %>
|
36
|
+
|
37
|
+
<% if form.object.errors.key?(field) %>
|
38
|
+
|
39
|
+
<div class="row">
|
40
|
+
<div class="col-12">
|
41
|
+
<div class="alert alert-danger">
|
42
|
+
<%= form.object.errors[field].join(", ") %>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<% end %>
|
48
|
+
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.11.0
|
@@ -30,6 +30,16 @@ module BaseEditingBootstrap
|
|
30
30
|
gem 'rails-controller-testing', group: :test, comment: "Required if used with controllers spec"
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
def install_nested_attributes_dependencies
|
35
|
+
# attualmente penso sia più sensato semplicemente scrivere a video i passaggi necessari, dato che
|
36
|
+
# potrebbe essere già presente importmap, nested_attribute_controller e le varie configurazioni
|
37
|
+
|
38
|
+
say "Install dependencies for nested attributes:"
|
39
|
+
say " bin/importmap pin @stimulus-components/rails-nested-form"
|
40
|
+
say "Attiva quindi come spiegato qua: https://www.stimulus-components.com/docs/stimulus-rails-nested-form il controller"
|
41
|
+
|
42
|
+
end
|
33
43
|
end
|
34
44
|
end
|
35
45
|
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.11.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: 2025-
|
11
|
+
date: 2025-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -346,10 +346,12 @@ files:
|
|
346
346
|
- app/views/base_editing/_form_fields_container.html.erb
|
347
347
|
- app/views/base_editing/_form_footer.html.erb
|
348
348
|
- app/views/base_editing/_form_footer_container.html.erb
|
349
|
+
- app/views/base_editing/_form_full_components.html.erb
|
349
350
|
- app/views/base_editing/_index_body.html.erb
|
350
351
|
- app/views/base_editing/_index_main_buttons.html.erb
|
351
352
|
- app/views/base_editing/_index_title_header.html.erb
|
352
353
|
- app/views/base_editing/_navbar.html.erb
|
354
|
+
- app/views/base_editing/_nested_row_form.html.erb
|
353
355
|
- app/views/base_editing/_new_page_title_header.html.erb
|
354
356
|
- app/views/base_editing/_search.html.erb
|
355
357
|
- app/views/base_editing/_search_field.erb
|
@@ -363,6 +365,8 @@ files:
|
|
363
365
|
- app/views/base_editing/cell_field/_enum.html.erb
|
364
366
|
- app/views/base_editing/cell_field/_timestamps.html.erb
|
365
367
|
- app/views/base_editing/edit.html.erb
|
368
|
+
- app/views/base_editing/form_field/_accept_has_many_nested_field.html.erb
|
369
|
+
- app/views/base_editing/form_field/_accept_has_one_nested_field.html.erb
|
366
370
|
- app/views/base_editing/form_field/_base.html.erb
|
367
371
|
- app/views/base_editing/form_field/_belongs_to_select.html.erb
|
368
372
|
- app/views/base_editing/form_field/_boolean.html.erb
|