Add multi dev collab for viewV2 definitions

This commit is contained in:
Andrew Kingston 2023-08-04 15:04:58 +01:00
parent 0a87e3502e
commit 938a5a445f
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import {
ViewV2,
RequiredKeys,
} from "@budibase/types"
import { builderSocket } from "../../../websockets"
async function parseSchemaUI(ctx: Ctx, view: CreateViewRequest) {
if (!view.schema) {
@ -86,6 +87,9 @@ export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
ctx.body = {
data: result,
}
const table = await sdk.tables.getTable(tableId)
builderSocket?.emitTableUpdate(ctx, table)
}
export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
@ -118,11 +122,17 @@ export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
ctx.body = {
data: result,
}
const table = await sdk.tables.getTable(tableId)
builderSocket?.emitTableUpdate(ctx, table)
}
export async function remove(ctx: Ctx) {
const { viewId } = ctx.params
await sdk.views.remove(viewId)
const view = await sdk.views.remove(viewId)
ctx.status = 204
const table = await sdk.tables.getTable(view.tableId)
builderSocket?.emitTableUpdate(ctx, table)
}

View File

@ -56,7 +56,7 @@ export function isV2(view: View | ViewV2): view is ViewV2 {
return (view as ViewV2).version === 2
}
export async function remove(viewId: string): Promise<void> {
export async function remove(viewId: string): Promise<ViewV2> {
const db = context.getAppDB()
const view = await get(viewId)
@ -67,6 +67,7 @@ export async function remove(viewId: string): Promise<void> {
delete table.views![view?.name]
await db.put(table)
return view
}
export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {