Lib: Allow table value formatting function to return promise

This commit is contained in:
2024-12-23 16:02:47 +01:00
parent 835146e38a
commit 3e0f17faf0
2 changed files with 5 additions and 3 deletions

View File

@ -20,7 +20,7 @@
<thead> <thead>
<tr class="bg-white"> <tr class="bg-white">
{#each columns as col} {#each columns as col}
<th>{col.label}</th> <th class="!px-3">{col.label}</th>
{/each} {/each}
</tr> </tr>
</thead> </thead>
@ -34,7 +34,9 @@
> >
{#each columns as col} {#each columns as col}
{#if col.valuefun} {#if col.valuefun}
<td class="!align-middle">{@html col.valuefun(row[col.data_value_name])}</td> <td class="!align-middle">
{#await col.valuefun(row[col.data_value_name]) then value}{@html value}{/await}
</td>
{:else} {:else}
<td class="!align-middle">{row[col.data_value_name]}</td> <td class="!align-middle">{row[col.data_value_name]}</td>
{/if} {/if}

View File

@ -6,5 +6,5 @@ export interface TableColumn {
label: string; label: string;
/** Any function to further customize the displayed value. May return HTML. */ /** Any function to further customize the displayed value. May return HTML. */
valuefun?: (value: any) => string; valuefun?: (value: any) => Promise<string>;
} }