fixed some pr comments

This commit is contained in:
Edi Cziszter 2022-01-17 11:53:36 +02:00
parent e35290029b
commit b795b50c84
9 changed files with 22 additions and 42 deletions

View File

@ -89,7 +89,7 @@
<iqser-circle-button <iqser-circle-button
(action)="annotationReferencesService.show(annotations)" (action)="annotationReferencesService.show(annotations)"
*ngIf="annotationReferencesService.hasReferences(annotations) && !multiSelectService.isActive" *ngIf="referencesButtonEnabled"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.see-references.label' | translate" [tooltip]="'annotation-actions.see-references.label' | translate"
[type]="buttonType" [type]="buttonType"

View File

@ -41,6 +41,7 @@ export class AnnotationActionsComponent implements OnChanges {
@Input() @Required() file!: File; @Input() @Required() file!: File;
@Output() annotationsChanged = new EventEmitter<AnnotationWrapper>(); @Output() annotationsChanged = new EventEmitter<AnnotationWrapper>();
annotationPermissions: AnnotationPermissions; annotationPermissions: AnnotationPermissions;
referencesButtonEnabled = false;
constructor( constructor(
private readonly _manualAnnotationService: ManualAnnotationService, private readonly _manualAnnotationService: ManualAnnotationService,
@ -63,6 +64,8 @@ export class AnnotationActionsComponent implements OnChanges {
@Input() @Input()
set annotations(value: AnnotationWrapper[]) { set annotations(value: AnnotationWrapper[]) {
this._annotations = value.filter(a => a !== undefined); this._annotations = value.filter(a => a !== undefined);
this.referencesButtonEnabled =
this.annotationReferencesService.hasReferences(this._annotations) && !this.multiSelectService.isActive;
} }
get viewerAnnotations() { get viewerAnnotations() {

View File

@ -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 { AnnotationWrapper } from '../../../../../../models/file/annotation.wrapper';
import { File } from '@red/domain'; import { File } from '@red/domain';
import { MultiSelectService } from '../../services/multi-select.service'; import { MultiSelectService } from '../../services/multi-select.service';
@ -7,6 +7,7 @@ import { MultiSelectService } from '../../services/multi-select.service';
selector: 'redaction-annotation-card', selector: 'redaction-annotation-card',
templateUrl: './annotation-card.component.html', templateUrl: './annotation-card.component.html',
styleUrls: ['./annotation-card.component.scss'], styleUrls: ['./annotation-card.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class AnnotationCardComponent { export class AnnotationCardComponent {
@Input() annotation: AnnotationWrapper; @Input() annotation: AnnotationWrapper;

View File

@ -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 { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { AnnotationReferencesService } from '../../services/annotation-references.service';
import { File } from '@red/domain'; import { File } from '@red/domain';
import { PdfViewerDataService } from '../../../../services/pdf-viewer-data.service';
import { FileDataModel } from '@models/file/file-data.model'; import { FileDataModel } from '@models/file/file-data.model';
@Component({ @Component({
selector: 'redaction-annotation-references-dialog', selector: 'redaction-annotation-references-dialog',
templateUrl: './annotation-references-dialog.component.html', templateUrl: './annotation-references-dialog.component.html',
styleUrls: ['./annotation-references-dialog.component.scss'], styleUrls: ['./annotation-references-dialog.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class AnnotationReferencesDialogComponent implements OnInit, OnChanges { export class AnnotationReferencesDialogComponent implements OnChanges {
@Input() @Input()
annotation: AnnotationWrapper; annotation: AnnotationWrapper;
@Input() @Input()
file: File; file: File;
@Input()
fileData: FileDataModel;
@Output() @Output()
readonly referenceClicked = new EventEmitter<AnnotationWrapper>(); readonly referenceClicked = new EventEmitter<AnnotationWrapper>();
fileData: FileDataModel;
annotationReferences: AnnotationWrapper[]; annotationReferences: AnnotationWrapper[];
constructor( constructor(readonly annotationReferencesService: AnnotationReferencesService) {}
readonly annotationReferencesService: AnnotationReferencesService,
private readonly _fileDownloadService: PdfViewerDataService,
) {}
async ngOnInit(): Promise<void> { ngOnChanges(changes: SimpleChanges): void {
console.log(this.annotation);
await this.setReferences();
}
async ngOnChanges(changes: SimpleChanges): Promise<void> {
await this.setReferences();
}
async setReferences(): Promise<void> {
await this._loadFileData(this.file);
this.annotationReferences = this.fileData.allAnnotations.filter(a => this.annotation.reference.includes(a.annotationId)); this.annotationReferences = this.fileData.allAnnotations.filter(a => this.annotation.reference.includes(a.annotationId));
} }
private async _loadFileData(file: File): Promise<void> {
const fileData = await this._fileDownloadService.loadDataFor(file, this.fileData).toPromise();
if (file.isPending) {
return;
}
this.fileData = fileData;
}
} }

View File

@ -1,9 +1,10 @@
import { Component, Input } from '@angular/core'; import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
@Component({ @Component({
selector: 'redaction-annotation-references-page-indicator', selector: 'redaction-annotation-references-page-indicator',
templateUrl: './annotation-references-page-indicator.component.html', templateUrl: './annotation-references-page-indicator.component.html',
styleUrls: ['./annotation-references-page-indicator.component.scss'], styleUrls: ['./annotation-references-page-indicator.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class AnnotationReferencesPageIndicatorComponent { export class AnnotationReferencesPageIndicatorComponent {
@Input() number; @Input() number;

View File

@ -45,8 +45,9 @@
</div> </div>
<redaction-annotation-references-dialog <redaction-annotation-references-dialog
(referenceClicked)="referenceClicked($event)"
*ngIf="annotationReferencesService.annotation$ | async as annotation" *ngIf="annotationReferencesService.annotation$ | async as annotation"
[annotation]="annotation" [annotation]="annotation"
[fileData]="fileData"
[file]="file" [file]="file"
(referenceClicked)="referenceClicked($event)"
></redaction-annotation-references-dialog> ></redaction-annotation-references-dialog>

View File

@ -4,6 +4,7 @@ import { FilterService, HelpModeService, IqserEventTarget } from '@iqser/common-
import { File } from '@red/domain'; import { File } from '@red/domain';
import { MultiSelectService } from '../../services/multi-select.service'; import { MultiSelectService } from '../../services/multi-select.service';
import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { AnnotationReferencesService } from '../../services/annotation-references.service';
import { FileDataModel } from '../../../../../../models/file/file-data.model';
@Component({ @Component({
selector: 'redaction-annotations-list', selector: 'redaction-annotations-list',
@ -13,6 +14,7 @@ import { AnnotationReferencesService } from '../../services/annotation-reference
}) })
export class AnnotationsListComponent implements OnChanges { export class AnnotationsListComponent implements OnChanges {
@Input() file: File; @Input() file: File;
@Input() fileData: FileDataModel;
@Input() annotations: AnnotationWrapper[]; @Input() annotations: AnnotationWrapper[];
@Input() selectedAnnotations: AnnotationWrapper[]; @Input() selectedAnnotations: AnnotationWrapper[];
@Input() annotationActionsTemplate: TemplateRef<unknown>; @Input() annotationActionsTemplate: TemplateRef<unknown>;
@ -54,18 +56,10 @@ export class AnnotationsListComponent implements OnChanges {
referenceClicked(annotation: AnnotationWrapper): void { referenceClicked(annotation: AnnotationWrapper): void {
this.annotationClicked(annotation, null); this.annotationClicked(annotation, null);
if (this._filterService.filtersEnabled('primaryFilters')) { 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 { isSelected(annotationId: string): boolean {
return !!this.selectedAnnotations?.find(a => a?.annotationId === annotationId); return !!this.selectedAnnotations?.find(a => a?.annotationId === annotationId);
} }

View File

@ -203,6 +203,7 @@
[annotationActionsTemplate]="annotationActionsTemplate" [annotationActionsTemplate]="annotationActionsTemplate"
[annotations]="(displayedAnnotations$ | async)?.get(activeViewerPage)" [annotations]="(displayedAnnotations$ | async)?.get(activeViewerPage)"
[canMultiSelect]="!isReadOnly" [canMultiSelect]="!isReadOnly"
[fileData]="fileData"
[file]="file" [file]="file"
[selectedAnnotations]="selectedAnnotations" [selectedAnnotations]="selectedAnnotations"
iqserHelpMode="workload-annotations-list" iqserHelpMode="workload-annotations-list"

View File

@ -107,6 +107,7 @@
[annotationActionsTemplate]="annotationActionsTemplate" [annotationActionsTemplate]="annotationActionsTemplate"
[annotations]="visibleAnnotations" [annotations]="visibleAnnotations"
[dialogRef]="dialogRef" [dialogRef]="dialogRef"
[fileData]="fileData"
[file]="file" [file]="file"
[selectedAnnotations]="selectedAnnotations" [selectedAnnotations]="selectedAnnotations"
[viewer]="activeViewer" [viewer]="activeViewer"