RED-3738: Removed selectAnnotations event emitter

This commit is contained in:
Adina Țeudan 2022-04-11 15:25:17 +03:00
parent 98f435b901
commit a24edcfa60
7 changed files with 47 additions and 47 deletions

View File

@ -32,7 +32,6 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O
@Input() activeViewerPage: number;
@Output() readonly pagesPanelActive = new EventEmitter<boolean>();
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
highlightGroups$ = new BehaviorSubject<TextHighlightsGroup[]>([]);
@ -82,7 +81,7 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O
if (canMultiSelect && ($event?.ctrlKey || $event?.metaKey) && this._listingService.selected.length > 0) {
this._multiSelectService.activate();
}
this.selectAnnotations.emit([annotation]);
this._pdf.selectAnnotations([annotation]);
}
}

View File

@ -48,7 +48,7 @@
<div *ngIf="multiSelectService.active$ | async" class="multi-select">
<div class="selected-wrapper">
<iqser-round-checkbox
(click)="selectAnnotations.emit()"
(click)="pdf.selectAnnotations()"
[indeterminate]="listingService.areSomeSelected$ | async"
type="with-bg"
></iqser-round-checkbox>
@ -213,7 +213,6 @@
<redaction-annotations-list
(pagesPanelActive)="pagesPanelActive = $event"
(selectAnnotations)="selectAnnotations.emit($event)"
[activeViewerPage]="activeViewerPage"
[annotationActionsTemplate]="annotationActionsTemplate"
[annotations]="(displayedAnnotations$ | async)?.get(activeViewerPage)"

View File

