From 92fcc329ba2dfe0048a69d4a7bf04d2ab3aef216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Tue, 10 Aug 2021 15:35:10 +0300 Subject: [PATCH] Refactor dossiers dialog service: remove annotations, force redaction --- .../services/annotation-actions.service.ts | 6 +-- .../services/dossiers-dialog.service.ts | 43 ++++--------------- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 3d381b8ee..538be18ea 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -43,8 +43,7 @@ export class AnnotationActionsService { } forceRedaction($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter) { - $event?.stopPropagation(); - this._dialogService.openForceRedactionDialog($event, request => { + this._dialogService.openDialog('forceRedaction', $event, null, request => { annotations.forEach(annotation => { this._processObsAndEmit( this._manualAnnotationService.forceRedaction({ @@ -76,7 +75,8 @@ export class AnnotationActionsService { removeFromDictionary: boolean, annotationsChanged: EventEmitter ) { - this._dialogService.openRemoveFromDictionaryDialog($event, annotations, removeFromDictionary, result => { + const data = { annotationsToRemove: annotations, removeFromDictionary }; + this._dialogService.openDialog('removeAnnotations', $event, data, result => { annotations.forEach(annotation => { this._processObsAndEmit( this._manualAnnotationService.removeOrSuggestRemoveAnnotation(annotation, removeFromDictionary, result.comment), diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index 24540213a..96adebc58 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -3,7 +3,6 @@ import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dial import { AddDossierDialogComponent } from '../dialogs/add-dossier-dialog/add-dossier-dialog.component'; import { RemoveAnnotationsDialogComponent } from '../dialogs/remove-annotations-dialog/remove-annotations-dialog.component'; import { ForceRedactionDialogComponent } from '../dialogs/force-redaction-dialog/force-redaction-dialog.component'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { ConfirmationDialogComponent } from '@shared/dialogs/confirmation-dialog/confirmation-dialog.component'; import { DocumentInfoDialogComponent } from '../dialogs/document-info-dialog/document-info-dialog.component'; import { AppStateService } from '@state/app-state.service'; @@ -35,7 +34,9 @@ type DialogType = | 'assignFile' | 'recategorizeImage' | 'changeLegalBasis' - | 'dossierDictionary'; + | 'dossierDictionary' + | 'removeAnnotations' + | 'forceRedaction'; type DossiersDialogConfig = { [key in DialogType]: { @@ -74,6 +75,12 @@ export class DossiersDialogService extends DialogService { dossierDictionary: { component: DossierDictionaryDialogComponent, dialogConfig: { width: '90vw', height: '90vh' } + }, + removeAnnotations: { + component: RemoveAnnotationsDialogComponent + }, + forceRedaction: { + component: ForceRedactionDialogComponent } }; @@ -101,36 +108,4 @@ export class DossiersDialogService extends DialogService { return ref; } - - openForceRedactionDialog($event: MouseEvent, cb?: Function): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(ForceRedactionDialogComponent, { - ...dialogConfig - }); - ref.afterClosed().subscribe(async result => { - if (result && cb) { - cb(result); - } - }); - return ref; - } - - openRemoveFromDictionaryDialog( - $event: MouseEvent, - annotations: AnnotationWrapper[], - removeFromDictionary: boolean, - cb?: Function - ): MatDialogRef { - $event?.stopPropagation(); - const ref = this._dialog.open(RemoveAnnotationsDialogComponent, { - ...dialogConfig, - data: { annotationsToRemove: annotations, removeFromDictionary: removeFromDictionary } - }); - ref.afterClosed().subscribe(async result => { - if (result) { - if (cb) cb(result); - } - }); - return ref; - } }