@@ -11,7 +11,7 @@ import {
11
11
requestingUser ,
12
12
sorting ,
13
13
} from '~/core/database/query' ;
14
- import { IProject , ProjectStep } from '../dto' ;
14
+ import { IProject , ProjectStep , stepToStatus } from '../dto' ;
15
15
import {
16
16
ExecuteProjectTransitionInput ,
17
17
ProjectWorkflowEvent as WorkflowEvent ,
@@ -67,11 +67,22 @@ export class ProjectWorkflowNeo4jRepository
67
67
relation ( 'out' , undefined , 'who' ) ,
68
68
node ( 'who' , 'User' ) ,
69
69
] )
70
- . return < { dto : UnsecuredDto < WorkflowEvent > } > (
70
+ . match ( [
71
+ node ( 'project' ) ,
72
+ relation ( 'out' , '' , 'step' , ACTIVE ) ,
73
+ node ( 'step' , 'Property' ) ,
74
+ ] )
75
+ . return < {
76
+ dto : UnsecuredDto < WorkflowEvent > & {
77
+ project : { previousStep : ProjectStep } ;
78
+ } ;
79
+ } > (
71
80
merge ( 'node' , {
72
81
at : 'node.createdAt' ,
73
82
who : 'who { .id }' ,
74
- project : 'project { .id, .type }' ,
83
+ project : merge ( 'project { .id, .type }' , {
84
+ previousStep : 'step.value' ,
85
+ } ) ,
75
86
} ) . as ( 'dto' ) ,
76
87
) ;
77
88
}
@@ -100,10 +111,17 @@ export class ProjectWorkflowNeo4jRepository
100
111
. first ( ) ;
101
112
const event = result ! . dto ;
102
113
114
+ const prevStatus = stepToStatus ( event . project . previousStep ) ;
115
+ const nextStatus = stepToStatus ( event . to ) ;
116
+
103
117
await this . db . updateProperties ( {
104
118
type : IProject ,
105
119
object : { id : project } ,
106
- changes : { step : event . to , stepChangedAt : event . at } ,
120
+ changes : {
121
+ step : event . to ,
122
+ stepChangedAt : event . at ,
123
+ status : prevStatus === nextStatus ? undefined : nextStatus ,
124
+ } ,
107
125
permanentAfter : null ,
108
126
} ) ;
109
127
0 commit comments