Fix adding rows

This commit is contained in:
Andrew Kingston 2023-07-28 15:57:35 +01:00
parent 5c5015bbc3
commit d83820b583
3 changed files with 14 additions and 7 deletions

View File

@ -23,7 +23,7 @@ export const buildRowEndpoints = API => ({
return
}
return await API.post({
url: `/api/${row.tableId}/rows`,
url: `/api/${row.viewId || row.tableId}/rows`,
body: row,
suppressErrors,
})

View File

@ -22,8 +22,8 @@ const DependencyOrderedStores = [
Filter,
Bounds,
Scroll,
Rows,
Columns,
Rows,
UI,
Validation,
Resize,

View File

@ -90,7 +90,6 @@ export const createActions = context => {
} = context
const instanceLoaded = writable(false)
const fetch = writable(null)
const tableId = writable(null)
// Local cache of row IDs to speed up checking if a row exists
let rowCacheMap = {}
@ -261,10 +260,18 @@ export const createActions = context => {
const addRow = async (row, idx, bubble = false) => {
try {
// Create row
const newRow = await API.saveRow(
{ ...row, tableId: get(tableId) },
SuppressErrors
)
const $datasource = get(datasource)
let newRow = { ...row }
if ($datasource.type === "table") {
newRow.tableId = $datasource.tableId
} else if ($datasource.type === "viewV2") {
newRow.tableId = $datasource.tableId
newRow._viewId = $datasource.id
} else {
return
}
console.log(newRow)
newRow = await API.saveRow(newRow, SuppressErrors)
// Update state
if (idx != null) {