@ -56,7 +56,6 @@ export class FileWorkloadComponent {
@Input() dialogRef: MatDialogRef<unknown>;
@Input() file!: File;
@Input() annotationActionsTemplate: TemplateRef<unknown>;
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
@Output() readonly selectPage = new EventEmitter<number>();
displayedPages: number[] = [];
pagesPanelActive = true;
@ -78,7 +77,7 @@ export class FileWorkloadComponent {
readonly fileDataService: FileDataService,
readonly viewModeService: ViewModeService,
readonly listingService: ListingService<AnnotationWrapper>,
private readonly _pdf: PdfViewer,
readonly pdf: PdfViewer,
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _annotationProcessingService: AnnotationProcessingService,
) {
@ -122,7 +121,7 @@ export class FileWorkloadComponent {
return this.multiSelectService.inactive$.pipe(
tap(value => {
if (value) {
this.selectAnnotations.emit();
this.pdf.selectAnnotations();
}
}),
shareDistinctLast(),
@ -167,11 +166,11 @@ export class FileWorkloadComponent {
}
selectAllOnActivePage() {
this.selectAnnotations.emit(this.activeAnnotations);
this.pdf.selectAnnotations(this.activeAnnotations);
}
deselectAllOnActivePage(): void {
this._pdf.deselectAnnotations(this.activeAnnotations);
this.pdf.deselectAnnotations(this.activeAnnotations);
}
@HostListener('window:keyup', ['$event'])
@ -279,18 +278,18 @@ export class FileWorkloadComponent {
if (!this._firstSelectedAnnotation || this.activeViewerPage !== this._firstSelectedAnnotation.pageNumber) {
if (this.displayedPages.indexOf(this.activeViewerPage) !== -1) {
// Displayed page has annotations
return this.selectAnnotations.emit(this.activeAnnotations ? [this.activeAnnotations[0]] : null);
return this.pdf.selectAnnotations(this.activeAnnotations ? [this.activeAnnotations[0]] : null);
}
// Displayed page doesn't have annotations
if ($event.key === 'ArrowDown') {
const nextPage = this._nextPageWithAnnotations();
this.selectAnnotations.emit([this.displayedAnnotations.get(nextPage)[0]]);
this.pdf.selectAnnotations([this.displayedAnnotations.get(nextPage)[0]]);
return;
}
const prevPage = this._prevPageWithAnnotations();
const prevPageAnnotations = this.displayedAnnotations.get(prevPage);
this.selectAnnotations.emit([prevPageAnnotations[prevPageAnnotations.length - 1]]);
this.pdf.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]);
return;
}
@ -304,13 +303,13 @@ export class FileWorkloadComponent {
if ($event.key === 'ArrowDown') {
if (idx + 1 !== annotationsOnPage.length) {
// If not last item in page
this.selectAnnotations.emit([annotationsOnPage[idx + 1]]);
this.pdf.selectAnnotations([annotationsOnPage[idx + 1]]);
} else if (nextPageIdx < this.displayedPages.length) {
// If not last page
for (let i = nextPageIdx; i < this.displayedPages.length; i++) {
const nextPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]);
if (nextPageAnnotations) {
this.selectAnnotations.emit([nextPageAnnotations[0]]);
this.pdf.selectAnnotations([nextPageAnnotations[0]]);
break;
}
}
@ -320,7 +319,7 @@ export class FileWorkloadComponent {
if (idx !== 0) {
// If not first item in page
return this.selectAnnotations.emit([annotationsOnPage[idx - 1]]);
return this.pdf.selectAnnotations([annotationsOnPage[idx - 1]]);
}
if (pageIdx) {
@ -328,7 +327,7 @@ export class FileWorkloadComponent {
for (let i = previousPageIdx; i >= 0; i--) {
const prevPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]);
if (prevPageAnnotations) {
this.selectAnnotations.emit([prevPageAnnotations[prevPageAnnotations.length - 1]]);
this.pdf.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]);
break;
}
}
@ -376,7 +375,7 @@ export class FileWorkloadComponent {
this.displayedPages.indexOf(this.activeViewerPage) >= 0 &&
this.activeAnnotations.length > 0
) {
this.selectAnnotations.emit([this.activeAnnotations[0]]);
this.pdf.selectAnnotations([this.activeAnnotations[0]]);
}
}

View File

@ -87,7 +87,6 @@
<redaction-file-workload
#fileWorkloadComponent
(selectAnnotations)="selectAnnotations($event)"
(selectPage)="selectPage($event)"
*ngIf="!file.excluded"
[activeViewerPage]="pdf.currentPage"

View File

@ -243,16 +243,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
this._changeDetectorRef.markForCheck();
}
@Debounce(10)
selectAnnotations(annotations: AnnotationWrapper[]) {
if (annotations) {
const annotationsToSelect = this.multiSelectService.isActive ? [...this.listingService.selected, ...annotations] : annotations;
this.pdf.selectAnnotations(annotationsToSelect, this.multiSelectService.isActive);
} else {
this.pdf.deselectAllAnnotations();
}
}
selectPage(pageNumber: number) {
this.pdf.navigateToPage(pageNumber);
this._workloadComponent?.scrollAnnotationsToPage(pageNumber, 'always');

View File

@ -10,7 +10,8 @@ import { DISABLED_HOTKEYS } from '../shared/constants';
import { Observable, Subject } from 'rxjs';
import { NGXLogger } from 'ngx-logger';
import { tap } from 'rxjs/operators';
import { shareLast } from '@iqser/common-ui';
import { ListingService, shareLast } from '@iqser/common-ui';
import { MultiSelectService } from './multi-select.service';
import Annotation = Core.Annotations.Annotation;
@Injectable()
@ -23,6 +24,8 @@ export class PdfViewer {
constructor(
@Inject(BASE_HREF) private readonly _baseHref: string,
private readonly _viewModeService: ViewModeService,
private readonly _multiSelectService: MultiSelectService,
private readonly _listingService: ListingService<AnnotationWrapper>,
private readonly _logger: NGXLogger,
) {
this.documentLoaded$ = this.#documentLoaded$.asObservable().pipe(
@ -178,25 +181,15 @@ export class PdfViewer {
this.annotationManager?.deselectAllAnnotations();
}
selectAnnotations(annotations: AnnotationWrapper[], multiSelectActive: boolean = false) {
if (!annotations) {
return;
}
const filteredAnnotations = annotations.filter(a => !!a);
if (!filteredAnnotations.length) {
return;
}
if (!multiSelectActive) {
selectAnnotations(annotations?: AnnotationWrapper[]) {
if (annotations) {
const annotationsToSelect = this._multiSelectService.isActive
? [...this._listingService.selected, ...annotations]
: annotations;
this.#selectAnnotations(annotationsToSelect);
} else {
this.deselectAllAnnotations();
}
const annotationsFromViewer = this.getAnnotationsById(filteredAnnotations.map(a => a.id));
this.annotationManager.jumpToAnnotation(annotationsFromViewer[0]);
this.annotationManager.selectAnnotations(annotationsFromViewer);
}
deleteAnnotations(annotationsIds?: readonly string[]) {
@ -221,6 +214,27 @@ export class PdfViewer {
this.annotationManager.deselectAnnotations(ann);
}
#selectAnnotations(annotations?: AnnotationWrapper[]) {
if (!annotations) {
return;
}
const filteredAnnotations = annotations.filter(a => !!a);
if (!filteredAnnotations.length) {
return;
}
if (!this._multiSelectService.isActive) {
this.deselectAllAnnotations();
}
const annotationsFromViewer = this.getAnnotationsById(filteredAnnotations.map(a => a.id));
this.annotationManager.jumpToAnnotation(annotationsFromViewer[0]);
this.annotationManager.selectAnnotations(annotationsFromViewer);
}
private _navigateToPage(pageNumber: number) {
if (this._currentInternalPage !== pageNumber) {
this.documentViewer.displayPageLocation(pageNumber, 0, 0);

@ -1 +1 @@
Subproject commit 3c0d4368c70975255478d5ee038587c1ea97ecf8
Subproject commit 5adbd5342fe94e2d1292054e7f0a8c6185b9420e