Skip to content

Commit f130871

Browse files
committed
fix: update save records logic
1 parent a4cf2a8 commit f130871

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

index.ts

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -625,36 +625,17 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
625625
}
626626
}
627627
}
628-
try {
629-
const AuditLogPlugin:any = this.adminforth.getPluginByClassName('AuditLogPlugin');
630-
if (AuditLogPlugin) {
631-
632-
for (const [key, value] of Object.entries(oldRecord)) {
633-
if (!(key in fieldsToUpdate[idx])) {
634-
delete oldRecord[key];
635-
}
636-
}
637-
638-
const reorderedOldRecord = Object.keys(fieldsToUpdate[idx]).reduce((acc, key) => {
639-
if (key in oldRecord) {
640-
acc[key] = oldRecord[key];
641-
}
642-
return acc;
643-
}, {} as Record<string, unknown>);
644-
645-
AuditLogPlugin.logCustomAction({
646-
resourceId: this.resourceConfig.resourceId,
647-
recordId: ID,
648-
actionId: 'Bulk-ai-flow',
649-
oldData: reorderedOldRecord,
650-
data: fieldsToUpdate[idx],
651-
user: adminUser,
652-
headers: headers
653-
});
654-
}
655-
} catch (error) { }
656-
657-
return this.adminforth.resource(this.resourceConfig.resourceId).update(ID, fieldsToUpdate[idx])
628+
const newRecord = {
629+
...oldRecord,
630+
...fieldsToUpdate[idx]
631+
};
632+
return this.adminforth.updateResourceRecord({
633+
resource: this.resourceConfig,
634+
recordId: ID,
635+
oldRecord: oldRecord,
636+
record: newRecord,
637+
adminUser: adminUser,
638+
})
658639
});
659640
await Promise.all(updates);
660641
return { ok: true };

0 commit comments

Comments
 (0)