forest_admin_datasource_active_record 1.0.0.pre.beta.94 → 1.0.0.pre.beta.96
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: 32aea28cf7659b7e3903b3ab71404a0a1c6b432a057fc04634378a0e259be677
|
4
|
+
data.tar.gz: 8acfd38b27078bb95ae8b845ec2e669fe6e15e4edb3a585b464004c54ffef325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b2ed1c0961e9630b977c8007cbcfdb7a608d86ef46bb33c700318649efa5db20f03fe819509b6075c76bbfeaa627c25933cd91c112f545e4f33cab5e20d9eaf
|
7
|
+
data.tar.gz: 17b65e9c435ddc9b1dc329f51efeb81aa1e4af14ad1b57c4196cda670dee9c16b5bf98a9b352e73561f82a5d22997aeb2e589eafe529afc06e727b0b1dc2a10f
|
@@ -175,6 +175,18 @@ module ForestAdminDatasourceActiveRecord
|
|
175
175
|
)
|
176
176
|
end
|
177
177
|
end
|
178
|
+
when :has_and_belongs_to_many
|
179
|
+
add_field(
|
180
|
+
association.name.to_s,
|
181
|
+
ForestAdminDatasourceToolkit::Schema::Relations::ManyToManySchema.new(
|
182
|
+
foreign_collection: format_model_name(association.klass.name),
|
183
|
+
origin_key: association.join_primary_key,
|
184
|
+
origin_key_target: association.join_foreign_key,
|
185
|
+
foreign_key: association.association_foreign_key,
|
186
|
+
foreign_key_target: association.association_primary_key,
|
187
|
+
through_collection: association.join_table.classify
|
188
|
+
)
|
189
|
+
)
|
178
190
|
end
|
179
191
|
end
|
180
192
|
end
|
@@ -78,7 +78,8 @@ module ForestAdminDatasourceActiveRecord
|
|
78
78
|
@models << model unless model.abstract_class? ||
|
79
79
|
@models.include?(model) ||
|
80
80
|
!model.table_exists? ||
|
81
|
-
!primary_key?(model)
|
81
|
+
!primary_key?(model) ||
|
82
|
+
model.const_defined?(:VIRTUAL_THROUGH_COLLECTION)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
@@ -101,19 +102,24 @@ module ForestAdminDatasourceActiveRecord
|
|
101
102
|
if @habtm_models.key?(model.table_name)
|
102
103
|
@habtm_models[model.table_name].left_reflection = model.right_reflection
|
103
104
|
# when the second model is added, we can push the HABTM model to the models list
|
104
|
-
|
105
|
+
through_model = make_through_model(
|
105
106
|
model.table_name,
|
106
107
|
[
|
107
108
|
@habtm_models[model.table_name].left_reflection,
|
108
109
|
@habtm_models[model.table_name].right_reflection
|
109
110
|
]
|
110
111
|
)
|
112
|
+
|
113
|
+
add_collection(
|
114
|
+
Collection.new(self, through_model, support_polymorphic_relations: @support_polymorphic_relations)
|
115
|
+
)
|
111
116
|
else
|
112
117
|
@habtm_models[model.table_name] = model
|
113
118
|
end
|
114
119
|
end
|
115
120
|
|
116
121
|
def make_through_model(table_name, associations)
|
122
|
+
through_model_name = table_name.classify
|
117
123
|
through_model = Class.new(ActiveRecord::Base) do
|
118
124
|
class << self
|
119
125
|
attr_accessor :name, :table_name
|
@@ -124,13 +130,15 @@ module ForestAdminDatasourceActiveRecord
|
|
124
130
|
end
|
125
131
|
end
|
126
132
|
|
127
|
-
through_model.name =
|
133
|
+
through_model.name = through_model_name
|
128
134
|
through_model.table_name = table_name
|
129
135
|
through_model.primary_key = [associations[0].foreign_key, associations[1].foreign_key]
|
130
136
|
associations.each do |association|
|
131
137
|
through_model.add_association(association.name, association.options)
|
132
138
|
end
|
133
139
|
|
140
|
+
through_model.const_set(:VIRTUAL_THROUGH_COLLECTION, true)
|
141
|
+
|
134
142
|
through_model
|
135
143
|
end
|
136
144
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_admin_datasource_active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.beta.
|
4
|
+
version: 1.0.0.pre.beta.96
|
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-
|
12
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|