Fix adding rows
This commit is contained in:
parent
5c5015bbc3
commit
d83820b583
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -22,8 +22,8 @@ const DependencyOrderedStores = [
|
|||
Filter,
|
||||
Bounds,
|
||||
Scroll,
|
||||
Rows,
|
||||
Columns,
|
||||
Rows,
|
||||
UI,
|
||||
Validation,
|
||||
Resize,
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue