|
|
|
@ -1,33 +1,34 @@
|
|
|
|
|
import { Router } from 'express'; |
|
|
|
|
import { ViewTypes } from 'nocodb-sdk'; |
|
|
|
|
import { T } from 'nc-help'; |
|
|
|
|
import View from '../../models/View'; |
|
|
|
|
import KanbanView from '../../models/KanbanView'; |
|
|
|
|
import ncMetaAclMw from '../../meta/helpers/ncMetaAclMw'; |
|
|
|
|
import { metaApiMetrics } from '../../meta/helpers/apiMetrics'; |
|
|
|
|
import { kanbanViewService } from '../../services'; |
|
|
|
|
import type { KanbanType } from 'nocodb-sdk'; |
|
|
|
|
import type { Request, Response } from 'express'; |
|
|
|
|
|
|
|
|
|
// todo: map to service
|
|
|
|
|
|
|
|
|
|
export async function kanbanViewGet(req: Request, res: Response<KanbanType>) { |
|
|
|
|
res.json(await KanbanView.get(req.params.kanbanViewId)); |
|
|
|
|
res.json( |
|
|
|
|
await kanbanViewService.kanbanViewGet({ |
|
|
|
|
kanbanViewId: req.params.kanbanViewId, |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function kanbanViewCreate(req: Request<any, any>, res) { |
|
|
|
|
T.emit('evt', { evt_type: 'vtable:created', show_as: 'kanban' }); |
|
|
|
|
const view = await View.insert({ |
|
|
|
|
...req.body, |
|
|
|
|
// todo: sanitize
|
|
|
|
|
fk_model_id: req.params.tableId, |
|
|
|
|
type: ViewTypes.KANBAN, |
|
|
|
|
}); |
|
|
|
|
res.json(view); |
|
|
|
|
res.json( |
|
|
|
|
await kanbanViewService.kanbanViewCreate({ |
|
|
|
|
tableId: req.params.tableId, |
|
|
|
|
kanban: req.body, |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function kanbanViewUpdate(req, res) { |
|
|
|
|
T.emit('evt', { evt_type: 'view:updated', type: 'kanban' }); |
|
|
|
|
res.json(await KanbanView.update(req.params.kanbanViewId, req.body)); |
|
|
|
|
res.json( |
|
|
|
|
await kanbanViewService.kanbanViewUpdate({ |
|
|
|
|
kanbanViewId: req.params.kanbanViewId, |
|
|
|
|
kanban: req.body, |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const router = Router({ mergeParams: true }); |
|
|
|
@ -37,14 +38,17 @@ router.post(
|
|
|
|
|
metaApiMetrics, |
|
|
|
|
ncMetaAclMw(kanbanViewCreate, 'kanbanViewCreate') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
router.patch( |
|
|
|
|
'/api/v1/db/meta/kanbans/:kanbanViewId', |
|
|
|
|
metaApiMetrics, |
|
|
|
|
ncMetaAclMw(kanbanViewUpdate, 'kanbanViewUpdate') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
router.get( |
|
|
|
|
'/api/v1/db/meta/kanbans/:kanbanViewId', |
|
|
|
|
metaApiMetrics, |
|
|
|
|
ncMetaAclMw(kanbanViewGet, 'kanbanViewGet') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
export default router; |
|
|
|
|