From 88c475e4cb24494a63fe9b21a497728380ec368c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 10 May 2023 16:00:12 +0100 Subject: [PATCH 1/5] Add grid menu items to copy row ID and rev --- .../grid/overlays/MenuOverlay.svelte | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte b/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte index 89e4d3503b..d0379edee6 100644 --- a/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte +++ b/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte @@ -1,5 +1,11 @@ {#if $menu.visible} @@ -64,6 +75,22 @@ > Edit row in modal + copyToClipboard($focusedRow?._id)} + on:click={menu.actions.close} + > + Copy row _id + + copyToClipboard($focusedRow?._rev)} + on:click={menu.actions.close} + > + Copy row _rev + Date: Wed, 10 May 2023 16:00:27 +0100 Subject: [PATCH 2/5] Fix not properly updating row state for formula columns --- packages/frontend-core/src/components/grid/stores/rows.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/frontend-core/src/components/grid/stores/rows.js b/packages/frontend-core/src/components/grid/stores/rows.js index 694b66629b..b6dc8c05d0 100644 --- a/packages/frontend-core/src/components/grid/stores/rows.js +++ b/packages/frontend-core/src/components/grid/stores/rows.js @@ -338,15 +338,11 @@ export const deriveStores = context => { ...state, [rowId]: true, })) - const newRow = { ...row, ...get(rowChangeCache)[rowId] } - const saved = await API.saveRow(newRow) + const saved = await API.saveRow({ ...row, ...get(rowChangeCache)[rowId] }) // Update state after a successful change rows.update(state => { - state[index] = { - ...newRow, - _rev: saved._rev, - } + state[index] = saved return state.slice() }) rowChangeCache.update(state => { From d146aae08421048081df090d0d9f19fe704fb8eb Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 10 May 2023 16:02:00 +0100 Subject: [PATCH 3/5] Treat formula cell as readonly! --- packages/frontend-core/src/components/grid/cells/DataCell.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/frontend-core/src/components/grid/cells/DataCell.svelte b/packages/frontend-core/src/components/grid/cells/DataCell.svelte index 0aa0cd54f4..f39b820632 100644 --- a/packages/frontend-core/src/components/grid/cells/DataCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/DataCell.svelte @@ -32,6 +32,7 @@ $: readonly = column.schema.autocolumn || column.schema.disabled || + column.schema.type === "formula" || (!$config.allowEditRows && row._id) // Register this cell API if the row is focused From 59ea4460f9ce211694468789e3adf23b661b3dca Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 11 May 2023 10:51:44 +0100 Subject: [PATCH 4/5] Fix multiple issues with keypresses and date cells due to flatpickr --- packages/bbui/src/Form/Core/DatePicker.svelte | 16 ++++++++-- .../src/components/grid/cells/DateCell.svelte | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/packages/bbui/src/Form/Core/DatePicker.svelte b/packages/bbui/src/Form/Core/DatePicker.svelte index 2c89a538a3..ad39136142 100644 --- a/packages/bbui/src/Form/Core/DatePicker.svelte +++ b/packages/bbui/src/Form/Core/DatePicker.svelte @@ -18,10 +18,14 @@ export let ignoreTimezones = false export let time24hr = false export let range = false + export let flatpickr + export let useKeyboardShortcuts = true + const dispatch = createEventDispatcher() const flatpickrId = `${uuid()}-wrapper` + let open = false - let flatpickr, flatpickrOptions + let flatpickrOptions // Another classic flatpickr issue. Errors were randomly being thrown due to // flatpickr internal code. Making sure that "destroy" is a valid function @@ -59,6 +63,8 @@ dispatch("change", timestamp.toISOString()) } }, + onOpen: () => dispatch("open"), + onClose: () => dispatch("close"), } $: redrawOptions = { @@ -113,12 +119,16 @@ const onOpen = () => { open = true - document.addEventListener("keyup", clearDateOnBackspace) + if (useKeyboardShortcuts) { + document.addEventListener("keyup", clearDateOnBackspace) + } } const onClose = () => { open = false - document.removeEventListener("keyup", clearDateOnBackspace) + if (useKeyboardShortcuts) { + document.removeEventListener("keyup", clearDateOnBackspace) + } // Manually blur all input fields since flatpickr creates a second // duplicate input field. diff --git a/packages/frontend-core/src/components/grid/cells/DateCell.svelte b/packages/frontend-core/src/components/grid/cells/DateCell.svelte index 0112bcda15..f5b1acb1c8 100644 --- a/packages/frontend-core/src/components/grid/cells/DateCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/DateCell.svelte @@ -1,12 +1,17 @@
@@ -42,6 +67,10 @@ {timeOnly} time24hr ignoreTimezones={schema.ignoreTimezones} + bind:flatpickr + on:open={() => (isOpen = true)} + on:close={() => (isOpen = false)} + useKeyboardShortcuts={false} />
{/if} From 5a0ae3ff01f1dc72c03d12e31c1ab0379dca884d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 11 May 2023 11:58:26 +0100 Subject: [PATCH 5/5] Disable most context menu options for cells in the new row --- .../src/components/grid/overlays/MenuOverlay.svelte | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte b/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte index d0379edee6..15ca08dbdf 100644 --- a/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte +++ b/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte @@ -7,6 +7,7 @@ notifications, } from "@budibase/bbui" import { getContext } from "svelte" + import { NewRowID } from "../lib/constants" const { focusedRow, @@ -20,9 +21,11 @@ clipboard, dispatch, focusedCellAPI, + focusedRowId, } = getContext("grid") $: style = makeStyle($menu) + $: isNewRow = $focusedRowId === NewRowID const makeStyle = menu => { return `left:${menu.left}px; top:${menu.top}px;` @@ -69,7 +72,7 @@
dispatch("edit-row", $focusedRow)} on:click={menu.actions.close} > @@ -77,7 +80,7 @@ copyToClipboard($focusedRow?._id)} on:click={menu.actions.close} > @@ -85,7 +88,7 @@ copyToClipboard($focusedRow?._rev)} on:click={menu.actions.close} > @@ -93,14 +96,14 @@ Duplicate row Delete row