File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
src/components/progress-report/variance-explanation Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Field , ObjectType } from '@nestjs/graphql' ;
2
+ import { stripIndent } from 'common-tags' ;
2
3
import { LazyGetter as Once } from 'lazy-get-decorator' ;
3
4
import { DataObject , JsonSet } from '~/common' ;
4
5
@@ -14,6 +15,16 @@ export class ProgressReportVarianceExplanationReasonOptions extends DataObject {
14
15
return new JsonSet ( [ ...this . behind , ...this . onTime , ...this . ahead ] ) ;
15
16
}
16
17
18
+ @Field ( ( ) => [ String ] , {
19
+ description : stripIndent `
20
+ A list of deprecated options.
21
+ If an option is deprecated, it is not available for selection/saving.
22
+ This allows rendering old options while enforcing a soft migration
23
+ to new values.
24
+ ` ,
25
+ } )
26
+ readonly deprecated : ReadonlySet < string > = new JsonSet ( [ ] ) ;
27
+
17
28
@Field ( ( ) => [ String ] )
18
29
readonly behind : ReadonlySet < string > = new JsonSet ( [
19
30
'Delayed activities; activities did not occur; slow start of project' ,
Original file line number Diff line number Diff line change 1
1
import { Injectable } from '@nestjs/common' ;
2
- import { mapFromList , NotFoundException , Session } from '~/common' ;
2
+ import {
3
+ InputException ,
4
+ mapFromList ,
5
+ NotFoundException ,
6
+ Session ,
7
+ } from '~/common' ;
3
8
import { ResourceLoader } from '~/core' ;
4
9
import { Privileges } from '../../authorization' ;
5
10
import { ProgressReport } from '../dto' ;
11
+ import { ProgressReportVarianceExplanationReasonOptions as ReasonOptions } from './reason-options' ;
6
12
import {
7
13
ProgressReportVarianceExplanation as VarianceExplanation ,
8
14
ProgressReportVarianceExplanationInput as VarianceExplanationInput ,
@@ -50,6 +56,18 @@ export class ProgressReportVarianceExplanationService {
50
56
return report ;
51
57
}
52
58
59
+ // Don't allow changing to a deprecated reason.
60
+ // Here to be nice and allow updating the comments even if the current
61
+ // reason is deprecated.
62
+ if (
63
+ changes . reasons ?. some ( ( r ) => ReasonOptions . instance . deprecated . has ( r ) )
64
+ ) {
65
+ throw new InputException (
66
+ 'Reason is deprecated and cannot be used' ,
67
+ 'reasons' ,
68
+ ) ;
69
+ }
70
+
53
71
this . privilegesFor ( session , report ) . verifyChanges ( changes ) ;
54
72
55
73
await this . repo . update ( report . id , changes , session ) ;
You can’t perform that action at this time.
0 commit comments