1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Prevent pasting in the new row component

This commit is contained in:
Andrew Kingston 2024-06-26 14:52:25 +01:00
parent 3fc6026f5c
commit 6e9939f441
No known key found for this signature in database

View file

@ -1,6 +1,7 @@
import { derived, writable, get } from "svelte/store" import { derived, writable, get } from "svelte/store"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { parseCellID, getCellID } from "../lib/utils" import { parseCellID, getCellID } from "../lib/utils"
import { NewRowID } from "../lib/constants"
export const createStores = () => { export const createStores = () => {
const clipboard = writable({ const clipboard = writable({
@ -13,7 +14,8 @@ export const createStores = () => {
} }
export const deriveStores = context => { export const deriveStores = context => {
const { clipboard, focusedCellAPI, selectedCellCount, config } = context const { clipboard, focusedCellAPI, selectedCellCount, config, focusedRowId } =
context
// Derive whether or not we're able to copy // Derive whether or not we're able to copy
const copyAllowed = derived(focusedCellAPI, $focusedCellAPI => { const copyAllowed = derived(focusedCellAPI, $focusedCellAPI => {
@ -22,12 +24,19 @@ export const deriveStores = context => {
// Derive whether or not we're able to paste // Derive whether or not we're able to paste
const pasteAllowed = derived( const pasteAllowed = derived(
[clipboard, focusedCellAPI, selectedCellCount, config], [clipboard, focusedCellAPI, selectedCellCount, config, focusedRowId],
([$clipboard, $focusedCellAPI, $selectedCellCount, $config]) => { ([
$clipboard,
$focusedCellAPI,
$selectedCellCount,
$config,
$focusedRowId,
]) => {
if ( if (
$clipboard.value == null || $clipboard.value == null ||
!$config.canEditRows || !$config.canEditRows ||
!$focusedCellAPI !$focusedCellAPI ||
$focusedRowId === NewRowID
) { ) {
return false return false
} }