From 409454972dd0568e75b0ea0ebcf8b4dc20a6d066 Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Mon, 17 Jan 2022 14:20:14 +0200 Subject: [PATCH] wip has references --- .../annotation-actions.component.html | 4 ++-- .../annotation-actions.component.ts | 4 +--- .../annotation-references-dialog.component.ts | 4 ++-- .../annotations-list.component.html | 6 +++--- .../annotations-list.component.ts | 2 +- .../services/annotation-references.service.ts | 18 ++++++++++++------ 6 files changed, 21 insertions(+), 17 deletions(-) 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 511d3dfde..5bcf080fb 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 @@ -88,8 +88,8 @@ > (); annotationPermissions: AnnotationPermissions; - referencesButtonEnabled = false; constructor( private readonly _manualAnnotationService: ManualAnnotationService, @@ -64,8 +63,7 @@ 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; + this.annotationReferencesService.setAnnotation(this._annotations); } get viewerAnnotations() { 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 0131ae11f..60db300f1 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,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { File } from '@red/domain'; @@ -23,7 +23,7 @@ export class AnnotationReferencesDialogComponent implements OnChanges { constructor(readonly annotationReferencesService: AnnotationReferencesService) {} - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this.annotationReferences = this.fileData.allAnnotations.filter(a => this.annotation.reference.includes(a.annotationId)); } } 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 6e046bfdb..291ab7cd0 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,11 @@ - + 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 dca79f580..19877e3bc 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 @@ -56,7 +56,7 @@ export class AnnotationsListComponent implements OnChanges { referenceClicked(annotation: AnnotationWrapper): void { this.annotationClicked(annotation, null); if (this._filterService.filtersEnabled('primaryFilters')) { - this._filterService.toggleFilter('primaryFilters', annotation.superType); + this._filterService.toggleFilter('primaryFilters', annotation.superType, true); } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-references.service.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-references.service.ts index 26cc1f09e..702f0124f 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-references.service.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-references.service.ts @@ -2,25 +2,31 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; import { shareDistinctLast } from '@iqser/common-ui'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { map } from 'rxjs/operators'; @Injectable() export class AnnotationReferencesService { readonly annotation$: Observable; - private readonly _annotation$ = new BehaviorSubject(null); + readonly hasReferences$: Observable; + readonly showReferences$: Observable; + private readonly _annotation$: BehaviorSubject = new BehaviorSubject(null); + private readonly _showReferences$: BehaviorSubject = new BehaviorSubject(false); constructor() { this.annotation$ = this._annotation$.asObservable().pipe(shareDistinctLast()); + this.showReferences$ = this._showReferences$.asObservable().pipe(shareDistinctLast()); + this.hasReferences$ = this.annotation$.pipe(map(annotation => !!annotation.reference && annotation.reference.length !== 0)); } - hasReferences(annotations: AnnotationWrapper[]): boolean { - return !!annotations[0].reference && annotations[0].reference.length !== 0; + setAnnotation(annotation: AnnotationWrapper[]): void { + this._annotation$.next(annotation[0]); } - show(annotations: AnnotationWrapper[]) { - this._annotation$.next(annotations[0]); + show() { + this._showReferences$.next(true); } hide() { - this._annotation$.next(null); + this._showReferences$.next(false); } }