RED-7935: fixed cannot save force annotation.

This commit is contained in:
Nicoleta Panaghiu 2023-11-21 14:17:43 +02:00
parent f9c001230e
commit f4b055bda2

View File

@ -41,22 +41,23 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
}
async ngOnInit() {
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
if (!this.isDocumine) {
const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this._data.dossier.dossierTemplateId));
this.legalOptions = data.map(lbm => ({
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,
}));
this.legalOptions = data.map(lbm => ({
legalBasis: lbm.reason,
description: lbm.description,
label: lbm.name,
}));
this.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
this.legalOptions.sort((a, b) => a.label.localeCompare(b.label));
// Set pre-existing reason if it exists
const existingReason = this.legalOptions.find(option => option.legalBasis === this._data.annotations[0].legalBasis);
if (!this._data.hint && existingReason) {
this.form.patchValue({ reason: existingReason }, { emitEvent: false });
// Set pre-existing reason if it exists
const existingReason = this.legalOptions.find(option => option.legalBasis === this._data.annotations[0].legalBasis);
if (!this._data.hint && existingReason) {
this.form.patchValue({ reason: existingReason }, { emitEvent: false });
}
}
this.initialFormValue = this.form.getRawValue();
}
@ -66,7 +67,7 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
private _getForm(): UntypedFormGroup {
return this._formBuilder.group({
reason: this._data.hint ? ['Forced Hint'] : [null, Validators.required],
reason: this._data.hint ? ['Forced Hint'] : [null, !this.isDocumine ? Validators.required : null],
comment: [null],
});
}
@ -74,9 +75,10 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
private _createForceRedactionRequest(): ILegalBasisChangeRequest {
const request: ILegalBasisChangeRequest = {};
const legalOption: LegalBasisOption = this.form.get('reason').value;
request.legalBasis = legalOption.legalBasis;
if (!this.isDocumine) {
const legalOption: LegalBasisOption = this.form.get('reason').value;
request.legalBasis = legalOption.legalBasis;
}
request.comment = this.form.get('comment').value;
return request;