rez_core 4.0.230 → 4.0.234
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.
package/package.json
CHANGED
|
@@ -99,12 +99,13 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
99
99
|
'fla.applicable_entity_type = attr.mapped_entity_type AND fla.applicable_attribute_key = attr.attribute_key',
|
|
100
100
|
)
|
|
101
101
|
.select([
|
|
102
|
-
'fla.applicable_entity_type',
|
|
103
|
-
'
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
|
|
102
|
+
'fla.applicable_entity_type AS applicable_entity_type',
|
|
103
|
+
'fla.applicable_attribute_key AS applicable_attribute_key', // SOURCE KEY (middle_name)
|
|
104
|
+
'fla.attribute_key AS target_attribute_key', // TARGET KEY (father_middle_name)
|
|
105
|
+
'fla.saved_filter_code AS saved_filter_code',
|
|
106
|
+
'attr.name AS name',
|
|
107
|
+
'attr.id AS id'
|
|
108
|
+
])
|
|
108
109
|
.where('attr.organization_id = :orgId', { orgId })
|
|
109
110
|
.getRawMany();
|
|
110
111
|
await this.loggerService.log(
|
|
@@ -215,30 +216,31 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
215
216
|
// 5. Merge linked attributes using saved filters
|
|
216
217
|
for (const linkAttr of safeAttributes.linkedAttributes) {
|
|
217
218
|
const childEntityType = linkAttr.fla_applicable_entity_type;
|
|
218
|
-
const
|
|
219
|
+
const sourceKey = linkAttr.applicable_attribute_key; // source column = middle_name
|
|
220
|
+
const targetKey = linkAttr.attribute_key; // final JSON key = father_middle_name
|
|
219
221
|
|
|
220
|
-
if (!childEntityType || !
|
|
222
|
+
if (!childEntityType || !sourceKey || !targetKey) continue;
|
|
221
223
|
|
|
222
|
-
//
|
|
223
|
-
const mappingValue = mainData?.[
|
|
224
|
+
// value must be taken from applicable_attribute_key
|
|
225
|
+
const mappingValue = mainData?.[sourceKey] ?? null;
|
|
224
226
|
|
|
225
227
|
const value = await this.applyLinkedFilterUsingSavedFilter(
|
|
226
228
|
childEntityType,
|
|
227
|
-
linkAttr.fla_saved_filter_code,
|
|
228
|
-
|
|
229
|
+
linkAttr.fla_saved_filter_code,
|
|
230
|
+
sourceKey,
|
|
229
231
|
mappingValue,
|
|
230
|
-
|
|
232
|
+
targetKey, // IMPORTANT → write to father_middle_name
|
|
231
233
|
loggedInUser,
|
|
232
234
|
entityId
|
|
233
235
|
);
|
|
234
236
|
|
|
235
237
|
if (value !== null && value !== undefined) {
|
|
236
|
-
//
|
|
237
|
-
const flatKey = attrMap[childAttributeKey] || childAttributeKey;
|
|
238
|
+
const flatKey = targetKey; // do NOT use childAttributeKey
|
|
238
239
|
flatJson[flatKey] = value;
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
242
|
|
|
243
|
+
|
|
242
244
|
// 6. Save JSON
|
|
243
245
|
await this.dataSource.query(
|
|
244
246
|
`INSERT INTO frm_entity_json (entity_type, entity_id, json_data, created_by)
|