Lib: Allow table value formatting function to return promise
This commit is contained in:
@ -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}
|
||||||
|
|||||||
@ -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>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user