1
0
Fork 0
mirror of synced 2024-09-20 11:27:56 +12:00

Stringify non strings when pasting into text cells

This commit is contained in:
Andrew Kingston 2024-07-19 16:34:20 +01:00
parent 2473b82ba5
commit 2ecedcea7c
No known key found for this signature in database

View file

@ -5,6 +5,7 @@ import { getCellID, parseCellID } from "../lib/utils"
import { tick } from "svelte" import { tick } from "svelte"
import { Helpers } from "@budibase/bbui" import { Helpers } from "@budibase/bbui"
import { sleep } from "../../../utils/utils" import { sleep } from "../../../utils/utils"
import { FieldType } from "@budibase/types"
export const createStores = () => { export const createStores = () => {
const rows = writable([]) const rows = writable([])
@ -421,8 +422,21 @@ export const createActions = context => {
// valid pending change was made or not // valid pending change was made or not
const stashRowChanges = (rowId, changes) => { const stashRowChanges = (rowId, changes) => {
const $rowLookupMap = get(rowLookupMap) const $rowLookupMap = get(rowLookupMap)
const $columnLookupMap = get(columnLookupMap)
const row = $rowLookupMap[rowId] const row = $rowLookupMap[rowId]
// Coerce some values into the correct types
for (let column of Object.keys(changes || {})) {
const type = $columnLookupMap[column]?.schema?.type
// Stringify objects
if (type === FieldType.STRING || type == FieldType.LONGFORM) {
if (changes[column] != null && typeof changes[column] !== "string") {
changes[column] = JSON.stringify(changes[column])
}
}
}
// Check this is a valid change // Check this is a valid change
if (!row || !changesAreValid(row, changes)) { if (!row || !changesAreValid(row, changes)) {
return false return false