Skip to content

Commit bb3d071

Browse files
bryanjnelsonCarsonF
authored andcommitted
Add Organization.reach
1 parent 8064521 commit bb3d071

File tree

7 files changed

+43
-0
lines changed

7 files changed

+43
-0
lines changed

src/components/organization/dto/create-organization.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql';
22
import { Type } from 'class-transformer';
33
import { ValidateNested } from 'class-validator';
44
import { NameField } from '../../../common';
5+
import { OrganizationReach } from './organization-reach.dto';
56
import { OrganizationType } from './organization-type.dto';
67
import { Organization } from './organization.dto';
78

@@ -18,6 +19,9 @@ export abstract class CreateOrganization {
1819

1920
@Field(() => [OrganizationType], { nullable: true })
2021
readonly types?: readonly OrganizationType[];
22+
23+
@Field(() => [OrganizationReach], { nullable: true })
24+
readonly reach?: readonly OrganizationReach[];
2125
}
2226

2327
@InputType()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ObjectType } from '@nestjs/graphql';
2+
import { EnumType, makeEnum, SecuredEnumList } from '~/common';
3+
4+
/**
5+
* The reach of the organization.
6+
*/
7+
export type OrganizationReach = EnumType<typeof OrganizationReach>;
8+
export const OrganizationReach = makeEnum({
9+
name: 'OrganizationReach',
10+
description: 'The reach of the organization',
11+
values: ['Local', 'Regional', 'National', 'Global'],
12+
});
13+
14+
@ObjectType({
15+
description: SecuredEnumList.descriptionFor('organization reach'),
16+
})
17+
export class SecuredOrganizationReach extends SecuredEnumList(
18+
OrganizationReach,
19+
) {}

src/components/organization/dto/organization.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
SensitivityField,
1515
} from '../../../common';
1616
import { Location } from '../../location/dto';
17+
import { SecuredOrganizationReach } from './organization-reach.dto';
1718
import { SecuredOrganizationTypes } from './organization-type.dto';
1819

1920
@RegisterResource()
@@ -45,6 +46,9 @@ export class Organization extends Resource {
4546

4647
@Field()
4748
readonly types: SecuredOrganizationTypes;
49+
50+
@Field()
51+
readonly reach: SecuredOrganizationReach;
4852
}
4953

5054
@ObjectType({

src/components/organization/dto/update-organization.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Field, InputType, ObjectType } from '@nestjs/graphql';
22
import { Type } from 'class-transformer';
33
import { ValidateNested } from 'class-validator';
44
import { ID, IdField, NameField } from '../../../common';
5+
import { OrganizationReach } from './organization-reach.dto';
56
import { OrganizationType } from './organization-type.dto';
67
import { Organization } from './organization.dto';
78

@@ -21,6 +22,9 @@ export abstract class UpdateOrganization {
2122

2223
@Field(() => [OrganizationType], { nullable: true })
2324
readonly types?: readonly OrganizationType[];
25+
26+
@Field(() => [OrganizationReach], { nullable: true })
27+
readonly reach?: readonly OrganizationReach[];
2428
}
2529

2630
@InputType()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { BaseMigration, Migration } from '~/core';
2+
import { Organization } from '../dto';
3+
4+
@Migration('2023-08-04T00:00:00')
5+
export class AddOrganizationReachMigration extends BaseMigration {
6+
async up() {
7+
await this.addProperty(Organization, 'reach', []);
8+
}
9+
}

src/components/organization/organization.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { forwardRef, Module } from '@nestjs/common';
22
import { AuthorizationModule } from '../authorization/authorization.module';
33
import { LocationModule } from '../location/location.module';
4+
import { AddOrganizationReachMigration } from './migrations/add-reach.migration';
45
import { AddOrganizationTypeMigration } from './migrations/add-type.migration';
56
import { OrganizationLoader } from './organization.loader';
67
import { OrganizationRepository } from './organization.repository';
@@ -14,6 +15,7 @@ import { OrganizationService } from './organization.service';
1415
OrganizationService,
1516
OrganizationRepository,
1617
OrganizationLoader,
18+
AddOrganizationReachMigration,
1719
AddOrganizationTypeMigration,
1820
],
1921
exports: [OrganizationService],

src/components/organization/organization.repository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class OrganizationRepository extends DtoRepository<
2929
acronym: input.acronym,
3030
address: input.address,
3131
types: input.types ?? [],
32+
reach: input.reach ?? [],
3233
canDelete: true,
3334
};
3435

0 commit comments

Comments
 (0)