Add multi dev collab for viewV2 definitions
This commit is contained in:
parent
0a87e3502e
commit
938a5a445f
|
@ -8,6 +8,7 @@ import {
|
||||||
ViewV2,
|
ViewV2,
|
||||||
RequiredKeys,
|
RequiredKeys,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
import { builderSocket } from "../../../websockets"
|
||||||
|
|
||||||
async function parseSchemaUI(ctx: Ctx, view: CreateViewRequest) {
|
async function parseSchemaUI(ctx: Ctx, view: CreateViewRequest) {
|
||||||
if (!view.schema) {
|
if (!view.schema) {
|
||||||
|
@ -86,6 +87,9 @@ export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
data: result,
|
data: result,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const table = await sdk.tables.getTable(tableId)
|
||||||
|
builderSocket?.emitTableUpdate(ctx, table)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
|
export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
|
||||||
|
@ -118,11 +122,17 @@ export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
data: result,
|
data: result,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const table = await sdk.tables.getTable(tableId)
|
||||||
|
builderSocket?.emitTableUpdate(ctx, table)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remove(ctx: Ctx) {
|
export async function remove(ctx: Ctx) {
|
||||||
const { viewId } = ctx.params
|
const { viewId } = ctx.params
|
||||||
|
|
||||||
await sdk.views.remove(viewId)
|
const view = await sdk.views.remove(viewId)
|
||||||
ctx.status = 204
|
ctx.status = 204
|
||||||
|
|
||||||
|
const table = await sdk.tables.getTable(view.tableId)
|
||||||
|
builderSocket?.emitTableUpdate(ctx, table)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ export function isV2(view: View | ViewV2): view is ViewV2 {
|
||||||
return (view as ViewV2).version === 2
|
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 db = context.getAppDB()
|
||||||
|
|
||||||
const view = await get(viewId)
|
const view = await get(viewId)
|
||||||
|
@ -67,6 +67,7 @@ export async function remove(viewId: string): Promise<void> {
|
||||||
|
|
||||||
delete table.views![view?.name]
|
delete table.views![view?.name]
|
||||||
await db.put(table)
|
await db.put(table)
|
||||||
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
|
export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
|
||||||
|
|
Loading…
Reference in New Issue