From aeaebdef6317f22c5d163b52ee3866d8946b2cc6 Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Wed, 8 Nov 2023 10:21:36 +0100 Subject: [PATCH] feat(frontend): add a way to customise the link's label (#2591) --- .../components/display/table/AppCell.svelte | 17 ++++++++++++++++- .../components/wizards/TableColumnWizard.svelte | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/apps/components/display/table/AppCell.svelte b/frontend/src/lib/components/apps/components/display/table/AppCell.svelte index 395ead1311..85f83f2fb2 100644 --- a/frontend/src/lib/components/apps/components/display/table/AppCell.svelte +++ b/frontend/src/lib/components/apps/components/display/table/AppCell.svelte @@ -3,6 +3,15 @@ export let type: 'text' | 'badge' | 'link' = 'text' export let value: any + + type LinkObject = { + href: string + label: string + } + + function isLinkObject(value: any): value is LinkObject { + return value && typeof value === 'object' && 'href' in value && 'label' in value + } {#if type === 'badge'} @@ -10,7 +19,13 @@ {value} {:else if type === 'link'} - {value} + {#if isLinkObject(value)} + + {value.label} + + {:else} + {value} + {/if} {:else} {value} {/if} diff --git a/frontend/src/lib/components/wizards/TableColumnWizard.svelte b/frontend/src/lib/components/wizards/TableColumnWizard.svelte index 34fce66ff1..a2f8a87cf1 100644 --- a/frontend/src/lib/components/wizards/TableColumnWizard.svelte +++ b/frontend/src/lib/components/wizards/TableColumnWizard.svelte @@ -1,5 +1,6 @@