1
0
Fork 0
mirror of synced 2024-09-10 22:46:09 +12:00

Merge branch 'views-v2-frontend' of github.com:Budibase/budibase into views-v2-frontend

This commit is contained in:
mike12345567 2023-08-11 13:18:16 +01:00
commit 74005761d7
4 changed files with 33 additions and 5 deletions

View file

@ -9,7 +9,7 @@
$: datasource = {
type: "viewV2",
id,
tableId: id?.split("_").slice(0, -1).join("_"),
tableId: $viewsV2.selected?.tableId
}
const handleGridViewUpdate = async e => {

View file

@ -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,
})

View file

@ -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

View file

@ -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,
}
}