Fix issue where IDs were stripped from rows in grids that were using a link datasource
This commit is contained in:
parent
052c6df713
commit
65c5aefe0f
|
@ -18,7 +18,7 @@
|
||||||
focusedCellAPI,
|
focusedCellAPI,
|
||||||
focusedRowId,
|
focusedRowId,
|
||||||
notifications,
|
notifications,
|
||||||
isDatasourcePlus,
|
hasBudibaseIdentifiers,
|
||||||
} = getContext("grid")
|
} = getContext("grid")
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="Copy"
|
icon="Copy"
|
||||||
disabled={isNewRow || !$focusedRow?._id || !$isDatasourcePlus}
|
disabled={isNewRow || !$focusedRow?._id || !$hasBudibaseIdentifiers}
|
||||||
on:click={() => copyToClipboard($focusedRow?._id)}
|
on:click={() => copyToClipboard($focusedRow?._id)}
|
||||||
on:click={menu.actions.close}
|
on:click={menu.actions.close}
|
||||||
>
|
>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="Copy"
|
icon="Copy"
|
||||||
disabled={isNewRow || !$focusedRow?._rev}
|
disabled={isNewRow || !$focusedRow?._rev || !$hasBudibaseIdentifiers}
|
||||||
on:click={() => copyToClipboard($focusedRow?._rev)}
|
on:click={() => copyToClipboard($focusedRow?._rev)}
|
||||||
on:click={menu.actions.close}
|
on:click={menu.actions.close}
|
||||||
>
|
>
|
||||||
|
|
|
@ -75,14 +75,14 @@ export const deriveStores = context => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const isDatasourcePlus = derived(datasource, $datasource => {
|
const hasBudibaseIdentifiers = derived(datasource, $datasource => {
|
||||||
return ["table", "viewV2"].includes($datasource?.type)
|
return ["table", "viewV2", "link"].includes($datasource?.type)
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
schema,
|
schema,
|
||||||
enrichedSchema,
|
enrichedSchema,
|
||||||
isDatasourcePlus,
|
hasBudibaseIdentifiers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ export const createActions = context => {
|
||||||
error,
|
error,
|
||||||
notifications,
|
notifications,
|
||||||
fetch,
|
fetch,
|
||||||
isDatasourcePlus,
|
hasBudibaseIdentifiers,
|
||||||
refreshing,
|
refreshing,
|
||||||
} = context
|
} = context
|
||||||
const instanceLoaded = writable(false)
|
const instanceLoaded = writable(false)
|
||||||
|
@ -196,9 +196,16 @@ export const createActions = context => {
|
||||||
// Handles validation errors from the rows API and updates local validation
|
// Handles validation errors from the rows API and updates local validation
|
||||||
// state, storing error messages against relevant cells
|
// state, storing error messages against relevant cells
|
||||||
const handleValidationError = (rowId, error) => {
|
const handleValidationError = (rowId, error) => {
|
||||||
|
let errorString
|
||||||
|
if (typeof error === "string") {
|
||||||
|
errorString = error
|
||||||
|
} else if (typeof error?.message === "string") {
|
||||||
|
errorString = error.message
|
||||||
|
}
|
||||||
|
|
||||||
// If the server doesn't reply with a valid error, assume that the source
|
// If the server doesn't reply with a valid error, assume that the source
|
||||||
// of the error is the focused cell's column
|
// of the error is the focused cell's column
|
||||||
if (!error?.json?.validationErrors && error?.message) {
|
if (!error?.json?.validationErrors && errorString) {
|
||||||
const focusedColumn = get(focusedCellId)?.split("-")[1]
|
const focusedColumn = get(focusedCellId)?.split("-")[1]
|
||||||
if (focusedColumn) {
|
if (focusedColumn) {
|
||||||
error = {
|
error = {
|
||||||
|
@ -261,7 +268,7 @@ export const createActions = context => {
|
||||||
focusedCellId.set(`${rowId}-${erroredColumns[0]}`)
|
focusedCellId.set(`${rowId}-${erroredColumns[0]}`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
get(notifications).error(error?.message || "An unknown error occurred")
|
get(notifications).error(errorString || "An unknown error occurred")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,14 +465,14 @@ export const createActions = context => {
|
||||||
}
|
}
|
||||||
let rowsToAppend = []
|
let rowsToAppend = []
|
||||||
let newRow
|
let newRow
|
||||||
const $isDatasourcePlus = get(isDatasourcePlus)
|
const $hasBudibaseIdentifiers = get(hasBudibaseIdentifiers)
|
||||||
for (let i = 0; i < newRows.length; i++) {
|
for (let i = 0; i < newRows.length; i++) {
|
||||||
newRow = newRows[i]
|
newRow = newRows[i]
|
||||||
|
|
||||||
// Ensure we have a unique _id.
|
// Ensure we have a unique _id.
|
||||||
// This means generating one for non DS+, overwriting any that may already
|
// This means generating one for non DS+, overwriting any that may already
|
||||||
// exist as we cannot allow duplicates.
|
// exist as we cannot allow duplicates.
|
||||||
if (!$isDatasourcePlus) {
|
if (!$hasBudibaseIdentifiers) {
|
||||||
newRow._id = Helpers.uuid()
|
newRow._id = Helpers.uuid()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +517,7 @@ export const createActions = context => {
|
||||||
const cleanRow = row => {
|
const cleanRow = row => {
|
||||||
let clone = { ...row }
|
let clone = { ...row }
|
||||||
delete clone.__idx
|
delete clone.__idx
|
||||||
if (!get(isDatasourcePlus)) {
|
if (!get(hasBudibaseIdentifiers)) {
|
||||||
delete clone._id
|
delete clone._id
|
||||||
}
|
}
|
||||||
return clone
|
return clone
|
||||||
|
|
Loading…
Reference in New Issue