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/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 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} diff --git a/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte b/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte index 89e4d3503b..15ca08dbdf 100644 --- a/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte +++ b/packages/frontend-core/src/components/grid/overlays/MenuOverlay.svelte @@ -1,6 +1,13 @@ {#if $menu.visible} @@ -58,22 +72,38 @@ dispatch("edit-row", $focusedRow)} on:click={menu.actions.close} > 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 + Duplicate row Delete row 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 => {