Merge branch 'views-v2-frontend' of github.com:Budibase/budibase into views-v2-frontend
This commit is contained in:
commit
74005761d7
4 changed files with 33 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
|||
$: datasource = {
|
||||
type: "viewV2",
|
||||
id,
|
||||
tableId: id?.split("_").slice(0, -1).join("_"),
|
||||
tableId: $viewsV2.selected?.tableId
|
||||
}
|
||||
|
||||
const handleGridViewUpdate = async e => {
|
||||
|
|
|
@ -23,7 +23,23 @@ export const buildRowEndpoints = API => ({
|
|||
return
|
||||
}
|
||||
return await API.post({
|
||||
url: `/api/${row.viewId || row.tableId}/rows`,
|
||||
url: `/api/${row._viewId || row.tableId}/rows`,
|
||||
body: row,
|
||||
suppressErrors,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Patches a row in a table.
|
||||
* @param row the row to patch
|
||||
* @param suppressErrors whether or not to suppress error notifications
|
||||
*/
|
||||
patchRow: async (row, suppressErrors = false) => {
|
||||
if (!row?.tableId) {
|
||||
return
|
||||
}
|
||||
return await API.patch({
|
||||
url: `/api/${row._viewId || row.tableId}/rows`,
|
||||
body: row,
|
||||
suppressErrors,
|
||||
})
|
||||
|
|
|
@ -57,6 +57,16 @@ export const buildViewV2Endpoints = API => ({
|
|||
delete: async viewId => {
|
||||
return await API.delete({ url: `/api/v2/views/${viewId}` })
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a row from a view
|
||||
* @param row the row to create
|
||||
|
|
|
@ -26,14 +26,16 @@ export const createActions = context => {
|
|||
const $datasource = get(datasource)
|
||||
row.tableId = $datasource?.tableId
|
||||
row._viewId = $datasource?.id
|
||||
return await API.viewV2.createRow(row, SuppressErrors)
|
||||
return {
|
||||
...await API.saveRow(row, SuppressErrors),
|
||||
_viewId: row._viewId
|
||||
}
|
||||
}
|
||||
|
||||
const updateRow = async row => {
|
||||
const $datasource = get(datasource)
|
||||
const savedRow = await API.viewV2.updateRow(row, SuppressErrors)
|
||||
return {
|
||||
...savedRow,
|
||||
...await API.patchRow(row, SuppressErrors),
|
||||
_viewId: $datasource.id,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue