Pull request #351: RED-3409: If user forces a skipped redaction pre-select the reason if available

Merge in RED/ui from RED-3409 to master

* commit '0891fa2eeaf2bdd3bcf9690c5952d37baa29ba92':
  If user forces a skipped redaction pre-select the reason if available
This commit is contained in:
Adina Teudan 2022-02-15 19:11:35 +01:00 committed by Timo Bejan
commit 850572175e
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 { Dossier, ILegalBasisChangeRequest } from '@red/domain';
import { firstValueFrom } from 'rxjs';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
export interface LegalBasisOption {
label?: string;
@ -37,11 +38,11 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
private readonly _permissionsService: PermissionsService,
protected readonly _injector: Injector,
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);
this.form = this._getForm();
this.initialFormValue = this.form.getRawValue();
}
get isHintDialog() {
@ -59,6 +60,14 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
}));
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() {

View File

@ -77,7 +77,7 @@ export class AnnotationActionsService {
hint: boolean = false,
) {
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) => {
annotations.forEach(annotation => {
this._processObsAndEmit(