mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
6 changed files with 101 additions and 1 deletions
@ -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(); |
||||
}); |
||||
}); |
@ -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, |
||||
}); |
||||
} |
||||
} |
@ -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 {} |
@ -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(); |
||||
}); |
||||
}); |
@ -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…
Reference in new issue