diff --git a/apps/server/src/employees/employees.controller.spec.ts b/apps/server/src/employees/employees.controller.spec.ts index 83042212..e5c7f5b4 100644 --- a/apps/server/src/employees/employees.controller.spec.ts +++ b/apps/server/src/employees/employees.controller.spec.ts @@ -89,7 +89,6 @@ describe('EmployeesController', () => { single: false, createdAt: new Date(1672531200), updatedAt: new Date(1672531200), - signatureFields: [], departmentId: 'department-id', department: { id: 'department-id', @@ -114,7 +113,6 @@ describe('EmployeesController', () => { single: false, createdAt: new Date(1672531200), updatedAt: new Date(1672531200), - signatureFields: [], departmentId: 'department-id', department: { id: 'department-id', diff --git a/apps/server/src/employees/employees.service.ts b/apps/server/src/employees/employees.service.ts index 2fa5f2b0..1fc6056a 100644 --- a/apps/server/src/employees/employees.service.ts +++ b/apps/server/src/employees/employees.service.ts @@ -26,7 +26,16 @@ export class EmployeesService { ), }, include: { - position: { include: { department: true, signatureFields: true } }, + position: { + include: { + department: true, + signatureFields: { + include: { + formTemplate: true, + }, + }, + }, + }, }, }); newEmployee.pswdHash = null; @@ -59,7 +68,16 @@ export class EmployeesService { id: id, }, include: { - position: { include: { department: true, signatureFields: true } }, + position: { + include: { + department: true, + signatureFields: { + include: { + formTemplate: true, + }, + }, + }, + }, }, }); return employee; @@ -78,7 +96,16 @@ export class EmployeesService { }, data: updateEmployeeDto, include: { - position: { include: { department: true, signatureFields: true } }, + position: { + include: { + department: true, + signatureFields: { + include: { + formTemplate: true, + }, + }, + }, + }, }, }); return updatedEmployee; diff --git a/apps/server/src/positions/entities/position.entity.ts b/apps/server/src/positions/entities/position.entity.ts index e6de3419..926ed68c 100644 --- a/apps/server/src/positions/entities/position.entity.ts +++ b/apps/server/src/positions/entities/position.entity.ts @@ -1,7 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { Position } from '@prisma/client'; import { Exclude } from 'class-transformer'; -import { SignatureFieldEntity } from './../../signature-fields/entities/signature-field.entity'; import { DepartmentEntity } from './../../departments/entities/department.entity'; import { IsOptional } from 'class-validator'; @@ -23,9 +22,6 @@ export class PositionEntity implements Position { @ApiProperty() department: DepartmentEntity; - @ApiProperty() - signatureFields: SignatureFieldEntity[]; - @Exclude() createdAt: Date; diff --git a/apps/server/src/signature-fields/entities/signature-field.entity.ts b/apps/server/src/signature-fields/entities/signature-field.entity.ts index 3ec793af..5d34b1f3 100644 --- a/apps/server/src/signature-fields/entities/signature-field.entity.ts +++ b/apps/server/src/signature-fields/entities/signature-field.entity.ts @@ -1,8 +1,7 @@ import { SignatureField } from '@prisma/client'; import { ApiProperty } from '@nestjs/swagger'; import { Exclude } from 'class-transformer'; -import { PositionEntity } from '@server/positions/entities/position.entity'; -import { FormTemplateEntity } from '@server/form-templates/entities/form-template.entity'; +import { PositionEntity } from '../../positions/entities/position.entity'; export class SignatureFieldEntity implements SignatureField { @ApiProperty() @@ -23,16 +22,17 @@ export class SignatureFieldEntity implements SignatureField { @Exclude() signerPositionId: string | null; - @Exclude() - formTemplateId: string; - @ApiProperty() signerPosition: PositionEntity | null; - @ApiProperty() - formTemplate: FormTemplateEntity; + @Exclude() + formTemplateId: string; constructor(partial: Partial) { + if (partial.signerPosition) { + partial.signerPosition = new PositionEntity(partial.signerPosition); + } + Object.assign(this, partial); } }