From 69c7c967924e6ac66eb1023354d82c3bf27f7b40 Mon Sep 17 00:00:00 2001 From: Bryan Nelson Date: Wed, 18 Dec 2024 14:19:13 -0500 Subject: [PATCH] Add `approvedPrograms` to `Partner` object --- dbschema/partner.esdl | 1 + src/components/partner/dto/create-partner.dto.ts | 5 +++++ src/components/partner/dto/partner.dto.ts | 5 ++++- src/components/partner/dto/update-partner.dto.ts | 5 +++++ src/components/partner/partner.repository.ts | 1 + src/components/project/dto/project-type.enum.ts | 10 +++++++++- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dbschema/partner.esdl b/dbschema/partner.esdl index f081bea851..de1eace4af 100644 --- a/dbschema/partner.esdl +++ b/dbschema/partner.esdl @@ -27,6 +27,7 @@ module default { address: str; multi types: Partner::Type; multi financialReportingTypes: Partnership::FinancialReportingType; + multi approvedPrograms: Project::Type; pointOfContact: User; languageOfWiderCommunication: Language; diff --git a/src/components/partner/dto/create-partner.dto.ts b/src/components/partner/dto/create-partner.dto.ts index 0e22744c99..5b9240862b 100644 --- a/src/components/partner/dto/create-partner.dto.ts +++ b/src/components/partner/dto/create-partner.dto.ts @@ -11,6 +11,7 @@ import { NameField, } from '~/common'; import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type.enum'; +import { ProjectType } from '../../project/dto'; import { PartnerType } from './partner-type.enum'; import { Partner } from './partner.dto'; @@ -64,6 +65,10 @@ export abstract class CreatePartner { @DateField({ nullable: true }) readonly startDate?: CalendarDate; + + @Field(() => [ProjectType], { nullable: true }) + @Transform(({ value }) => uniq(value)) + readonly approvedPrograms?: ProjectType[]; } @InputType() diff --git a/src/components/partner/dto/partner.dto.ts b/src/components/partner/dto/partner.dto.ts index e7c43f40d9..db592b7486 100644 --- a/src/components/partner/dto/partner.dto.ts +++ b/src/components/partner/dto/partner.dto.ts @@ -21,7 +21,7 @@ import { Commentable } from '../../comments/dto'; import { SecuredFinancialReportingTypes } from '../../partnership/dto'; import { Pinnable } from '../../pin/dto'; import { Postable } from '../../post/dto'; -import { IProject } from '../../project/dto'; +import { IProject, SecuredProjectTypes } from '../../project/dto'; import { SecuredPartnerTypes } from './partner-type.enum'; const Interfaces = IntersectTypes(Resource, Pinnable, Postable, Commentable); @@ -84,6 +84,9 @@ export class Partner extends Interfaces { description: "Based on the project's sensitivity", }) readonly sensitivity: Sensitivity; + + @Field() + readonly approvedPrograms: SecuredProjectTypes; } @ObjectType({ diff --git a/src/components/partner/dto/update-partner.dto.ts b/src/components/partner/dto/update-partner.dto.ts index 43f34d2547..9be4996ee8 100644 --- a/src/components/partner/dto/update-partner.dto.ts +++ b/src/components/partner/dto/update-partner.dto.ts @@ -11,6 +11,7 @@ import { NameField, } from '~/common'; import { FinancialReportingType } from '../../partnership/dto'; +import { ProjectType } from '../../project/dto'; import { PartnerType } from './partner-type.enum'; import { Partner } from './partner.dto'; @@ -64,6 +65,10 @@ export abstract class UpdatePartner { @DateField({ nullable: true }) readonly startDate?: CalendarDate | null; + + @Field(() => [ProjectType], { nullable: true }) + @Transform(({ value }) => uniq(value)) + readonly approvedPrograms?: ProjectType[]; } @InputType() diff --git a/src/components/partner/partner.repository.ts b/src/components/partner/partner.repository.ts index 8c341f1d6b..e6fefe9517 100644 --- a/src/components/partner/partner.repository.ts +++ b/src/components/partner/partner.repository.ts @@ -78,6 +78,7 @@ export class PartnerRepository extends DtoRepository< address: input.address, modifiedAt: DateTime.local(), canDelete: true, + approvedPrograms: input.approvedPrograms, }; const result = await this.db .query() diff --git a/src/components/project/dto/project-type.enum.ts b/src/components/project/dto/project-type.enum.ts index ca81789d07..9cebaa4400 100644 --- a/src/components/project/dto/project-type.enum.ts +++ b/src/components/project/dto/project-type.enum.ts @@ -1,4 +1,5 @@ -import { EnumType, makeEnum } from '~/common'; +import { ObjectType } from '@nestjs/graphql'; +import { EnumType, makeEnum, SecuredEnum, SecuredEnumList } from '~/common'; export type ProjectType = EnumType; export const ProjectType = makeEnum({ @@ -10,3 +11,10 @@ export const ProjectType = makeEnum({ ], exposeOrder: true, }); + +@ObjectType({ + description: SecuredEnum.descriptionFor('project types'), +}) +export abstract class SecuredProjectTypes extends SecuredEnumList( + ProjectType, +) {}