From 6dde9e526984970a9f4bc805053621f7730faecd Mon Sep 17 00:00:00 2001 From: gitstart-twenty Date: Tue, 20 Aug 2024 20:20:36 +0000 Subject: [PATCH] If an object is disabled, then the relationships to that object should be disabled --- .../object-metadata.service.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts b/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts index 973a5cf35be5..180ff15019c4 100644 --- a/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts +++ b/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts @@ -5,7 +5,7 @@ import console from 'console'; import { Query, QueryOptions } from '@ptc-org/nestjs-query-core'; import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm'; -import { FindManyOptions, FindOneOptions, Repository } from 'typeorm'; +import { FindManyOptions, FindOneOptions, In, Repository } from 'typeorm'; import { FieldMetadataSettings } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-settings.interface'; @@ -369,6 +369,8 @@ export class ObjectMetadataService extends TypeOrmQueryService { + acc.push(fromFieldMetadataId, toFieldMetadataId); + + return acc; + }, + [] as string[], + ); + + if (affectedFieldIds.length > 0) { + await this.fieldMetadataRepository.update( + { id: In(affectedFieldIds) }, + { isActive: input.update.isActive }, + ); + } + } + } }