If user forces a skipped redaction pre-select the reason if available

This commit is contained in:
Adina Țeudan 2022-02-15 15:59:52 +02:00
parent 78518c3fd7
commit 0891fa2eea
2 changed files with 12 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import { DossiersService } from '@services/entity-services/dossiers.service';
import { JustificationsService } from '@services/entity-services/justifications.service'; import { JustificationsService } from '@services/entity-services/justifications.service';
import { Dossier, ILegalBasisChangeRequest } from '@red/domain'; import { Dossier, ILegalBasisChangeRequest } from '@red/domain';
import { firstValueFrom } from 'rxjs'; import { firstValueFrom } from 'rxjs';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
export interface LegalBasisOption { export interface LegalBasisOption {
label?: string; label?: string;
@ -37,11 +38,11 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
private readonly _permissionsService: PermissionsService, private readonly _permissionsService: PermissionsService,
protected readonly _injector: Injector, protected readonly _injector: Injector,
protected readonly _dialogRef: MatDialogRef<ForceAnnotationDialogComponent>, protected readonly _dialogRef: MatDialogRef<ForceAnnotationDialogComponent>,
@Inject(MAT_DIALOG_DATA) private readonly _data: { readonly dossier: Dossier; readonly hint: boolean }, @Inject(MAT_DIALOG_DATA)
private readonly _data: { readonly dossier: Dossier; readonly hint: boolean; annotations: AnnotationWrapper[] },
) { ) {
super(_injector, _dialogRef); super(_injector, _dialogRef);
this.form = this._getForm(); this.form = this._getForm();
this.initialFormValue = this.form.getRawValue();
} }
get isHintDialog() { get isHintDialog() {
@ -59,6 +60,14 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
})); }));
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 });
}
this.initialFormValue = this.form.getRawValue();
} }
save() { save() {

View File

@ -77,7 +77,7 @@ export class AnnotationActionsService {
hint: boolean = false, hint: boolean = false,
) { ) {
const { dossierId, fileId } = this._screenStateService; const { dossierId, fileId } = this._screenStateService;
const data = { dossier: this._dossier, hint }; const data = { dossier: this._dossier, annotations, hint };
this._dialogService.openDialog('forceAnnotation', $event, data, (request: ILegalBasisChangeRequest) => { this._dialogService.openDialog('forceAnnotation', $event, data, (request: ILegalBasisChangeRequest) => {
annotations.forEach(annotation => { annotations.forEach(annotation => {
this._processObsAndEmit( this._processObsAndEmit(