RED-3831: Remove annotationsChanged event emitters

This commit is contained in:
Adina Țeudan 2022-04-11 09:58:11 +03:00
parent ca127dcbfe
commit 149610a801
13 changed files with 83 additions and 150 deletions

View File

@ -38,7 +38,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.changeLegalBasis($event, annotations, annotationsChanged)"
(action)="annotationActionsService.changeLegalBasis($event, annotations)"
*ngIf="annotationPermissions.canChangeLegalBasis"
[scrollableParentView]="scrollableParentView"
[tooltipPosition]="tooltipPosition"
@ -60,7 +60,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.acceptSuggestion($event, annotations, annotationsChanged)"
(action)="annotationActionsService.acceptSuggestion($event, annotations)"
*ngIf="annotationPermissions.canAcceptSuggestion"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.accept-suggestion.label' | translate"
@ -69,16 +69,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.acceptSuggestion($event, annotations, annotationsChanged)"
*ngIf="annotationPermissions.canAcceptSuggestion"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.accept-suggestion.label' | translate"
[type]="buttonType"
icon="iqser:check"
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.convertHighlights(annotations, annotationsChanged)"
(action)="annotationActionsService.convertHighlights(annotations)"
*ngIf="(viewModeService.viewMode$ | async) === 'TEXT_HIGHLIGHTS'"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.convert-highlights.label' | translate"
@ -87,7 +78,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.removeHighlights(annotations, annotationsChanged)"
(action)="annotationActionsService.removeHighlights(annotations)"
*ngIf="(viewModeService.viewMode$ | async) === 'TEXT_HIGHLIGHTS'"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.remove-highlights.label' | translate"
@ -96,7 +87,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.undoDirectAction($event, annotations, annotationsChanged)"
(action)="annotationActionsService.undoDirectAction($event, annotations)"
*ngIf="annotationPermissions.canUndo"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.undo' | translate"
@ -105,7 +96,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.rejectSuggestion($event, annotations, annotationsChanged)"
(action)="annotationActionsService.rejectSuggestion($event, annotations)"
*ngIf="annotationPermissions.canRejectSuggestion"
[tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.reject-suggestion' | translate"
@ -114,7 +105,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.recategorizeImages($event, annotations, annotationsChanged)"
(action)="annotationActionsService.recategorizeImages($event, annotations)"
*ngIf="annotationPermissions.canRecategorizeImage"
[iqserHelpMode]="helpModeKey + '_recategorize'"
[tooltipPosition]="tooltipPosition"
@ -133,7 +124,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.forceAnnotation($event, annotations, annotationsChanged)"
(action)="annotationActionsService.forceAnnotation($event, annotations)"
*ngIf="annotationPermissions.canForceRedaction"
[scrollableParentView]="scrollableParentView"
[tooltipPosition]="tooltipPosition"
@ -144,7 +135,7 @@
></iqser-circle-button>
<iqser-circle-button
(action)="annotationActionsService.forceAnnotation($event, annotations, annotationsChanged, true)"
(action)="annotationActionsService.forceAnnotation($event, annotations, true)"
*ngIf="annotationPermissions.canForceHint"
[iqserHelpMode]="helpModeKey + '_force_hint'"
[tooltipPosition]="tooltipPosition"

View File

@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
import { ChangeDetectorRef, Component, Input, OnChanges } from '@angular/core';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { PermissionsService } from '@services/permissions.service';
import { AnnotationPermissions } from '@models/file/annotation.permissions';
@ -30,7 +30,6 @@ export class AnnotationActionsComponent implements OnChanges {
@Input() tooltipPosition: 'before' | 'above' = 'before';
@Input() canPerformAnnotationActions: boolean;
@Input() alwaysVisible: boolean;
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper[]>();
annotationPermissions: AnnotationPermissions;
constructor(
@ -94,15 +93,15 @@ export class AnnotationActionsComponent implements OnChanges {
removeOrSuggestRemoveAnnotation($event: MouseEvent, removeFromDict: boolean) {
$event.stopPropagation();
this.annotationActionsService.removeOrSuggestRemoveAnnotation($event, this.annotations, removeFromDict, this.annotationsChanged);
this.annotationActionsService.removeOrSuggestRemoveAnnotation($event, this.annotations, removeFromDict);
}
markAsFalsePositive($event: MouseEvent) {
this.annotationActionsService.markAsFalsePositive($event, this.annotations, this.annotationsChanged);
this.annotationActionsService.markAsFalsePositive($event, this.annotations);
}
acceptRecommendation($event: MouseEvent) {
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations, this.annotationsChanged);
this.annotationActionsService.convertRecommendationToAnnotation($event, this.annotations);
}
hideAnnotation($event: MouseEvent) {
@ -124,11 +123,11 @@ export class AnnotationActionsComponent implements OnChanges {
}
acceptResize($event: MouseEvent) {
return this.annotationActionsService.acceptResize($event, this.annotations[0], this.annotationsChanged);
return this.annotationActionsService.acceptResize($event, this.annotations[0]);
}
cancelResize($event: MouseEvent) {
return this.annotationActionsService.cancelResize($event, this.annotations[0], this.annotationsChanged);
return this.annotationActionsService.cancelResize($event, this.annotations[0]);
}
private async _setPermissions() {

View File

@ -1,10 +1,6 @@
<ng-container *ngFor="let annotation of annotations; let idx = index">
<div *ngIf="showHighlightGroup(idx) as highlightGroup" class="workload-separator">
<redaction-highlights-separator
(annotationsChanged)="annotationsChanged.emit($event)"
[annotation]="annotation"
[highlightGroup]="highlightGroup"
></redaction-highlights-separator>
<redaction-highlights-separator [annotation]="annotation" [highlightGroup]="highlightGroup"></redaction-highlights-separator>
</div>
<redaction-annotation-wrapper

View File

@ -33,7 +33,6 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O
@Output() readonly pagesPanelActive = new EventEmitter<boolean>();
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper[]>();
highlightGroups$ = new BehaviorSubject<TextHighlightsGroup[]>([]);

View File

@ -56,7 +56,6 @@
<span class="all-caps-label">{{ listingService.selectedLength$ | async }} selected </span>
<redaction-annotation-actions
(annotationsChanged)="annotationsChanged.emit($event)"
*ngIf="listingService.areSomeSelected$ | async"
[alwaysVisible]="true"
[annotations]="listingService.selectedEntities$ | async"
@ -213,7 +212,6 @@
</ng-container>
<redaction-annotations-list
(annotationsChanged)="annotationsChanged.emit($event)"
(pagesPanelActive)="pagesPanelActive = $event"
(selectAnnotations)="selectAnnotations.emit($event)"
[activeViewerPage]="activeViewerPage"

View File

@ -58,7 +58,6 @@ export class FileWorkloadComponent {
@Input() annotationActionsTemplate: TemplateRef<unknown>;
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
@Output() readonly selectPage = new EventEmitter<number>();
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper[]>();
displayedPages: number[] = [];
pagesPanelActive = true;
readonly displayedAnnotations$: Observable<Map<number, AnnotationWrapper[]>>;

View File

@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { CircleButtonTypes } from '@iqser/common-ui';
import { TextHighlightOperation, TextHighlightsGroup } from '@red/domain';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
@ -16,7 +16,6 @@ import { MultiSelectService } from '../../services/multi-select.service';
export class HighlightsSeparatorComponent {
@Input() highlightGroup: TextHighlightsGroup;
@Input() annotation: AnnotationWrapper;
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper[]>();
readonly circleButtonTypes = CircleButtonTypes;
readonly isWritable$ = this._state.isWritable$;
@ -48,7 +47,9 @@ export class HighlightsSeparatorComponent {
operation,
highlights,
pageNumber: this.annotation.pageNumber,
annotationsChanged: this.annotationsChanged,
annotationsChanged: async () => {
await this._fileDataService.annotationsChanged();
},
};
}
}

View File

@ -60,7 +60,6 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
@Output() readonly manualAnnotationRequested = new EventEmitter<ManualRedactionEntryWrapper>();
@Output() readonly pageChanged = new EventEmitter<number>();
@Output() readonly keyUp = new EventEmitter<KeyboardEvent>();
@Output() readonly annotationsChanged = new EventEmitter<AnnotationWrapper[]>();
@ViewChild('viewer', { static: true }) viewer: ElementRef;
@ViewChild('compareFileInput', { static: true }) compareFileInput: ElementRef;
instance: WebViewerInstance;
@ -392,7 +391,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
]);
}
const actions = this._annotationActionsService.getViewerAvailableActions(this.dossier, annotationWrappers, this.annotationsChanged);
const actions = this._annotationActionsService.getViewerAvailableActions(this.dossier, annotationWrappers);
this.instance.UI.annotationPopup.add(actions);
}

View File

@ -1,4 +1,4 @@
import { Component, EventEmitter, Inject, Injector } from '@angular/core';
import { Component, 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,7 +15,7 @@ export interface HighlightActionData {
readonly fileId: string;
readonly highlights: AnnotationWrapper[];
readonly pageNumber: number;
readonly annotationsChanged?: EventEmitter<AnnotationWrapper[]>;
readonly annotationsChanged?: () => Promise<void>;
}
@Component({
@ -51,7 +51,7 @@ 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);
await this.data.annotationsChanged();
}
this._loadingService.stop();
this._dialogRef.close(true);

View File

@ -65,7 +65,6 @@
<div class="content-container">
<redaction-pdf-viewer
(annotationSelected)="handleAnnotationSelected($event)"
(annotationsChanged)="annotationsChangedByReviewAction()"
(keyUp)="handleKeyEvent($event); handleArrowEvent($event)"
(manualAnnotationRequested)="openManualAnnotationDialog($event)"
(pageChanged)="viewerPageChanged($event)"
@ -88,7 +87,6 @@
<redaction-file-workload
#fileWorkloadComponent
(annotationsChanged)="annotationsChangedByReviewAction()"
(selectAnnotations)="selectAnnotations($event)"
(selectPage)="selectPage($event)"
*ngIf="!file.excluded"
@ -104,7 +102,6 @@
<ng-template #annotationActionsTemplate let-annotation="annotation">
<redaction-annotation-actions
(annotationsChanged)="annotationsChangedByReviewAction()"
[annotations]="[annotation]"
[canPerformAnnotationActions]="canPerformAnnotationActions$ | async"
></redaction-annotation-actions>

View File

@ -362,15 +362,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
this._changeDetectorRef.markForCheck();
}
async annotationsChangedByReviewAction() {
this.multiSelectService.deactivate();
const file = await this.state.file;
const fileReloaded = await firstValueFrom(this._filesService.reload(this.dossierId, file));
if (!fileReloaded) {
await this._fileDataService.loadAnnotations(file);
}
}
closeFullScreen() {
if (!!document.fullscreenElement && document.exitFullscreen) {
document.exitFullscreen().then();

View File

@ -1,4 +1,4 @@
import { EventEmitter, Inject, Injectable, NgZone } from '@angular/core';
import { Inject, Injectable, NgZone } from '@angular/core';
import { PermissionsService } from '@services/permissions.service';
import { ManualRedactionService } from './manual-redaction.service';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
@ -34,6 +34,7 @@ import { FilePreviewStateService } from './file-preview-state.service';
import { PdfViewer } from './pdf-viewer.service';
import { FilePreviewDialogService } from './file-preview-dialog.service';
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
import { FileDataService } from './file-data.service';
import Quad = Core.Math.Quad;
@Injectable()
@ -52,13 +53,14 @@ export class AnnotationActionsService {
private readonly _activeDossiersService: ActiveDossiersService,
private readonly _dictionariesMapService: DictionariesMapService,
private readonly _state: FilePreviewStateService,
private readonly _fileDataService: FileDataService,
) {}
private get _dossier(): Dossier {
return this._activeDossiersService.find(this._state.dossierId);
}
acceptSuggestion($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
acceptSuggestion($event: MouseEvent, annotations: AnnotationWrapper[]) {
$event?.stopPropagation();
const { dossierId, fileId } = this._state;
this._processObsAndEmit(
@ -67,22 +69,20 @@ export class AnnotationActionsService {
dossierId,
fileId,
),
annotations,
annotationsChanged,
);
}
removeHighlights(highlights: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>): void {
const data = this._getHighlightOperationData(TextHighlightOperation.REMOVE, highlights, annotationsChanged);
removeHighlights(highlights: AnnotationWrapper[]): void {
const data = this._getHighlightOperationData(TextHighlightOperation.REMOVE, highlights);
this._dialogService.openDialog('highlightAction', null, data);
}
convertHighlights(highlights: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>): void {
const data = this._getHighlightOperationData(TextHighlightOperation.CONVERT, highlights, annotationsChanged);
convertHighlights(highlights: AnnotationWrapper[]): void {
const data = this._getHighlightOperationData(TextHighlightOperation.CONVERT, highlights);
this._dialogService.openDialog('highlightAction', null, data);
}
rejectSuggestion($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
rejectSuggestion($event: MouseEvent, annotations: AnnotationWrapper[]) {
$event?.stopPropagation();
const { dossierId, fileId } = this._state;
this._processObsAndEmit(
@ -92,17 +92,10 @@ export class AnnotationActionsService {
fileId,
annotations[0].isModifyDictionary,
),
annotations,
annotationsChanged,
);
}
forceAnnotation(
$event: MouseEvent,
annotations: AnnotationWrapper[],
annotationsChanged: EventEmitter<AnnotationWrapper[]>,
hint: boolean = false,
) {
forceAnnotation($event: MouseEvent, annotations: AnnotationWrapper[], hint: boolean = false) {
const { dossierId, fileId } = this._state;
const data = { dossier: this._dossier, annotations, hint };
this._dialogService.openDialog('forceAnnotation', $event, data, (request: ILegalBasisChangeRequest) => {
@ -112,13 +105,11 @@ export class AnnotationActionsService {
dossierId,
fileId,
),
annotations,
annotationsChanged,
);
});
}
changeLegalBasis($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
changeLegalBasis($event: MouseEvent, annotations: AnnotationWrapper[]) {
const { dossierId, fileId } = this._state;
this._dialogService.openDialog(
'changeLegalBasis',
@ -133,21 +124,12 @@ export class AnnotationActionsService {
value: data.value,
}));
this._processObsAndEmit(
this._manualRedactionService.changeLegalBasis(body, dossierId, fileId),
annotations,
annotationsChanged,
);
this._processObsAndEmit(this._manualRedactionService.changeLegalBasis(body, dossierId, fileId));
},
);
}
removeOrSuggestRemoveAnnotation(
$event: MouseEvent,
annotations: AnnotationWrapper[],
removeFromDictionary: boolean,
annotationsChanged: EventEmitter<AnnotationWrapper[]>,
) {
removeOrSuggestRemoveAnnotation($event: MouseEvent, annotations: AnnotationWrapper[], removeFromDictionary: boolean) {
const data = {
annotationsToRemove: annotations,
removeFromDictionary,
@ -161,15 +143,11 @@ export class AnnotationActionsService {
removeFromDictionary,
comment: result.comment,
}));
this._processObsAndEmit(
this._manualRedactionService.removeOrSuggestRemove(body, dossierId, fileId, removeFromDictionary),
annotations,
annotationsChanged,
);
this._processObsAndEmit(this._manualRedactionService.removeOrSuggestRemove(body, dossierId, fileId, removeFromDictionary));
});
}
recategorizeImages($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
recategorizeImages($event: MouseEvent, annotations: AnnotationWrapper[]) {
const data = { annotations, dossier: this._dossier };
const { dossierId, fileId } = this._state;
this._dialogService.openDialog('recategorizeImage', $event, data, ({ comment, type }: { type: string; comment: string }) => {
@ -178,15 +156,11 @@ export class AnnotationActionsService {
type,
comment,
}));
this._processObsAndEmit(
this._manualRedactionService.recategorizeImage(body, dossierId, fileId),
annotations,
annotationsChanged,
);
this._processObsAndEmit(this._manualRedactionService.recategorizeImage(body, dossierId, fileId));
});
}
undoDirectAction($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
undoDirectAction($event: MouseEvent, annotations: AnnotationWrapper[]) {
$event?.stopPropagation();
const { dossierId, fileId } = this._state;
@ -198,16 +172,10 @@ export class AnnotationActionsService {
fileId,
modifyDictionary,
),
annotations,
annotationsChanged,
);
}
convertRecommendationToAnnotation(
$event: any,
recommendations: AnnotationWrapper[],
annotationsChanged: EventEmitter<AnnotationWrapper[]>,
) {
convertRecommendationToAnnotation($event: any, recommendations: AnnotationWrapper[]) {
$event?.stopPropagation();
const { dossierId, fileId } = this._state;
@ -218,19 +186,11 @@ export class AnnotationActionsService {
const dialogClosed = dialogRef.afterClosed().pipe(filter(value => !!value && !!value.annotations));
dialogClosed.subscribe(({ annotations, comment: commentText }) => {
const comment = commentText ? { text: commentText } : undefined;
this._processObsAndEmit(
this._manualRedactionService.addRecommendation(annotations, dossierId, fileId, comment),
annotations,
annotationsChanged,
);
this._processObsAndEmit(this._manualRedactionService.addRecommendation(annotations, dossierId, fileId, comment));
});
}
getViewerAvailableActions(
dossier: Dossier,
annotations: AnnotationWrapper[],
annotationsChanged: EventEmitter<AnnotationWrapper[]>,
): Record<string, unknown>[] {
getViewerAvailableActions(dossier: Dossier, annotations: AnnotationWrapper[]): Record<string, unknown>[] {
const availableActions = [];
const annotationPermissions = annotations.map(annotation => ({
annotation,
@ -254,14 +214,14 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.resize-accept.label'),
onClick: () =>
this._ngZone.run(() => {
this.acceptResize(null, firstAnnotation, annotationsChanged);
this.acceptResize(null, firstAnnotation);
}),
});
availableActions.push({
type: 'actionButton',
img: this._convertPath('/assets/icons/general/close.svg'),
title: this._translateService.instant('annotation-actions.resize-cancel.label'),
onClick: () => this._ngZone.run(() => this.cancelResize(null, firstAnnotation, annotationsChanged)),
onClick: () => this._ngZone.run(() => this.cancelResize(null, firstAnnotation)),
});
return availableActions;
}
@ -282,7 +242,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.edit-reason.label'),
onClick: () =>
this._ngZone.run(() => {
this.changeLegalBasis(null, annotations, annotationsChanged);
this.changeLegalBasis(null, annotations);
}),
});
}
@ -295,7 +255,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.recategorize-image'),
onClick: () =>
this._ngZone.run(() => {
this.recategorizeImages(null, annotations, annotationsChanged);
this.recategorizeImages(null, annotations);
}),
});
}
@ -311,7 +271,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.remove-annotation.remove-from-dict'),
onClick: () =>
this._ngZone.run(() => {
this.removeOrSuggestRemoveAnnotation(null, annotations, true, annotationsChanged);
this.removeOrSuggestRemoveAnnotation(null, annotations, true);
}),
});
}
@ -324,7 +284,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.accept-recommendation.label'),
onClick: () =>
this._ngZone.run(() => {
this.convertRecommendationToAnnotation(null, annotations, annotationsChanged);
this.convertRecommendationToAnnotation(null, annotations);
}),
});
}
@ -337,7 +297,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.accept-suggestion.label'),
onClick: () =>
this._ngZone.run(() => {
this.acceptSuggestion(null, annotations, annotationsChanged);
this.acceptSuggestion(null, annotations);
}),
});
}
@ -350,7 +310,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.undo'),
onClick: () =>
this._ngZone.run(() => {
this.undoDirectAction(null, annotations, annotationsChanged);
this.undoDirectAction(null, annotations);
}),
});
}
@ -363,7 +323,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.remove-annotation.false-positive'),
onClick: () =>
this._ngZone.run(() => {
this.markAsFalsePositive(null, annotations, annotationsChanged);
this.markAsFalsePositive(null, annotations);
}),
});
}
@ -376,7 +336,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.force-redaction.label'),
onClick: () =>
this._ngZone.run(() => {
this.forceAnnotation(null, annotations, annotationsChanged);
this.forceAnnotation(null, annotations);
}),
});
}
@ -389,7 +349,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.force-hint.label'),
onClick: () =>
this._ngZone.run(() => {
this.forceAnnotation(null, annotations, annotationsChanged, true);
this.forceAnnotation(null, annotations, true);
}),
});
}
@ -402,7 +362,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.reject-suggestion'),
onClick: () =>
this._ngZone.run(() => {
this.rejectSuggestion(null, annotations, annotationsChanged);
this.rejectSuggestion(null, annotations);
}),
});
}
@ -418,7 +378,7 @@ export class AnnotationActionsService {
title: this._translateService.instant('annotation-actions.remove-annotation.only-here'),
onClick: () =>
this._ngZone.run(() => {
this.removeOrSuggestRemoveAnnotation(null, annotations, false, annotationsChanged);
this.removeOrSuggestRemoveAnnotation(null, annotations, false);
}),
});
}
@ -448,7 +408,7 @@ export class AnnotationActionsService {
this._pdf.annotationManager.selectAnnotation(viewerAnnotation);
}
acceptResize($event: MouseEvent, annotationWrapper: AnnotationWrapper, annotationsChanged?: EventEmitter<AnnotationWrapper[]>) {
acceptResize($event: MouseEvent, annotationWrapper: AnnotationWrapper) {
const data = { dossier: this._dossier };
const fileId = this._state.fileId;
this._dialogService.openDialog('resizeAnnotation', $event, data, async (result: { comment: string }) => {
@ -463,15 +423,11 @@ export class AnnotationActionsService {
value: text,
};
this._processObsAndEmit(
this._manualRedactionService.resizeOrSuggestResize([resizeRequest], data.dossier.dossierId, fileId),
[annotationWrapper],
annotationsChanged,
);
this._processObsAndEmit(this._manualRedactionService.resizeOrSuggestResize([resizeRequest], data.dossier.dossierId, fileId));
});
}
async cancelResize($event: MouseEvent, annotationWrapper: AnnotationWrapper, annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
async cancelResize($event: MouseEvent, annotationWrapper: AnnotationWrapper) {
$event?.stopPropagation();
annotationWrapper.resizing = false;
@ -479,10 +435,10 @@ export class AnnotationActionsService {
this._pdf.deleteAnnotations([annotationWrapper.id]);
await this._annotationDrawService.drawAnnotations([annotationWrapper]);
this._pdf.annotationManager.deselectAllAnnotations();
annotationsChanged.emit([annotationWrapper]);
await this._fileDataService.annotationsChanged();
}
markAsFalsePositive($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter<AnnotationWrapper[]>) {
markAsFalsePositive($event: MouseEvent, annotations: AnnotationWrapper[]) {
$event?.stopPropagation();
const requests: List<IAddRedactionRequest> = annotations.map(annotation => ({
@ -498,7 +454,7 @@ export class AnnotationActionsService {
}));
const { dossierId, fileId } = this._state;
this._processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId), annotations, annotationsChanged);
this._processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId));
}
#generateRectangle(annotationWrapper: AnnotationWrapper) {
@ -521,28 +477,22 @@ export class AnnotationActionsService {
return annotation;
}
private _getHighlightOperationData(
operation: TextHighlightOperation,
highlights: AnnotationWrapper[],
annotationsChanged: EventEmitter<AnnotationWrapper[]>,
) {
private _getHighlightOperationData(operation: TextHighlightOperation, highlights: AnnotationWrapper[]) {
return {
dossierId: this._state.dossierId,
fileId: this._state.fileId,
operation,
highlights,
annotationsChanged,
annotationsChanged: async () => {
await this._fileDataService.annotationsChanged();
},
};
}
private _processObsAndEmit(
obs: Observable<unknown>,
annotations: AnnotationWrapper[],
annotationsChanged: EventEmitter<AnnotationWrapper[]>,
) {
private _processObsAndEmit(obs: Observable<unknown>) {
obs.subscribe({
next: () => annotationsChanged.emit(annotations),
error: () => annotationsChanged.emit(),
next: () => this._fileDataService.annotationsChanged(),
error: () => this._fileDataService.annotationsChanged(),
});
}

View File

@ -27,6 +27,8 @@ import { ViewModeService } from './view-mode.service';
import { Core } from '@pdftron/webviewer';
import dayjs from 'dayjs';
import { NGXLogger } from 'ngx-logger';
import { MultiSelectService } from './multi-select.service';
import { FilesService } from '../../../services/entity-services/files.service';
import Annotation = Core.Annotations.Annotation;
const DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes;
@ -51,6 +53,8 @@ export class FileDataService extends EntitiesService<AnnotationWrapper> {
private readonly _permissionsService: PermissionsService,
private readonly _redactionLogService: RedactionLogService,
private readonly _textHighlightsService: TextHighlightService,
private readonly _multiSelectService: MultiSelectService,
private readonly _filesService: FilesService,
private readonly _toaster: Toaster,
private readonly _logger: NGXLogger,
protected readonly _injector: Injector,
@ -99,6 +103,15 @@ export class FileDataService extends EntitiesService<AnnotationWrapper> {
await this.loadRedactionLog();
}
async annotationsChanged() {
this._multiSelectService.deactivate();
const file = await this._state.file;
const fileReloaded = await firstValueFrom(this._filesService.reload(file.dossierId, file));
if (!fileReloaded) {
await this.loadAnnotations(file);
}
}
async loadTextHighlights(): Promise<AnnotationWrapper[]> {
const highlights = await firstValueFrom(this._textHighlightsService.getTextHighlights(this._state.dossierId, this._state.fileId));
this.#textHighlights$.next(highlights);