forest_admin_datasource_customizer 1.0.0.pre.beta.89 → 1.0.0.pre.beta.90
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/publication/publication_collection_decorator.rb +1 -2
- data/lib/forest_admin_datasource_customizer/decorators/publication/publication_datasource_decorator.rb +2 -1
- data/lib/forest_admin_datasource_customizer/decorators/relation/relation_collection_decorator.rb +4 -4
- data/lib/forest_admin_datasource_customizer/decorators/rename_collection/rename_collection_datasource_decorator.rb +2 -1
- data/lib/forest_admin_datasource_customizer/decorators/search/search_collection_decorator.rb +2 -2
- data/lib/forest_admin_datasource_customizer/decorators/write/write_replace/write_replace_collection_decorator.rb +1 -1
- data/lib/forest_admin_datasource_customizer/plugins/import_field.rb +2 -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: 109d2802a468e5ba0619dbc7ef6e34d50ecb50d08f881520cead2c003986797c
|
4
|
+
data.tar.gz: 62291765be8a719d788b4a69425f2f94d4d2da56e3282a6c3e013e7d42a6da5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10670d71629f95e4e65a1c18fb722f4ba8d3046b400c737602199426f7e1ba180e0a6d03ff6f4de2a0c8c6c74d4a32c57eec4432f825dbf7596989f150fe9a92
|
7
|
+
data.tar.gz: 05a182833649a5204cbbf63e38a4e3019461d17619c6128381338e1238b5e843252967f8585d2852257b13b175420bab42b597ccd7986c05b610134805ae6eb1
|
@@ -70,8 +70,7 @@ module ForestAdminDatasourceCustomizer
|
|
70
70
|
)
|
71
71
|
end
|
72
72
|
|
73
|
-
if
|
74
|
-
field.type == 'PolymorphicOneToOne' || field.type == 'PolymorphicOneToMany'
|
73
|
+
if %w[OneToOne OneToMany PolymorphicOneToOne PolymorphicOneToMany].include?(field.type)
|
75
74
|
return (
|
76
75
|
datasource.published?(field.foreign_collection) &&
|
77
76
|
datasource.get_collection(field.foreign_collection).published?(field.origin_key) &&
|
@@ -51,8 +51,9 @@ module ForestAdminDatasourceCustomizer
|
|
51
51
|
|
52
52
|
def validate_is_removable(collection_name)
|
53
53
|
collection = get_collection(collection_name)
|
54
|
+
polymorphic_relations = %w[PolymorphicOneToOne PolymorphicOneToMany]
|
54
55
|
collection.schema[:fields].each do |field_name, field_schema|
|
55
|
-
next unless
|
56
|
+
next unless polymorphic_relations.include?(field_schema.type)
|
56
57
|
|
57
58
|
inverse = ForestAdminDatasourceToolkit::Utils::Collection.get_inverse_relation(collection, field_name)
|
58
59
|
|
data/lib/forest_admin_datasource_customizer/decorators/relation/relation_collection_decorator.rb
CHANGED
@@ -129,7 +129,7 @@ module ForestAdminDatasourceCustomizer
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def check_foreign_keys(relation)
|
132
|
-
return unless
|
132
|
+
return unless ['ManyToOne', 'ManyToMany'].include?(relation.type)
|
133
133
|
|
134
134
|
check_keys(
|
135
135
|
relation.type == 'ManyToMany' ? datasource.get_collection(relation.through_collection) : self,
|
@@ -140,7 +140,7 @@ module ForestAdminDatasourceCustomizer
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def check_origin_keys(relation)
|
143
|
-
return unless
|
143
|
+
return unless %w[OneToMany OneToOne ManyToMany].include?(relation.type)
|
144
144
|
|
145
145
|
check_keys(
|
146
146
|
relation.type == 'ManyToMany' ? datasource.get_collection(relation.through_collection) : datasource.get_collection(relation.foreign_collection),
|
@@ -177,7 +177,7 @@ module ForestAdminDatasourceCustomizer
|
|
177
177
|
prefix = field.split(':').first
|
178
178
|
field_schema = schema[:fields][prefix]
|
179
179
|
|
180
|
-
return [field] if
|
180
|
+
return [field] if ['Column', 'PolymorphicManyToOne'].include?(field_schema.type)
|
181
181
|
|
182
182
|
relation = datasource.get_collection(field_schema.foreign_collection)
|
183
183
|
result = []
|
@@ -252,7 +252,7 @@ module ForestAdminDatasourceCustomizer
|
|
252
252
|
records.each do |record|
|
253
253
|
record[name] = sub_records.find { |sr| sr[field_schema.foreign_key_target] == record[field_schema.foreign_key] }
|
254
254
|
end
|
255
|
-
elsif
|
255
|
+
elsif ['OneToOne', 'OneToMany'].include?(field_schema.type)
|
256
256
|
ids = records.filter_map { |record| record[field_schema.origin_key_target] }.uniq
|
257
257
|
sub_filter = Filter.new(condition_tree: ConditionTreeLeaf.new(field_schema.origin_key, 'In', ids))
|
258
258
|
sub_records = association.list(caller, sub_filter, projection.union([field_schema.origin_key]))
|
@@ -55,8 +55,9 @@ module ForestAdminDatasourceCustomizer
|
|
55
55
|
"Cannot rename a collection twice: #{@to_child_name[current_name]}->#{current_name}->#{new_name}"
|
56
56
|
end
|
57
57
|
|
58
|
+
polymorphic_relations = %w[PolymorphicOneToOne PolymorphicOneToMany]
|
58
59
|
get_collection(current_name).schema[:fields].each do |field_name, field_schema|
|
59
|
-
next unless
|
60
|
+
next unless polymorphic_relations.include?(field_schema.type)
|
60
61
|
|
61
62
|
reverse_relation_name = Utils::Collection.get_inverse_relation(get_collection(current_name), field_name)
|
62
63
|
|
data/lib/forest_admin_datasource_customizer/decorators/search/search_collection_decorator.rb
CHANGED
@@ -118,8 +118,8 @@ module ForestAdminDatasourceCustomizer
|
|
118
118
|
)
|
119
119
|
end
|
120
120
|
|
121
|
-
|
122
|
-
|
121
|
+
to_one_relations = %w[ManyToOne OneToOne PolymorphicOneToOne]
|
122
|
+
next unless extended && to_one_relations.include?(field.type)
|
123
123
|
|
124
124
|
related = @child_collection.datasource.get_collection(field.foreign_collection)
|
125
125
|
|
@@ -95,7 +95,7 @@ module ForestAdminDatasourceCustomizer
|
|
95
95
|
new_patch = rewrite_patch(context.caller, context.action, field_patch.except(key), used + [key])
|
96
96
|
|
97
97
|
is_value ? deep_merge({ key => value }, new_patch) : new_patch
|
98
|
-
elsif
|
98
|
+
elsif ['ManyToOne', 'OneToOne'].include?(field_schema&.type)
|
99
99
|
# Delegate relations to the appropriate collection.
|
100
100
|
relation = datasource.get_collection(field_schema.foreign_collection)
|
101
101
|
|
@@ -17,10 +17,11 @@ module ForestAdminDatasourceCustomizer
|
|
17
17
|
raise ForestException, "Field #{field} not found in collection #{collection.name}"
|
18
18
|
end
|
19
19
|
|
20
|
+
to_one_relations = %w[ManyToOne OneToOne]
|
20
21
|
field_schema = collection.schema[:fields][field]
|
21
22
|
if field_schema.type == 'Column'
|
22
23
|
{ schema: field_schema }
|
23
|
-
elsif
|
24
|
+
elsif to_one_relations.include?(field_schema.type)
|
24
25
|
{ collection: field_schema.foreign_collection }
|
25
26
|
end
|
26
27
|
end
|
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.90
|
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: 2025-01-
|
12
|
+
date: 2025-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|