wip has references
This commit is contained in:
parent
c8f19f68e0
commit
409454972d
@ -88,8 +88,8 @@
|
||||
></iqser-circle-button>
|
||||
|
||||
<iqser-circle-button
|
||||
(action)="annotationReferencesService.show(annotations)"
|
||||
*ngIf="referencesButtonEnabled"
|
||||
(action)="annotationReferencesService.show()"
|
||||
*ngIf="(annotationReferencesService.hasReferences$ | async) && !multiSelectService.isActive"
|
||||
[tooltipPosition]="tooltipPosition"
|
||||
[tooltip]="'annotation-actions.see-references.label' | translate"
|
||||
[type]="buttonType"
|
||||
|
||||
@ -41,7 +41,6 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
@Input() @Required() file!: File;
|
||||
@Output() annotationsChanged = new EventEmitter<AnnotationWrapper>();
|
||||
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() {
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,11 +44,11 @@
|
||||
<redaction-annotation-details [annotation]="annotation"></redaction-annotation-details>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="annotationReferencesService.annotation$ | async as annotation">
|
||||
<ng-container *ngIf="annotationReferencesService.showReferences$ | async">
|
||||
<redaction-annotation-references-dialog
|
||||
(referenceClicked)="referenceClicked($event)"
|
||||
*ngIf="annotationReferencesService.hasReferences([annotation])"
|
||||
[annotation]="annotation"
|
||||
*ngIf="annotationReferencesService.hasReferences$ | async"
|
||||
[annotation]="annotationReferencesService.annotation$ | async"
|
||||
[fileData]="fileData"
|
||||
[file]="file"
|
||||
></redaction-annotation-references-dialog>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<AnnotationWrapper>;
|
||||
private readonly _annotation$ = new BehaviorSubject(null);
|
||||
readonly hasReferences$: Observable<boolean>;
|
||||
readonly showReferences$: Observable<boolean>;
|
||||
private readonly _annotation$: BehaviorSubject<AnnotationWrapper> = new BehaviorSubject<AnnotationWrapper>(null);
|
||||
private readonly _showReferences$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user