diff --git a/src/lib/components/DataDisplay/TableDisplay.svelte b/src/lib/components/DataDisplay/TableDisplay.svelte index 157207e1..bc077f78 100644 --- a/src/lib/components/DataDisplay/TableDisplay.svelte +++ b/src/lib/components/DataDisplay/TableDisplay.svelte @@ -8,37 +8,68 @@ TableSearch } from 'flowbite-svelte'; + // variables export let data = [{ id: 1, name: 'testA', time: 2017, status: 'good' }]; + export let caption = + 'Hier finden sie eine Übersicht über alle abgeschlossenen und ausstehenden Meilensteine für die momentane Bestandsaufnahme.'; + export let statusIndicator = { good: 'bg-green-500', bad: 'bg-red-500', warn: 'bg-yellow-500' }; + export let statusColumns = ['status']; + + export let searchableColumns = ['name']; + // functionality let searchTerm = ''; + // make the placeholdertext for the searchbar dynamic + const numCols = Object.keys(data[0]).length; + let placeholderText = 'Search ' + searchableColumns[0]; + + if (searchableColumns.length > 1 && searchableColumns.length < numCols - 1) { + placeholderText = 'Search ' + `any of ${searchableColumns.join(', ')}`; + } else if (searchableColumns.length >= numCols - 1 && searchableColumns.length < numCols) { + const difference = Object.keys(data[0]).filter((key) => !searchableColumns.includes(key)); + placeholderText = 'Search all columns except ' + `${difference.join(', ')}`; + } else if (searchableColumns.length === numCols) { + placeholderText = 'Search all columns'; + } + + // TODO: adjust this to searchable stuff $: filteredItems = data.filter( (item) => item.name.toLowerCase().indexOf(searchTerm.toLowerCase()) !== -1 ); - - function extractStatusIndicator(status) { - return statusIndicator?.[status] || ''; - } - + + + {caption} + - ID - Name - Result + {#each Object.keys(data[0]) as key} + {key} + {/each} {#each filteredItems as item} - {item.id} - {item.name} - {item.status} + {#each Object.entries(item) as pair} + {#if statusColumns.includes(pair[0])} + {pair[1]} + {:else} + {pair[1]} + {/if} + {/each} {/each} diff --git a/src/routes/feedback/+page.svelte b/src/routes/feedback/+page.svelte deleted file mode 100644 index 94572bd3..00000000 --- a/src/routes/feedback/+page.svelte +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/src/routes/nextdropdown/+page.svelte b/src/routes/nextdropdown/+page.svelte index 4db0cb8d..c5316f51 100644 --- a/src/routes/nextdropdown/+page.svelte +++ b/src/routes/nextdropdown/+page.svelte @@ -40,7 +40,7 @@ diff --git a/src/routes/surveyfeedback/+page.svelte b/src/routes/surveyfeedback/+page.svelte new file mode 100644 index 00000000..284fb941 --- /dev/null +++ b/src/routes/surveyfeedback/+page.svelte @@ -0,0 +1,27 @@ + + + + + diff --git a/src/routes/trafficlightfeedback/+page.svelte b/src/routes/trafficlightfeedback/+page.svelte new file mode 100644 index 00000000..4d279187 --- /dev/null +++ b/src/routes/trafficlightfeedback/+page.svelte @@ -0,0 +1,69 @@ + + + + +