Skip to content

Commit 042ff8f

Browse files
authored
Allow FPMs to add engagements while the project is discussing changes to plan (#3388)
1 parent b239437 commit 042ff8f

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

dbschema/migrations/00017-m1d2nmz.edgeql

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { field, Hierarchies, member, Policy } from '../util';
1+
import { any, field, Hierarchies, member, Policy } from '../util';
22

33
@Policy([...Hierarchies.Field, ...Hierarchies.Finance], (r) => [
44
r.Project,
55
r.Engagement.read,
6-
r.Engagement.whenAll(member, field('project.status', 'InDevelopment')).create,
6+
r.Engagement.whenAll(
7+
member,
8+
any(
9+
field('project.status', 'InDevelopment'),
10+
field('project.step', 'DiscussingChangeToPlan'),
11+
),
12+
).create,
713
r.Engagement.whenAll(member, field('status', 'InDevelopment')).delete,
814
])
915
export class EngagementsCreateDeletePolicy {}

src/components/engagement/dto/engagement.dto.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class Engagement extends Interfaces {
7575

7676
declare readonly __typename: DBNames<typeof e.Engagement>;
7777

78-
readonly project: LinkTo<'Project'> & Pick<IProject, 'status' | 'type'>;
78+
readonly project: LinkTo<'Project'> &
79+
Pick<UnsecuredDto<IProject>, 'status' | 'step' | 'type'>;
7980

8081
@Field(() => IProject)
8182
declare readonly parent: BaseNode;

src/components/engagement/engagement.gel.repository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const baseHydrate = e.shape(e.Engagement, (engagement) => ({
2222
project: {
2323
id: true,
2424
status: true,
25+
step: true,
2526
type: true,
2627
},
2728
parent: e.tuple({

src/components/engagement/engagement.repository.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,12 @@ export class EngagementRepository extends CommonRepository {
167167
node('mouEnd'),
168168
])
169169
.match([
170-
node('project'),
171-
relation('out', '', 'status', ACTIVE),
172-
node('status'),
170+
[
171+
node('project'),
172+
relation('out', '', 'status', ACTIVE),
173+
node('status'),
174+
],
175+
[node('project'), relation('out', '', 'step', ACTIVE), node('step')],
173176
])
174177
.return<{ dto: UnsecuredDto<Engagement> }>(
175178
merge('props', 'changedProps', {
@@ -185,6 +188,7 @@ export class EngagementRepository extends CommonRepository {
185188
id: 'project.id',
186189
type: 'project.type',
187190
status: 'status.value',
191+
step: 'step.value',
188192
},
189193
language: 'language { .id }',
190194
pnp: { id: 'props.pnp' },

0 commit comments

Comments
 (0)