Refactor dossiers dialog service: remove annotations, force redaction

This commit is contained in:
Adina Țeudan 2021-08-10 15:35:10 +03:00
parent df54ab3fc2
commit 92fcc329ba
2 changed files with 12 additions and 37 deletions

View File

@ -43,8 +43,7 @@ export class AnnotationActionsService {
}
forceRedaction($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper>) {
$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<AnnotationWrapper>
) {
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),

View File

@ -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<DialogType> {
dossierDictionary: {
component: DossierDictionaryDialogComponent,
dialogConfig: { width: '90vw', height: '90vh' }
},
removeAnnotations: {
component: RemoveAnnotationsDialogComponent
},
forceRedaction: {
component: ForceRedactionDialogComponent
}
};
@ -101,36 +108,4 @@ export class DossiersDialogService extends DialogService<DialogType> {
return ref;
}
openForceRedactionDialog($event: MouseEvent, cb?: Function): MatDialogRef<ForceRedactionDialogComponent> {
$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<RemoveAnnotationsDialogComponent> {
$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;
}
}