Skip to content

Commit

Permalink
Add Partner.approvedPrograms (#3347)
Browse files Browse the repository at this point in the history
Co-authored-by: Carson Full <carson_full@tsco.org>
  • Loading branch information
bryanjnelson and CarsonF authored Dec 20, 2024
1 parent 4d35560 commit ec30c04
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions dbschema/migrations/00012-m1ec555.edgeql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dbschema/partner.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module default {
address: str;
multi types: Partner::Type;
multi financialReportingTypes: Partnership::FinancialReportingType;
multi approvedPrograms: Project::Type;

pointOfContact: User;
languageOfWiderCommunication: Language;
Expand Down
5 changes: 5 additions & 0 deletions src/components/partner/dto/create-partner.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NameField,
} from '~/common';
import { FinancialReportingType } from '../../partnership/dto/financial-reporting-type.enum';
import { ProjectType } from '../../project/dto/project-type.enum';
import { PartnerType } from './partner-type.enum';
import { Partner } from './partner.dto';

Expand Down Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion src/components/partner/dto/partner.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -84,6 +84,9 @@ export class Partner extends Interfaces {
description: "Based on the project's sensitivity",
})
readonly sensitivity: Sensitivity;

@Field()
readonly approvedPrograms: SecuredProjectTypes;
}

@ObjectType({
Expand Down
5 changes: 5 additions & 0 deletions src/components/partner/dto/update-partner.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NameField,
} from '~/common';
import { FinancialReportingType } from '../../partnership/dto';
import { ProjectType } from '../../project/dto/project-type.enum';
import { PartnerType } from './partner-type.enum';
import { Partner } from './partner.dto';

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BaseMigration, Migration } from '~/core/database';
import { Partner } from '../dto';

@Migration('2024-12-19T11:00:00')
export class AddPartnerApprovedProgramsMigration extends BaseMigration {
async up() {
await this.addProperty(Partner, 'approvedPrograms', []);
}
}
2 changes: 2 additions & 0 deletions src/components/partner/partner.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LanguageModule } from '../language/language.module';
import { OrganizationModule } from '../organization/organization.module';
import { ProjectModule } from '../project/project.module';
import { UserModule } from '../user/user.module';
import { AddPartnerApprovedProgramsMigration } from './migrations/add-partner-approved-programs.migration';
import { PartnerEdgeDBRepository } from './partner.edgedb.repository';
import { PartnerLoader } from './partner.loader';
import { PartnerRepository } from './partner.repository';
Expand All @@ -26,6 +27,7 @@ import { PartnerService } from './partner.service';
PartnerService,
splitDb(PartnerRepository, PartnerEdgeDBRepository),
PartnerLoader,
AddPartnerApprovedProgramsMigration,
],
exports: [PartnerService],
})
Expand Down
1 change: 1 addition & 0 deletions src/components/partner/partner.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 9 additions & 1 deletion src/components/project/dto/project-type.enum.ts
Original file line number Diff line number Diff line change
@@ -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<typeof ProjectType>;
export const ProjectType = makeEnum({
Expand All @@ -10,3 +11,10 @@ export const ProjectType = makeEnum({
],
exposeOrder: true,
});

@ObjectType({
description: SecuredEnum.descriptionFor('project types'),
})
export abstract class SecuredProjectTypes extends SecuredEnumList(
ProjectType,
) {}

0 comments on commit ec30c04

Please sign in to comment.