@@ -63,6 +63,8 @@ export const documentTemplateForm = transformed(
63
63
) ,
64
64
language : required ( oneOf < OfficialLanguage > ( ) ) ,
65
65
confidential : boolean ( ) ,
66
+ confidentialityDurationYears : required ( value < string > ( ) ) ,
67
+ confidentialityBasis : required ( value < string > ( ) ) ,
66
68
legalBasis : string ( ) ,
67
69
validity : required ( openEndedLocalDateRange ( ) ) ,
68
70
processDefinitionNumber : required ( value < string > ( ) ) ,
@@ -75,20 +77,43 @@ export const documentTemplateForm = transformed(
75
77
if ( isNaN ( archiveDurationMonths ) || archiveDurationMonths < 1 ) {
76
78
return ValidationError . field ( 'archiveDurationMonths' , 'integerFormat' )
77
79
}
78
- const output : DocumentTemplateBasicsRequest = {
79
- ...value ,
80
- processDefinitionNumber : value . processDefinitionNumber . trim ( ) ,
81
- archiveDurationMonths : archiveDurationMonths
80
+ }
81
+
82
+ const confidential = value . confidential
83
+ if ( confidential ) {
84
+ const confidentialityDurationYears = parseInt (
85
+ value . confidentialityDurationYears
86
+ )
87
+ if (
88
+ isNaN ( confidentialityDurationYears ) ||
89
+ confidentialityDurationYears < 1
90
+ ) {
91
+ return ValidationError . field (
92
+ 'confidentialityDurationYears' ,
93
+ 'integerFormat'
94
+ )
82
95
}
83
- return ValidationSuccess . of ( output )
84
- } else {
85
- const output : DocumentTemplateBasicsRequest = {
86
- ...value ,
87
- processDefinitionNumber : null ,
88
- archiveDurationMonths : null
96
+ if ( value . confidentialityBasis . trim ( ) . length === 0 ) {
97
+ return ValidationError . field ( 'confidentialityBasis' , 'required' )
89
98
}
90
- return ValidationSuccess . of ( output )
91
99
}
100
+
101
+ const output : DocumentTemplateBasicsRequest = {
102
+ ...value ,
103
+ processDefinitionNumber : archived
104
+ ? value . processDefinitionNumber . trim ( )
105
+ : null ,
106
+ archiveDurationMonths : archived
107
+ ? parseInt ( value . archiveDurationMonths )
108
+ : null ,
109
+ confidentiality : confidential
110
+ ? {
111
+ durationYears : parseInt ( value . confidentialityDurationYears ) ,
112
+ basis : value . confidentialityBasis . trim ( )
113
+ }
114
+ : null
115
+ }
116
+ return ValidationSuccess . of ( output )
92
117
}
93
118
)
94
119
@@ -154,7 +179,10 @@ export default React.memo(function TemplateModal({ onClose, mode }: Props) {
154
179
domValue : mode . data . language ,
155
180
options : languageOptions
156
181
} ,
157
- confidential : mode . data . confidential ,
182
+ confidential : mode . data . confidentiality !== null ,
183
+ confidentialityDurationYears :
184
+ mode . data . confidentiality ?. durationYears ?. toString ( ) ?? '' ,
185
+ confidentialityBasis : mode . data . confidentiality ?. basis ?? '' ,
158
186
legalBasis : mode . data . legalBasis ,
159
187
validity : openEndedLocalDateRange . fromRange (
160
188
DateRange . parseJson ( mode . data . validity )
@@ -175,6 +203,8 @@ export default React.memo(function TemplateModal({ onClose, mode }: Props) {
175
203
options : languageOptions
176
204
} ,
177
205
confidential : true ,
206
+ confidentialityDurationYears : '100' ,
207
+ confidentialityBasis : '' ,
178
208
legalBasis : '' ,
179
209
validity : openEndedLocalDateRange . empty ( ) ,
180
210
processDefinitionNumber : '' ,
@@ -191,6 +221,8 @@ export default React.memo(function TemplateModal({ onClose, mode }: Props) {
191
221
placementTypes,
192
222
language,
193
223
confidential,
224
+ confidentialityDurationYears,
225
+ confidentialityBasis,
194
226
legalBasis,
195
227
validity,
196
228
processDefinitionNumber,
@@ -260,6 +292,29 @@ export default React.memo(function TemplateModal({ onClose, mode }: Props) {
260
292
bind = { confidential }
261
293
label = { i18n . documentTemplates . templateModal . confidential }
262
294
/>
295
+ { confidential . state && (
296
+ < >
297
+ < Gap />
298
+ < Label >
299
+ { i18n . documentTemplates . templateModal . confidentialityDuration }
300
+ </ Label >
301
+ < InputFieldF
302
+ data-qa = "confidentiality-duration-years"
303
+ bind = { confidentialityDurationYears }
304
+ type = "number"
305
+ hideErrorsBeforeTouched
306
+ /> { ' ' }
307
+ < Gap />
308
+ < Label >
309
+ { i18n . documentTemplates . templateModal . confidentialityBasis }
310
+ </ Label >
311
+ < InputFieldF
312
+ data-qa = "confidentiality-basis"
313
+ bind = { confidentialityBasis }
314
+ hideErrorsBeforeTouched
315
+ />
316
+ </ >
317
+ ) }
263
318
< Gap />
264
319
< ExpandingInfo
265
320
info = { i18n . documentTemplates . templateModal . processDefinitionNumberInfo }
0 commit comments