Skip to content

Commit 8f1b95f

Browse files
committed
fix: correctly pass record id to the custom action in list view
1 parent 990bb08 commit 8f1b95f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
:row="row"
195195
:resource="resource"
196196
:adminUser="adminUser"
197-
@callAction="(payload? : Object) => startCustomAction(action.id, payload ?? row)"
197+
@callAction="(payload? : Object) => startCustomAction(action.id, row, payload)"
198198
>
199199
<button
200200
type="button"
@@ -561,7 +561,8 @@ async function deleteRecord(row: any) {
561561
562562
const actionLoadingStates = ref<Record<string | number, boolean>>({});
563563
564-
async function startCustomAction(actionId: string, row: any) {
564+
async function startCustomAction(actionId: string, row: any, extraData: Record<string, any> = {}) {
565+
console.log('Starting custom action', actionId, row);
565566
actionLoadingStates.value[actionId] = true;
566567
567568
const data = await callAdminForthApi({
@@ -571,7 +572,7 @@ async function startCustomAction(actionId: string, row: any) {
571572
resourceId: props.resource?.resourceId,
572573
actionId: actionId,
573574
recordId: row._primaryKeyValue,
574-
extra: row,
575+
extra: extraData,
575576
}
576577
});
577578

adminforth/spa/src/components/ResourceListTableVirtual.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
:row="row"
209209
:resource="resource"
210210
:adminUser="adminUser"
211-
@callAction="(payload? : Object) => startCustomAction(action.id, payload ?? row)"
211+
@callAction="(payload? : Object) => startCustomAction(action.id, row, payload )"
212212
>
213213
<button
214214
type="button"
@@ -586,7 +586,7 @@ async function deleteRecord(row: any) {
586586
587587
const actionLoadingStates = ref<Record<string | number, boolean>>({});
588588
589-
async function startCustomAction(actionId: string, row: any) {
589+
async function startCustomAction(actionId: string, row: any, extraData: Record<string, any> = {}) {
590590
actionLoadingStates.value[actionId] = true;
591591
592592
const data = await callAdminForthApi({
@@ -596,7 +596,7 @@ async function startCustomAction(actionId: string, row: any) {
596596
resourceId: props.resource?.resourceId,
597597
actionId: actionId,
598598
recordId: row._primaryKeyValue,
599-
extra: row
599+
extra: extraData
600600
}
601601
});
602602

0 commit comments

Comments
 (0)