From 8f5c5cc75835d813dbf1c5acdb5f23825765f562 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 21 Feb 2023 11:10:26 +0000 Subject: [PATCH] Make sticky column the primary display and fix opening options cells --- .../app/spreadsheet/OptionsCell.svelte | 10 +++++++++- .../app/spreadsheet/Spreadsheet.svelte | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/app/spreadsheet/OptionsCell.svelte b/packages/client/src/components/app/spreadsheet/OptionsCell.svelte index ee75ededac..1d4fc0c85b 100644 --- a/packages/client/src/components/app/spreadsheet/OptionsCell.svelte +++ b/packages/client/src/components/app/spreadsheet/OptionsCell.svelte @@ -41,6 +41,14 @@ } } } + + const toggleOpen = () => { + if (multi) { + open = true + } else { + open = !open + } + }
(open = true) : null} + on:click={editable ? toggleOpen : null} >
{#each values as val (val)} diff --git a/packages/client/src/components/app/spreadsheet/Spreadsheet.svelte b/packages/client/src/components/app/spreadsheet/Spreadsheet.svelte index d772e88505..dc7f715d90 100644 --- a/packages/client/src/components/app/spreadsheet/Spreadsheet.svelte +++ b/packages/client/src/components/app/spreadsheet/Spreadsheet.svelte @@ -36,11 +36,12 @@ query, limit, }) - $: fields = Object.keys($fetch.schema || {}) + $: schema = $fetch.schema + $: primaryDisplay = $fetch.definition?.primaryDisplay + $: fields = getFields(schema, primaryDisplay) $: fieldCount = fields.length $: fieldCount, initWidths() $: gridStyles = getGridStyles(widths) - $: schema = $fetch.schema $: rowCount = $fetch.rows?.length || 0 $: selectedRowCount = Object.values(selectedRows).filter(x => !!x).length $: rows = getSortedRows($fetch.rows, newRows) @@ -59,6 +60,14 @@ }) } + const getFields = (schema, primaryDisplay) => { + let fields = Object.keys(schema || {}) + if (primaryDisplay) { + fields = [primaryDisplay, ...fields.filter(x => x !== primaryDisplay)] + } + return fields + } + const initWidths = () => { widths = fields.map(() => defaultWidth) } @@ -293,7 +302,7 @@
addRow(field)}