Skip to content

Commit c76ac24

Browse files
committed
feat: add support AuditLog pluggin
1 parent 3dd78c8 commit c76ac24

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

custom/visionTable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<Input
7474
type="number"
7575
v-model="selected[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])][n]"
76-
class="w-full "
76+
class="w-full min-w-[80px]"
7777
:fullWidth="true"
7878
/>
7979
</div>

index.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,35 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
387387
}
388388
}
389389
}
390+
try {
391+
const AuditLogPlugin = this.adminforth.getPluginByClassName('AuditLogPlugin');
392+
if (AuditLogPlugin) {
393+
394+
for (const [key, value] of Object.entries(oldRecord)) {
395+
if (!(key in fieldsToUpdate[idx])) {
396+
delete oldRecord[key];
397+
}
398+
}
399+
400+
const reorderedOldRecord = Object.keys(fieldsToUpdate[idx]).reduce((acc, key) => {
401+
if (key in oldRecord) {
402+
acc[key] = oldRecord[key];
403+
}
404+
return acc;
405+
}, {} as Record<string, unknown>);
406+
407+
AuditLogPlugin.logCustomAction({
408+
resourceId: this.resourceConfig.resourceId,
409+
recordId: ID,
410+
actionId: 'Bulk-ai-flow',
411+
oldData: reorderedOldRecord,
412+
data: fieldsToUpdate[idx],
413+
user: adminUser,
414+
headers: headers
415+
});
416+
}
417+
} catch (error) { }
418+
390419
return this.adminforth.resource(this.resourceConfig.resourceId).update(ID, fieldsToUpdate[idx])
391420
});
392421
await Promise.all(updates);

0 commit comments

Comments
 (0)