Skip to content

Commit f02359e

Browse files
committed
feat: add tableRowReplaceInjection prop for customizable row rendering in ResourceListTable components
1 parent d36b564 commit f02359e

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

adminforth/documentation/docs/tutorial/03-Customization/08-pageInjections.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ const props = defineProps<{
442442
record: any
443443
resource: any
444444
meta: any
445+
adminUser: any
445446
}>();
446447
</script>
447448
```
@@ -458,7 +459,7 @@ Component contract:
458459
459460
Notes and tips:
460461
- Requirements:
461-
- Required <tr></tr> structure around </slot>
462+
- Required `<tr></tr>` structure around `<slot />`
462463
463464
## List table beforeActionButtons
464465

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,20 @@
8383
</td>
8484
</tr>
8585

86-
<tr @click="onClick($event,row)"
87-
v-else v-for="(row, rowI) in rows" :key="`row_${row._primaryKeyValue}`"
88-
ref="rowRefs"
89-
class="list-table-body-row bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover"
90-
91-
:class="{'border-b': rowI !== rows.length - 1, 'cursor-pointer': row._clickUrl !== null}"
92-
>
86+
<component
87+
v-else
88+
v-for="(row, rowI) in rows"
89+
:is="tableRowReplaceInjection ? getCustomComponent(tableRowReplaceInjection) : 'tr'"
90+
:key="`row_${row._primaryKeyValue}`"
91+
:record="row"
92+
:resource="resource"
93+
:adminUser="coreStore.adminUser"
94+
:meta="tableRowReplaceInjection ? tableRowReplaceInjection.meta : undefined"
95+
@click="onClick($event, row)"
96+
ref="rowRefs"
97+
class="list-table-body-row bg-lightListTable dark:bg-darkListTable border-lightListBorder dark:border-gray-700 hover:bg-lightListTableRowHover dark:hover:bg-darkListTableRowHover"
98+
:class="{'border-b': rowI !== rows.length - 1, 'cursor-pointer': row._clickUrl !== null}"
99+
>
93100
<td class="w-4 p-4 cursor-default sticky-column bg-lightListTable dark:bg-darkListTable" @click="(e)=>e.stopPropagation()">
94101
<Checkbox
95102
:model-value="checkboxesInternal.includes(row._primaryKeyValue)"
@@ -210,7 +217,7 @@
210217
</div>
211218

212219
</td>
213-
</tr>
220+
</component>
214221
</tbody>
215222
</table>
216223
</div>
@@ -345,6 +352,7 @@ const props = defineProps<{
345352
noRoundings?: boolean,
346353
customActionsInjection?: any[],
347354
tableBodyStartInjection?: any[],
355+
tableRowReplaceInjection?: any,
348356
}>();
349357
350358
// emits, update page

adminforth/spa/src/components/ResourceListTableVirtual.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ const props = defineProps<{
377377
containerHeight?: number,
378378
itemHeight?: number,
379379
bufferSize?: number,
380+
tableRowReplaceInjection?: any
380381
}>();
381382
382383
// emits, update page

0 commit comments

Comments
 (0)