forest_admin_datasource_toolkit 1.14.0 → 1.14.2
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14b4d17884efca6a8d8271661dee8120b5cab01d92706e73f47c729ea955a09f
|
|
4
|
+
data.tar.gz: 1d428080c2c5915142969f304cea7ee9aba349bcefbbf211b8fca16a38ace6d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 14da57905ebec6b51577484ce685b558efd9fcd63126883cd8f5d468231a997d953d8e94b2231ac93a2202069fe927c1df2a0317983a0abab2a449a27ee5ac55
|
|
7
|
+
data.tar.gz: 2a88b70e97bafea005a8660010776bf712461380b44055da349e524653e4e33ec0d1a4624b5ddc86b5686f623e5e061a0e510a8bf7a4ef9b19e4b7944de1cd19
|
|
@@ -89,12 +89,15 @@ module ForestAdminDatasourceToolkit
|
|
|
89
89
|
)
|
|
90
90
|
else
|
|
91
91
|
through_collection = collection.datasource.get_collection(relation.through_collection)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
conditions = [
|
|
93
|
+
Nodes::ConditionTreeLeaf.new(relation.origin_key, Operators::EQUAL, origin_value),
|
|
94
|
+
Nodes::ConditionTreeLeaf.new(relation.foreign_key, Operators::PRESENT)
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
# add polymorphic type condition if the through association is polymorphic
|
|
98
|
+
add_polymorphic_condition(conditions, relation)
|
|
99
|
+
|
|
100
|
+
through_tree = ConditionTreeFactory.intersect(conditions)
|
|
98
101
|
records = through_collection.list(
|
|
99
102
|
caller,
|
|
100
103
|
Filter.new(condition_tree: through_tree),
|
|
@@ -141,12 +144,16 @@ module ForestAdminDatasourceToolkit
|
|
|
141
144
|
if foreign_relation && base_foreign_filter.nestable?
|
|
142
145
|
foreign_key = collection.datasource.get_collection(relation.through_collection).schema[:fields][relation.foreign_key]
|
|
143
146
|
base_through_filter = base_foreign_filter.nest(foreign_relation)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
|
|
148
|
+
conditions = [
|
|
149
|
+
Nodes::ConditionTreeLeaf.new(relation.origin_key, Operators::EQUAL, origin_value),
|
|
150
|
+
base_through_filter.condition_tree
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
# add polymorphic type condition if the through association is polymorphic
|
|
154
|
+
add_polymorphic_condition(conditions, relation)
|
|
155
|
+
|
|
156
|
+
condition_tree = ConditionTreeFactory.intersect(conditions)
|
|
150
157
|
|
|
151
158
|
if foreign_key.type == 'Column' && foreign_key.filter_operators.include?(Operators::PRESENT)
|
|
152
159
|
present = Nodes::ConditionTreeLeaf.new(relation.foreign_key, Operators::PRESENT)
|
|
@@ -165,20 +172,33 @@ module ForestAdminDatasourceToolkit
|
|
|
165
172
|
Projection.new([relation.foreign_key_target])
|
|
166
173
|
)
|
|
167
174
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
# only children of parent
|
|
172
|
-
Nodes::ConditionTreeLeaf.new(relation.origin_key, Operators::EQUAL, origin_value),
|
|
175
|
+
conditions = [
|
|
176
|
+
# only children of parent
|
|
177
|
+
Nodes::ConditionTreeLeaf.new(relation.origin_key, Operators::EQUAL, origin_value),
|
|
173
178
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
)
|
|
180
|
-
]
|
|
179
|
+
# only the children which match the conditions in baseForeignFilter
|
|
180
|
+
Nodes::ConditionTreeLeaf.new(
|
|
181
|
+
relation.foreign_key,
|
|
182
|
+
Operators::IN,
|
|
183
|
+
records.map { |r| r[relation.foreign_key_target] }
|
|
181
184
|
)
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
# add polymorphic type condition if the through association is polymorphic
|
|
188
|
+
add_polymorphic_condition(conditions, relation)
|
|
189
|
+
|
|
190
|
+
Filter.new(condition_tree: ConditionTreeFactory.intersect(conditions))
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def self.add_polymorphic_condition(conditions, relation)
|
|
194
|
+
return conditions unless relation.respond_to?(:origin_type_field) &&
|
|
195
|
+
relation.origin_type_field &&
|
|
196
|
+
relation.origin_type_value
|
|
197
|
+
|
|
198
|
+
conditions << Nodes::ConditionTreeLeaf.new(
|
|
199
|
+
relation.origin_type_field,
|
|
200
|
+
Operators::EQUAL,
|
|
201
|
+
relation.origin_type_value
|
|
182
202
|
)
|
|
183
203
|
end
|
|
184
204
|
end
|
|
@@ -2,7 +2,8 @@ module ForestAdminDatasourceToolkit
|
|
|
2
2
|
module Schema
|
|
3
3
|
module Relations
|
|
4
4
|
class ManyToManySchema < RelationSchema
|
|
5
|
-
attr_accessor :origin_key, :through_collection, :foreign_key, :origin_key_target, :foreign_key_target
|
|
5
|
+
attr_accessor :origin_key, :through_collection, :foreign_key, :origin_key_target, :foreign_key_target,
|
|
6
|
+
:origin_type_field, :origin_type_value
|
|
6
7
|
|
|
7
8
|
def initialize(
|
|
8
9
|
origin_key:,
|
|
@@ -10,7 +11,9 @@ module ForestAdminDatasourceToolkit
|
|
|
10
11
|
foreign_key:,
|
|
11
12
|
foreign_key_target:,
|
|
12
13
|
foreign_collection:,
|
|
13
|
-
through_collection
|
|
14
|
+
through_collection:,
|
|
15
|
+
origin_type_field: nil,
|
|
16
|
+
origin_type_value: nil
|
|
14
17
|
)
|
|
15
18
|
super(foreign_collection, 'ManyToMany')
|
|
16
19
|
@origin_key = origin_key
|
|
@@ -18,6 +21,8 @@ module ForestAdminDatasourceToolkit
|
|
|
18
21
|
@through_collection = through_collection
|
|
19
22
|
@foreign_key = foreign_key
|
|
20
23
|
@foreign_key_target = foreign_key_target
|
|
24
|
+
@origin_type_field = origin_type_field
|
|
25
|
+
@origin_type_value = origin_type_value
|
|
21
26
|
end
|
|
22
27
|
end
|
|
23
28
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_datasource_toolkit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.14.
|
|
4
|
+
version: 1.14.2
|
|
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-11-
|
|
12
|
+
date: 2025-11-12 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|