diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.html index ebdcd32f0..511d3dfde 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-actions/annotation-actions.component.html @@ -89,7 +89,7 @@ (); annotationPermissions: AnnotationPermissions; + referencesButtonEnabled = false; constructor( private readonly _manualAnnotationService: ManualAnnotationService, @@ -63,6 +64,8 @@ export class AnnotationActionsComponent implements OnChanges { @Input() set annotations(value: AnnotationWrapper[]) { this._annotations = value.filter(a => a !== undefined); + this.referencesButtonEnabled = + this.annotationReferencesService.hasReferences(this._annotations) && !this.multiSelectService.isActive; } get viewerAnnotations() { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-card/annotation-card.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-card/annotation-card.component.ts index a0b18557d..0ce73621e 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-card/annotation-card.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-card/annotation-card.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { AnnotationWrapper } from '../../../../../../models/file/annotation.wrapper'; import { File } from '@red/domain'; import { MultiSelectService } from '../../services/multi-select.service'; @@ -7,6 +7,7 @@ import { MultiSelectService } from '../../services/multi-select.service'; selector: 'redaction-annotation-card', templateUrl: './annotation-card.component.html', styleUrls: ['./annotation-card.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationCardComponent { @Input() annotation: AnnotationWrapper; diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-dialog/annotation-references-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-dialog/annotation-references-dialog.component.ts index 1a7a9e97d..0131ae11f 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-dialog/annotation-references-dialog.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-dialog/annotation-references-dialog.component.ts @@ -1,51 +1,29 @@ -import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { File } from '@red/domain'; -import { PdfViewerDataService } from '../../../../services/pdf-viewer-data.service'; import { FileDataModel } from '@models/file/file-data.model'; @Component({ selector: 'redaction-annotation-references-dialog', templateUrl: './annotation-references-dialog.component.html', styleUrls: ['./annotation-references-dialog.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, }) -export class AnnotationReferencesDialogComponent implements OnInit, OnChanges { +export class AnnotationReferencesDialogComponent implements OnChanges { @Input() annotation: AnnotationWrapper; @Input() file: File; + @Input() + fileData: FileDataModel; @Output() readonly referenceClicked = new EventEmitter(); - fileData: FileDataModel; annotationReferences: AnnotationWrapper[]; - constructor( - readonly annotationReferencesService: AnnotationReferencesService, - private readonly _fileDownloadService: PdfViewerDataService, - ) {} + constructor(readonly annotationReferencesService: AnnotationReferencesService) {} - async ngOnInit(): Promise { - console.log(this.annotation); - await this.setReferences(); - } - - async ngOnChanges(changes: SimpleChanges): Promise { - await this.setReferences(); - } - - async setReferences(): Promise { - await this._loadFileData(this.file); + ngOnChanges(changes: SimpleChanges): void { this.annotationReferences = this.fileData.allAnnotations.filter(a => this.annotation.reference.includes(a.annotationId)); } - - private async _loadFileData(file: File): Promise { - const fileData = await this._fileDownloadService.loadDataFor(file, this.fileData).toPromise(); - - if (file.isPending) { - return; - } - - this.fileData = fileData; - } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts index 42761871a..1bb4e131a 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts @@ -1,9 +1,10 @@ -import { Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; @Component({ selector: 'redaction-annotation-references-page-indicator', templateUrl: './annotation-references-page-indicator.component.html', styleUrls: ['./annotation-references-page-indicator.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationReferencesPageIndicatorComponent { @Input() number; 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 1a9e22ec7..638ca717a 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 @@ -45,8 +45,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 a3583836d..dca79f580 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,6 +4,7 @@ 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', @@ -13,6 +14,7 @@ import { AnnotationReferencesService } from '../../services/annotation-reference }) export class AnnotationsListComponent implements OnChanges { @Input() file: File; + @Input() fileData: FileDataModel; @Input() annotations: AnnotationWrapper[]; @Input() selectedAnnotations: AnnotationWrapper[]; @Input() annotationActionsTemplate: TemplateRef; @@ -54,18 +56,10 @@ export class AnnotationsListComponent implements OnChanges { referenceClicked(annotation: AnnotationWrapper): void { this.annotationClicked(annotation, null); if (this._filterService.filtersEnabled('primaryFilters')) { - this.toggleFilterAndChildren(annotation); + this._filterService.toggleFilter('primaryFilters', annotation.superType); } } - toggleFilterAndChildren(annotation: AnnotationWrapper): void { - const primaryFilters = this._filterService.getGroup('primaryFilters'); - const filter = primaryFilters.filters.find(f => f.id === annotation.superType); - filter.checked = true; - filter.children.forEach(f => (f.checked = true)); - this._filterService.refresh(); - } - isSelected(annotationId: string): boolean { return !!this.selectedAnnotations?.find(a => a?.annotationId === annotationId); } 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 71c41366d..e87104673 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,6 +203,7 @@ [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/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index b90dd8d93..b8a4fe9b0 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 @@ -107,6 +107,7 @@ [annotationActionsTemplate]="annotationActionsTemplate" [annotations]="visibleAnnotations" [dialogRef]="dialogRef" + [fileData]="fileData" [file]="file" [selectedAnnotations]="selectedAnnotations" [viewer]="activeViewer"