forest_admin_datasource_customizer 1.0.0.pre.beta.64 → 1.0.0.pre.beta.65
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/lib/forest_admin_datasource_customizer/decorators/computed/utils/flattener.rb +5 -2
- data/lib/forest_admin_datasource_customizer/decorators/publication/publication_collection_decorator.rb +2 -1
- data/lib/forest_admin_datasource_customizer/decorators/rename_field/rename_field_collection_decorator.rb +9 -2
- data/lib/forest_admin_datasource_customizer/decorators/search/search_collection_decorator.rb +1 -1
- data/lib/forest_admin_datasource_customizer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ff06d84529de19b6e3d26bb2c13bf90ec9777198f3fe817ee5232bf395e1b31
|
4
|
+
data.tar.gz: b84c75a15e00e7865e9ed37b14cc8a8b60fd1120d9c8d712f514656b46f7abe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5ec8e8088d0d82a6089795dba63674e589c3ca90e226808c5c73d6d3f78dffd5ce6f3862a5699f9cbe9505eeb3d2f7ca5a744a84ed495969954e13c0743aa0d
|
7
|
+
data.tar.gz: 9f124ec9a5a2e75741ce5d405fb6968bda58f5c231727bb6ea99d5b6c82603426f278ad93851720cd25f98aa0a406ce575f1d2294d46e4cc0d274c06c0593b15
|
@@ -31,7 +31,10 @@ module ForestAdminDatasourceCustomizer
|
|
31
31
|
|
32
32
|
def self.flatten(records, projection)
|
33
33
|
projection.map do |field|
|
34
|
-
|
34
|
+
# because we don't compute computed fields over polymorphic relation (only usage of *),
|
35
|
+
# we decide to consider the all record as a value instead of a relation
|
36
|
+
parts = field.split(':').reject { |part| part == '*' }
|
37
|
+
|
35
38
|
records.map do |record|
|
36
39
|
value = record
|
37
40
|
|
@@ -63,7 +66,7 @@ module ForestAdminDatasourceCustomizer
|
|
63
66
|
records[record_index] = {}
|
64
67
|
|
65
68
|
projection.each_with_index do |path, path_index|
|
66
|
-
parts = path.split(':').reject { |part| part
|
69
|
+
parts = path.split(':').reject { |part| [MARKER_NAME, '*'].include?(part) }
|
67
70
|
value = flatten[path_index][record_index]
|
68
71
|
|
69
72
|
# Ignore undefined values.
|
@@ -70,7 +70,8 @@ module ForestAdminDatasourceCustomizer
|
|
70
70
|
)
|
71
71
|
end
|
72
72
|
|
73
|
-
if field.type == 'OneToOne' || field.type == 'OneToMany'
|
73
|
+
if field.type == 'OneToOne' || field.type == 'OneToMany' ||
|
74
|
+
field.type == 'PolymorphicOneToOne' || field.type == 'PolymorphicOneToMany'
|
74
75
|
return (
|
75
76
|
datasource.published?(field.foreign_collection) &&
|
76
77
|
datasource.get_collection(field.foreign_collection).published?(field.origin_key) &&
|
@@ -52,6 +52,8 @@ module ForestAdminDatasourceCustomizer
|
|
52
52
|
fields = {}
|
53
53
|
schema = sub_schema.dup
|
54
54
|
|
55
|
+
# we don't handle schema modification for polymorphic many to one and reverse relations because
|
56
|
+
# we forbid to rename foreign key and type fields on polymorphic many to one
|
55
57
|
sub_schema[:fields].each do |old_name, old_schema|
|
56
58
|
case old_schema.type
|
57
59
|
when 'ManyToOne'
|
@@ -160,7 +162,11 @@ module ForestAdminDatasourceCustomizer
|
|
160
162
|
paths = path.split(':')
|
161
163
|
relation_name = paths[0]
|
162
164
|
relation_schema = schema[:fields][relation_name]
|
163
|
-
if relation_schema.type
|
165
|
+
if relation_schema.type == 'PolymorphicManyToOne'
|
166
|
+
relation_name = to_child_collection[relation_name]
|
167
|
+
|
168
|
+
return "#{relation_name}:#{paths[1]}"
|
169
|
+
else
|
164
170
|
relation = datasource.get_collection(relation_schema.foreign_collection)
|
165
171
|
child_field = to_child_collection[relation_name] || relation_name
|
166
172
|
|
@@ -188,7 +194,8 @@ module ForestAdminDatasourceCustomizer
|
|
188
194
|
field_schema = schema[:fields][field]
|
189
195
|
|
190
196
|
# Perform the mapping, recurse for relation
|
191
|
-
if field_schema.type == 'Column' || field_schema.type == 'PolymorphicManyToOne' ||
|
197
|
+
if field_schema.type == 'Column' || value.nil? || field_schema.type == 'PolymorphicManyToOne' ||
|
198
|
+
field_schema.type == 'PolymorphicOneToOne'
|
192
199
|
record[field] = value
|
193
200
|
else
|
194
201
|
relation = datasource.get_collection(field_schema.foreign_collection)
|
data/lib/forest_admin_datasource_customizer/decorators/search/search_collection_decorator.rb
CHANGED
@@ -104,7 +104,7 @@ module ForestAdminDatasourceCustomizer
|
|
104
104
|
collection.schema[:fields].each do |name, field|
|
105
105
|
fields.push([name, field]) if field.type == 'Column'
|
106
106
|
|
107
|
-
if field.type == 'PolymorphicManyToOne'
|
107
|
+
if field.type == 'PolymorphicManyToOne' && extended
|
108
108
|
ForestAdminAgent::Facades::Container.logger.log(
|
109
109
|
'Debug',
|
110
110
|
"We're not searching through #{self.name}.#{name} because it's a polymorphic relation. " \
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_admin_datasource_customizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.beta.
|
4
|
+
version: 1.0.0.pre.beta.65
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthieu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-08-
|
12
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|