base_editing_bootstrap 2.0.2 → 2.1.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 +6 -0
- data/README.md +4 -0
- data/app/views/base_editing/form_field/_accept_has_many_nested_field.html.erb +6 -1
- data/lib/base_editing_bootstrap/VERSION +1 -1
- data/lib/base_editing_bootstrap/base_model.rb +29 -0
- data/spec/support/external_shared/base_model.rb +12 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc5e88d1a3608d25d679030ede2eeaa24779f2e5b7e65099ab6591ab86357bee
|
|
4
|
+
data.tar.gz: b99d16876db70bc89645cd21a7c3048a813bd80cfda46f80e3b4718a5826aeaf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1b70ff9cc671acae3f2c0242cd2745409fe7a04afee42b52886c8bbacf217ac8a218982d688790c2c3268e358ad2174a7412fa8eaf5df298dedc0d60799ff072
|
|
7
|
+
data.tar.gz: 75a010274b3cda722a3a87cdc98b8a99664bcc43504ce8440c022a611db5424befb2daf32f1dc14bb41fe7921ba84e17d9a84bc38fc533391cc4747fa08d3d69
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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
|
+
## 2.1.0 - 2026-11-19
|
|
6
|
+
#### Features
|
|
7
|
+
- Custom nested attributes order by model (#32) - (42f80ad) - Marino Bonetti
|
|
8
|
+
|
|
9
|
+
- - -
|
|
10
|
+
|
|
5
11
|
## 2.0.2 - 2026-10-15
|
|
6
12
|
#### Bug Fixes
|
|
7
13
|
- Aggiorna la dipendenza di ransack per supportare versioni maggiori (#31) - (014d9bd) - Marino Bonetti
|
data/README.md
CHANGED
|
@@ -289,6 +289,10 @@ Note:
|
|
|
289
289
|
- nel caso di has_one: `XXXXX_attributes => [Array attributi da editare]`
|
|
290
290
|
- Il permitted _destroy vale solamente nel caso in cui si definisca nei nested_attributes che debba essere cancellabile.
|
|
291
291
|
- I campi visualizzati del modello sono presi dalla relativa policy.
|
|
292
|
+
- viene accettato e gestito il parametro :limit in modo che non sia possibile aggiungere più record di quelli definiti
|
|
293
|
+
nel modello sia a livello di ActiveRecord che a livello di UI
|
|
294
|
+
- è presente un metodo di classe `set_accept_nested_attributes_for_order`
|
|
295
|
+
che permette di definire l'ordine dei record nested attraverso l'uso di uno scope sulla relazione.
|
|
292
296
|
|
|
293
297
|
Fai riferimento all'implementazione di esempio del dummy `Company->addresses`
|
|
294
298
|
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
limit
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
+
fields_for_attributes = [field]
|
|
20
|
+
if(sorted_by = form.object.class.accept_nested_attributes_for_order(field))
|
|
21
|
+
# devo appendere la relazione con l'ordine degli elementi da renderizzare
|
|
22
|
+
fields_for_attributes<<form.object.public_send(field).public_send(sorted_by)
|
|
23
|
+
end
|
|
19
24
|
|
|
20
25
|
%>
|
|
21
26
|
|
|
@@ -42,7 +47,7 @@
|
|
|
42
47
|
|
|
43
48
|
<tbody>
|
|
44
49
|
|
|
45
|
-
<%= form.fields_for
|
|
50
|
+
<%= form.fields_for(*fields_for_attributes) do |form_for_sections| %>
|
|
46
51
|
<%= render "nested_row_form", form: form_for_sections %>
|
|
47
52
|
<% end %>
|
|
48
53
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
2.0
|
|
1
|
+
2.1.0
|
|
@@ -12,6 +12,7 @@ module BaseEditingBootstrap
|
|
|
12
12
|
:ransackable_scopes, to: :@class
|
|
13
13
|
|
|
14
14
|
class_attribute :_field_to_form_partial
|
|
15
|
+
class_attribute :_accept_nested_attributes_for_order
|
|
15
16
|
|
|
16
17
|
##
|
|
17
18
|
# Label da utilizzare nelle option per quando si genera le select dei belongs to
|
|
@@ -64,6 +65,34 @@ module BaseEditingBootstrap
|
|
|
64
65
|
self._field_to_form_partial.fetch(field, nil)
|
|
65
66
|
end
|
|
66
67
|
|
|
68
|
+
##
|
|
69
|
+
# Questo metodo serve per impostare l'ordinamento da applicare alla relazione has_many durante
|
|
70
|
+
# la creazione della form nel caso di accept_nested_attributes_for
|
|
71
|
+
# ES:
|
|
72
|
+
# has_many :imports do
|
|
73
|
+
# def ui_ordered
|
|
74
|
+
# order(ui_alias: :asc)
|
|
75
|
+
# end
|
|
76
|
+
# end
|
|
77
|
+
# accepts_nested_attributes_for :imports
|
|
78
|
+
# set_accept_nested_attributes_for_order(:imports, :ui_ordered)
|
|
79
|
+
# La firma del metodo è:
|
|
80
|
+
# set_accept_nested_attributes_for_order(association_name, order_method_name)
|
|
81
|
+
#
|
|
82
|
+
#
|
|
83
|
+
# E' presente anche un helper per i test:
|
|
84
|
+
#
|
|
85
|
+
# it_behaves_like "a model with custom accept_nested_attributes_for_order", :imports, :ui_ordered
|
|
86
|
+
def set_accept_nested_attributes_for_order(association_name, order_method_name)
|
|
87
|
+
self._accept_nested_attributes_for_order ||= {}
|
|
88
|
+
self._accept_nested_attributes_for_order = self._accept_nested_attributes_for_order.merge(association_name => order_method_name)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def accept_nested_attributes_for_order(field)
|
|
92
|
+
return nil unless self._accept_nested_attributes_for_order
|
|
93
|
+
self._accept_nested_attributes_for_order.fetch(field, nil)
|
|
94
|
+
end
|
|
95
|
+
|
|
67
96
|
end
|
|
68
97
|
end
|
|
69
98
|
end
|
|
@@ -95,4 +95,16 @@ RSpec.shared_examples "a model with custom field_to_form_partial" do |field, par
|
|
|
95
95
|
expect(described_class.field_to_form_partial(anything)).to be_nil
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
RSpec.shared_examples "a model with custom accept_nested_attributes_for_order" do |association,order_scope|
|
|
101
|
+
|
|
102
|
+
it "when #{association}" do
|
|
103
|
+
expect(described_class.accept_nested_attributes_for_order(association)).to eq order_scope
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "anything else" do
|
|
107
|
+
expect(described_class.accept_nested_attributes_for_order(anything)).to be_nil
|
|
108
|
+
end
|
|
109
|
+
|
|
98
110
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: base_editing_bootstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marino Bonetti
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-11-19 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: rails
|
|
@@ -437,6 +438,7 @@ licenses:
|
|
|
437
438
|
metadata:
|
|
438
439
|
source_code_uri: https://github.com/oniram88/BaseEditingBootstrap
|
|
439
440
|
changelog_uri: https://github.com/oniram88/BaseEditingBootstrap/blob/main/CHANGELOG.md
|
|
441
|
+
post_install_message:
|
|
440
442
|
rdoc_options: []
|
|
441
443
|
require_paths:
|
|
442
444
|
- lib
|
|
@@ -451,7 +453,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
451
453
|
- !ruby/object:Gem::Version
|
|
452
454
|
version: '0'
|
|
453
455
|
requirements: []
|
|
454
|
-
rubygems_version:
|
|
456
|
+
rubygems_version: 3.5.22
|
|
457
|
+
signing_key:
|
|
455
458
|
specification_version: 4
|
|
456
459
|
summary: 'BaseEditing: funzionalità di base per cms rails'
|
|
457
460
|
test_files: []
|