Prevent pasting in the new row component
This commit is contained in:
parent
3fc6026f5c
commit
6e9939f441
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue