From 2614d5fa1eda3381a3c04e54b99af4a077a73f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Thu, 7 Apr 2022 17:08:54 +0300 Subject: [PATCH] RED-3721: Refresh highlights after removal --- .../annotation-actions.component.html | 4 ++-- .../annotations-list.component.html | 6 +++++- .../annotations-list.component.ts | 1 + .../file-workload/file-workload.component.html | 1 + .../highlights-separator.component.ts | 4 +++- .../highlight-action-dialog.component.ts | 6 +++++- .../services/annotation-actions.service.ts | 15 ++++++++++----- apps/red-ui/src/assets/i18n/en.json | 2 +- 8 files changed, 28 insertions(+), 11 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html index bac1fd33f..ffe99a522 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html @@ -78,7 +78,7 @@ >
- +
(); @Output() readonly selectAnnotations = new EventEmitter(); + @Output() readonly annotationsChanged = new EventEmitter(); highlightGroups$ = new BehaviorSubject([]); diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html index 78995241f..70b6abc7f 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html @@ -213,6 +213,7 @@ (); readonly circleButtonTypes = CircleButtonTypes; readonly isWritable$ = this._state.isWritable$; @@ -44,6 +45,7 @@ export class HighlightsSeparatorComponent { operation, highlights, pageNumber: this.annotation.pageNumber, + annotationsChanged: this.annotationsChanged, }; } } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/highlight-action-dialog/highlight-action-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/highlight-action-dialog/highlight-action-dialog.component.ts index ec26760b3..b09d8b661 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/highlight-action-dialog/highlight-action-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/highlight-action-dialog/highlight-action-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, Injector } from '@angular/core'; +import { Component, EventEmitter, Inject, Injector } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { TextHighlightOperation, TextHighlightOperationPages } from '@red/domain'; @@ -15,6 +15,7 @@ export interface HighlightActionData { readonly fileId: string; readonly highlights: AnnotationWrapper[]; readonly pageNumber: number; + readonly annotationsChanged?: EventEmitter; } @Component({ @@ -49,6 +50,9 @@ export class HighlightActionDialogComponent extends BaseDialogComponent { const ids = filteredHighlights.map(h => h.id); await firstValueFrom(this._textHighlightService.performHighlightsAction(ids, dossierId, fileId, operation)); + if (this.data.annotationsChanged) { + this.data.annotationsChanged.emit(highlights); + } this._loadingService.stop(); this._dialogRef.close(true); } diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index 5b39e9bb9..36f0c0c65 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -72,13 +72,13 @@ export class AnnotationActionsService { ); } - removeHighlights(highlights: AnnotationWrapper[]): void { - const data = this._getHighlightOperationData(TextHighlightOperation.REMOVE, highlights); + removeHighlights(highlights: AnnotationWrapper[], annotationsChanged: EventEmitter): void { + const data = this._getHighlightOperationData(TextHighlightOperation.REMOVE, highlights, annotationsChanged); this._dialogService.openDialog('highlightAction', null, data); } - convertHighlights(highlights: AnnotationWrapper[]): void { - const data = this._getHighlightOperationData(TextHighlightOperation.CONVERT, highlights); + convertHighlights(highlights: AnnotationWrapper[], annotationsChanged: EventEmitter): void { + const data = this._getHighlightOperationData(TextHighlightOperation.CONVERT, highlights, annotationsChanged); this._dialogService.openDialog('highlightAction', null, data); } @@ -496,12 +496,17 @@ export class AnnotationActionsService { this._processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId), annotations, annotationsChanged); } - private _getHighlightOperationData(operation: TextHighlightOperation, highlights: AnnotationWrapper[]) { + private _getHighlightOperationData( + operation: TextHighlightOperation, + highlights: AnnotationWrapper[], + annotationsChanged: EventEmitter, + ) { return { dossierId: this._state.dossierId, fileId: this._state.fileId, operation, highlights, + annotationsChanged, }; } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index b9a940b85..317e7b7d8 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1443,7 +1443,7 @@ "save": "Remove Highlights", "title": "Remove highlights" }, - "success": "{operation, select, convert{Converting} delete{Removing} other{}} highlights in progress...", + "success": "{operation, select, convert{Converting highlights in progress...} delete{Successfully removed highlights!} other{}} ", "this-page": "Only for this page" }, "highlights": "{color} - {length} {length, plural, one{highlight} other{highlights}}",