Fix adding rows
This commit is contained in:
parent
5c5015bbc3
commit
d83820b583
|
@ -23,7 +23,7 @@ export const buildRowEndpoints = API => ({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return await API.post({
|
return await API.post({
|
||||||
url: `/api/${row.tableId}/rows`,
|
url: `/api/${row.viewId || row.tableId}/rows`,
|
||||||
body: row,
|
body: row,
|
||||||
suppressErrors,
|
suppressErrors,
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,8 +22,8 @@ const DependencyOrderedStores = [
|
||||||
Filter,
|
Filter,
|
||||||
Bounds,
|
Bounds,
|
||||||
Scroll,
|
Scroll,
|
||||||
Rows,
|
|
||||||
Columns,
|
Columns,
|
||||||
|
Rows,
|
||||||
UI,
|
UI,
|
||||||
Validation,
|
Validation,
|
||||||
Resize,
|
Resize,
|
||||||
|
|
|
@ -90,7 +90,6 @@ export const createActions = context => {
|
||||||
} = context
|
} = context
|
||||||
const instanceLoaded = writable(false)
|
const instanceLoaded = writable(false)
|
||||||
const fetch = writable(null)
|
const fetch = writable(null)
|
||||||
const tableId = writable(null)
|
|
||||||
|
|
||||||
// Local cache of row IDs to speed up checking if a row exists
|
// Local cache of row IDs to speed up checking if a row exists
|
||||||
let rowCacheMap = {}
|
let rowCacheMap = {}
|
||||||
|
@ -261,10 +260,18 @@ export const createActions = context => {
|
||||||
const addRow = async (row, idx, bubble = false) => {
|
const addRow = async (row, idx, bubble = false) => {
|
||||||
try {
|
try {
|
||||||
// Create row
|
// Create row
|
||||||
const newRow = await API.saveRow(
|
const $datasource = get(datasource)
|
||||||
{ ...row, tableId: get(tableId) },
|
let newRow = { ...row }
|
||||||
SuppressErrors
|
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
|
// Update state
|
||||||
if (idx != null) {
|
if (idx != null) {
|
||||||
|
|
Loading…
Reference in New Issue