Browse Source

feat: form view column apis

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
48a2841465
  1. 3
      packages/nocodb-nest/src/app.module.ts
  2. 20
      packages/nocodb-nest/src/modules/form-columns/form-columns.controller.spec.ts
  3. 27
      packages/nocodb-nest/src/modules/form-columns/form-columns.controller.ts
  4. 9
      packages/nocodb-nest/src/modules/form-columns/form-columns.module.ts
  5. 18
      packages/nocodb-nest/src/modules/form-columns/form-columns.service.spec.ts
  6. 25
      packages/nocodb-nest/src/modules/form-columns/form-columns.service.ts

3
packages/nocodb-nest/src/app.module.ts

@ -22,9 +22,10 @@ import { FormsModule } from './modules/forms/forms.module';
import { GridsModule } from './modules/grids/grids.module'; import { GridsModule } from './modules/grids/grids.module';
import { KanbansModule } from './modules/kanbans/kanbans.module'; import { KanbansModule } from './modules/kanbans/kanbans.module';
import { GalleriesModule } from './modules/galleries/galleries.module'; import { GalleriesModule } from './modules/galleries/galleries.module';
import { FormColumnsModule } from './modules/form-columns/form-columns.module';
@Module({ @Module({
imports: [AuthModule, UsersModule, UtilsModule, ProjectsModule, TablesModule, ViewsModule, FiltersModule, SortsModule, ColumnsModule, ViewColumnsModule, BasesModule, HooksModule, SharedBasesModule, FormsModule, GridsModule, KanbansModule, GalleriesModule], imports: [AuthModule, UsersModule, UtilsModule, ProjectsModule, TablesModule, ViewsModule, FiltersModule, SortsModule, ColumnsModule, ViewColumnsModule, BasesModule, HooksModule, SharedBasesModule, FormsModule, GridsModule, KanbansModule, GalleriesModule, FormColumnsModule],
controllers: [], controllers: [],
providers: [Connection, MetaService, JwtStrategy, ExtractProjectIdMiddleware], providers: [Connection, MetaService, JwtStrategy, ExtractProjectIdMiddleware],
exports: [Connection, MetaService], exports: [Connection, MetaService],

20
packages/nocodb-nest/src/modules/form-columns/form-columns.controller.spec.ts

@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FormColumnsController } from './form-columns.controller';
import { FormColumnsService } from './form-columns.service';
describe('FormColumnsController', () => {
let controller: FormColumnsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [FormColumnsController],
providers: [FormColumnsService],
}).compile();
controller = module.get<FormColumnsController>(FormColumnsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

27
packages/nocodb-nest/src/modules/form-columns/form-columns.controller.ts

@ -0,0 +1,27 @@
import { Body, Controller, Param, Patch, UseGuards } from '@nestjs/common';
import {
Acl,
ExtractProjectIdMiddleware,
} from '../../middlewares/extract-project-id/extract-project-id.middleware';
import { FormColumnsService } from './form-columns.service';
import { AuthGuard } from '@nestjs/passport';
class FormColumnUpdateReqType {}
@Controller('form-columns')
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt'))
export class FormColumnsController {
constructor(private readonly formColumnsService: FormColumnsService) {}
@Patch('/api/v1/db/meta/form-columns/:formViewColumnId')
@Acl('columnUpdate')
async columnUpdate(
@Param('formViewColumnId') formViewColumnId: string,
@Body() formViewColumnbody: FormColumnUpdateReqType,
) {
return await this.formColumnsService.columnUpdate({
formViewColumnId,
formViewColumn: formViewColumnbody,
});
}
}

9
packages/nocodb-nest/src/modules/form-columns/form-columns.module.ts

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { FormColumnsService } from './form-columns.service';
import { FormColumnsController } from './form-columns.controller';
@Module({
controllers: [FormColumnsController],
providers: [FormColumnsService]
})
export class FormColumnsModule {}

18
packages/nocodb-nest/src/modules/form-columns/form-columns.service.spec.ts

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { FormColumnsService } from './form-columns.service';
describe('FormColumnsService', () => {
let service: FormColumnsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [FormColumnsService],
}).compile();
service = module.get<FormColumnsService>(FormColumnsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

25
packages/nocodb-nest/src/modules/form-columns/form-columns.service.ts

@ -0,0 +1,25 @@
import { Injectable } from '@nestjs/common';
import { validatePayload } from '../../helpers'
import { FormViewColumn } from '../../models'
import { T } from 'nc-help'
@Injectable()
export class FormColumnsService {
async columnUpdate(param: {
formViewColumnId: string;
// todo: replace with FormColumnReq
formViewColumn: FormViewColumn;
}) {
validatePayload(
'swagger.json#/components/schemas/FormColumnReq',
param.formViewColumn
);
T.emit('evt', { evt_type: 'formViewColumn:updated' });
return await FormViewColumn.update(
param.formViewColumnId,
param.formViewColumn
);
}
}
Loading…
Cancel
Save