diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.html index fe7f4ac8d..c0d14e753 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.html @@ -1,13 +1,13 @@ -
+
- {{ annotationReferences.length }} - {{ (annotationReferences.length === 1 ? 'references.singular' : 'references.plural') | translate }} + {{ references.length }} + {{ (references.length === 1 ? 'references.singular' : 'references.plural') | translate }}
-
+
@@ -18,7 +18,7 @@
diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.ts index b759f0d94..6657f3c96 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-list/annotation-references-list.component.ts @@ -1,8 +1,10 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { File } from '@red/domain'; -import { FileDataModel } from '@models/file/file-data.model'; +import { FilePreviewStateService } from '../../services/file-preview-state.service'; +import { combineLatest, Observable } from 'rxjs'; +import { filter, map } from 'rxjs/operators'; @Component({ selector: 'redaction-annotation-references-list', @@ -10,18 +12,23 @@ import { FileDataModel } from '@models/file/file-data.model'; styleUrls: ['./annotation-references-list.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class AnnotationReferencesListComponent implements OnChanges { - @Input() annotation: AnnotationWrapper; +export class AnnotationReferencesListComponent { @Input() file: File; - @Input() fileData: FileDataModel; @Input() selectedAnnotations: AnnotationWrapper[]; @Output() readonly referenceClicked = new EventEmitter(); - annotationReferences: AnnotationWrapper[]; + references$ = this._annotationReferences; - constructor(readonly annotationReferencesService: AnnotationReferencesService) {} + constructor( + readonly annotationReferencesService: AnnotationReferencesService, + private readonly _filePreviewStateService: FilePreviewStateService, + ) {} - ngOnChanges(): void { - this.annotationReferences = this.fileData.allAnnotations.filter(a => this.annotation.reference.includes(a.annotationId)); + private get _annotationReferences(): Observable { + const combination = combineLatest([this.annotationReferencesService.annotation$, this._filePreviewStateService.fileData$]); + return combination.pipe( + filter(([annotation]) => !!annotation), + map(([{ reference }, fileData]) => fileData.allAnnotations.filter(a => reference.includes(a.annotationId))), + ); } isSelected(annotationId: string): boolean { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.html index d45e29274..0ad1cdb71 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.html @@ -44,11 +44,9 @@
- + diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts index bffbe67f4..7b182a364 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts @@ -4,7 +4,6 @@ import { FilterService, HelpModeService, IqserEventTarget } from '@iqser/common- import { File } from '@red/domain'; import { MultiSelectService } from '../../services/multi-select.service'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; -import { FileDataModel } from '../../../../../../models/file/file-data.model'; @Component({ selector: 'redaction-annotations-list', @@ -14,7 +13,6 @@ import { FileDataModel } from '../../../../../../models/file/file-data.model'; }) export class AnnotationsListComponent implements OnChanges { @Input() file: File; - @Input() fileData: FileDataModel; @Input() annotations: AnnotationWrapper[]; @Input() selectedAnnotations: AnnotationWrapper[]; @Input() annotationActionsTemplate: TemplateRef; diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html index e87104673..71c41366d 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html @@ -203,7 +203,6 @@ [annotationActionsTemplate]="annotationActionsTemplate" [annotations]="(displayedAnnotations$ | async)?.get(activeViewerPage)" [canMultiSelect]="!isReadOnly" - [fileData]="fileData" [file]="file" [selectedAnnotations]="selectedAnnotations" iqserHelpMode="workload-annotations-list" diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts index 2420dba07..584a25e84 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts @@ -33,7 +33,6 @@ import { ExcludedPagesService } from '../../services/excluded-pages.service'; import { MultiSelectService } from '../../services/multi-select.service'; import { DocumentInfoService } from '../../services/document-info.service'; import { SkippedService } from '../../services/skipped.service'; -import { FileDataModel } from '../../../../../../models/file/file-data.model'; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -56,7 +55,6 @@ export class FileWorkloadComponent { @Input() file!: File; @Input() annotationActionsTemplate: TemplateRef; @Input() viewer: WebViewerInstance; - @Input() fileData: FileDataModel; @Output() readonly shouldDeselectAnnotationsOnPageChangeChange = new EventEmitter(); @Output() readonly selectAnnotations = new EventEmitter(); @Output() readonly deselectAnnotations = new EventEmitter(); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index 63d312a1c..1fdaebc1a 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html @@ -102,7 +102,6 @@ [annotationActionsTemplate]="annotationActionsTemplate" [annotations]="visibleAnnotations" [dialogRef]="dialogRef" - [fileData]="fileData" [file]="file" [selectedAnnotations]="selectedAnnotations" [viewer]="activeViewer"