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 = { $: datasource = {
type: "viewV2", type: "viewV2",
id, id,
tableId: id?.split("_").slice(0, -1).join("_"), tableId: $viewsV2.selected?.tableId
} }
const handleGridViewUpdate = async e => { const handleGridViewUpdate = async e => {

View File

@ -23,7 +23,23 @@ export const buildRowEndpoints = API => ({
return return
} }
return await API.post({ 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, body: row,
suppressErrors, suppressErrors,
}) })

View File

@ -57,6 +57,16 @@ export const buildViewV2Endpoints = API => ({
delete: async viewId => { delete: async viewId => {
return await API.delete({ url: `/api/v2/views/${viewId}` }) return await API.delete({ url: `/api/v2/views/${viewId}` })
}, },
/** /**
* Creates a row from a view * Creates a row from a view
* @param row the row to create * @param row the row to create

View File

@ -26,14 +26,16 @@ export const createActions = context => {
const $datasource = get(datasource) const $datasource = get(datasource)
row.tableId = $datasource?.tableId row.tableId = $datasource?.tableId
row._viewId = $datasource?.id 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 updateRow = async row => {
const $datasource = get(datasource) const $datasource = get(datasource)
const savedRow = await API.viewV2.updateRow(row, SuppressErrors)
return { return {
...savedRow, ...await API.patchRow(row, SuppressErrors),
_viewId: $datasource.id, _viewId: $datasource.id,
} }
} }