RED-3738: Removed selectAnnotations event emitter
This commit is contained in:
parent
98f435b901
commit
a24edcfa60
@ -32,7 +32,6 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O
|
|||||||
@Input() activeViewerPage: number;
|
@Input() activeViewerPage: number;
|
||||||
|
|
||||||
@Output() readonly pagesPanelActive = new EventEmitter<boolean>();
|
@Output() readonly pagesPanelActive = new EventEmitter<boolean>();
|
||||||
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
|
|
||||||
|
|
||||||
highlightGroups$ = new BehaviorSubject<TextHighlightsGroup[]>([]);
|
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) {
|
if (canMultiSelect && ($event?.ctrlKey || $event?.metaKey) && this._listingService.selected.length > 0) {
|
||||||
this._multiSelectService.activate();
|
this._multiSelectService.activate();
|
||||||
}
|
}
|
||||||
this.selectAnnotations.emit([annotation]);
|
this._pdf.selectAnnotations([annotation]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
<div *ngIf="multiSelectService.active$ | async" class="multi-select">
|
<div *ngIf="multiSelectService.active$ | async" class="multi-select">
|
||||||
<div class="selected-wrapper">
|
<div class="selected-wrapper">
|
||||||
<iqser-round-checkbox
|
<iqser-round-checkbox
|
||||||
(click)="selectAnnotations.emit()"
|
(click)="pdf.selectAnnotations()"
|
||||||
[indeterminate]="listingService.areSomeSelected$ | async"
|
[indeterminate]="listingService.areSomeSelected$ | async"
|
||||||
type="with-bg"
|
type="with-bg"
|
||||||
></iqser-round-checkbox>
|
></iqser-round-checkbox>
|
||||||
@ -213,7 +213,6 @@
|
|||||||
|
|
||||||
<redaction-annotations-list
|
<redaction-annotations-list
|
||||||
(pagesPanelActive)="pagesPanelActive = $event"
|
(pagesPanelActive)="pagesPanelActive = $event"
|
||||||
(selectAnnotations)="selectAnnotations.emit($event)"
|
|
||||||
[activeViewerPage]="activeViewerPage"
|
[activeViewerPage]="activeViewerPage"
|
||||||
[annotationActionsTemplate]="annotationActionsTemplate"
|
[annotationActionsTemplate]="annotationActionsTemplate"
|
||||||
[annotations]="(displayedAnnotations$ | async)?.get(activeViewerPage)"
|
[annotations]="(displayedAnnotations$ | async)?.get(activeViewerPage)"
|
||||||
|
|||||||
@ -56,7 +56,6 @@ export class FileWorkloadComponent {
|
|||||||
@Input() dialogRef: MatDialogRef<unknown>;
|
@Input() dialogRef: MatDialogRef<unknown>;
|
||||||
@Input() file!: File;
|
@Input() file!: File;
|
||||||
@Input() annotationActionsTemplate: TemplateRef<unknown>;
|
@Input() annotationActionsTemplate: TemplateRef<unknown>;
|
||||||
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
|
|
||||||
@Output() readonly selectPage = new EventEmitter<number>();
|
@Output() readonly selectPage = new EventEmitter<number>();
|
||||||
displayedPages: number[] = [];
|
displayedPages: number[] = [];
|
||||||
pagesPanelActive = true;
|
pagesPanelActive = true;
|
||||||
@ -78,7 +77,7 @@ export class FileWorkloadComponent {
|
|||||||
readonly fileDataService: FileDataService,
|
readonly fileDataService: FileDataService,
|
||||||
readonly viewModeService: ViewModeService,
|
readonly viewModeService: ViewModeService,
|
||||||
readonly listingService: ListingService<AnnotationWrapper>,
|
readonly listingService: ListingService<AnnotationWrapper>,
|
||||||
private readonly _pdf: PdfViewer,
|
readonly pdf: PdfViewer,
|
||||||
private readonly _changeDetectorRef: ChangeDetectorRef,
|
private readonly _changeDetectorRef: ChangeDetectorRef,
|
||||||
private readonly _annotationProcessingService: AnnotationProcessingService,
|
private readonly _annotationProcessingService: AnnotationProcessingService,
|
||||||
) {
|
) {
|
||||||
@ -122,7 +121,7 @@ export class FileWorkloadComponent {
|
|||||||
return this.multiSelectService.inactive$.pipe(
|
return this.multiSelectService.inactive$.pipe(
|
||||||
tap(value => {
|
tap(value => {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.selectAnnotations.emit();
|
this.pdf.selectAnnotations();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
shareDistinctLast(),
|
shareDistinctLast(),
|
||||||
@ -167,11 +166,11 @@ export class FileWorkloadComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectAllOnActivePage() {
|
selectAllOnActivePage() {
|
||||||
this.selectAnnotations.emit(this.activeAnnotations);
|
this.pdf.selectAnnotations(this.activeAnnotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
deselectAllOnActivePage(): void {
|
deselectAllOnActivePage(): void {
|
||||||
this._pdf.deselectAnnotations(this.activeAnnotations);
|
this.pdf.deselectAnnotations(this.activeAnnotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:keyup', ['$event'])
|
@HostListener('window:keyup', ['$event'])
|
||||||
@ -279,18 +278,18 @@ export class FileWorkloadComponent {
|
|||||||
if (!this._firstSelectedAnnotation || this.activeViewerPage !== this._firstSelectedAnnotation.pageNumber) {
|
if (!this._firstSelectedAnnotation || this.activeViewerPage !== this._firstSelectedAnnotation.pageNumber) {
|
||||||
if (this.displayedPages.indexOf(this.activeViewerPage) !== -1) {
|
if (this.displayedPages.indexOf(this.activeViewerPage) !== -1) {
|
||||||
// Displayed page has annotations
|
// 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
|
// Displayed page doesn't have annotations
|
||||||
if ($event.key === 'ArrowDown') {
|
if ($event.key === 'ArrowDown') {
|
||||||
const nextPage = this._nextPageWithAnnotations();
|
const nextPage = this._nextPageWithAnnotations();
|
||||||
this.selectAnnotations.emit([this.displayedAnnotations.get(nextPage)[0]]);
|
this.pdf.selectAnnotations([this.displayedAnnotations.get(nextPage)[0]]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevPage = this._prevPageWithAnnotations();
|
const prevPage = this._prevPageWithAnnotations();
|
||||||
const prevPageAnnotations = this.displayedAnnotations.get(prevPage);
|
const prevPageAnnotations = this.displayedAnnotations.get(prevPage);
|
||||||
this.selectAnnotations.emit([prevPageAnnotations[prevPageAnnotations.length - 1]]);
|
this.pdf.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,13 +303,13 @@ export class FileWorkloadComponent {
|
|||||||
if ($event.key === 'ArrowDown') {
|
if ($event.key === 'ArrowDown') {
|
||||||
if (idx + 1 !== annotationsOnPage.length) {
|
if (idx + 1 !== annotationsOnPage.length) {
|
||||||
// If not last item in page
|
// If not last item in page
|
||||||
this.selectAnnotations.emit([annotationsOnPage[idx + 1]]);
|
this.pdf.selectAnnotations([annotationsOnPage[idx + 1]]);
|
||||||
} else if (nextPageIdx < this.displayedPages.length) {
|
} else if (nextPageIdx < this.displayedPages.length) {
|
||||||
// If not last page
|
// If not last page
|
||||||
for (let i = nextPageIdx; i < this.displayedPages.length; i++) {
|
for (let i = nextPageIdx; i < this.displayedPages.length; i++) {
|
||||||
const nextPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]);
|
const nextPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]);
|
||||||
if (nextPageAnnotations) {
|
if (nextPageAnnotations) {
|
||||||
this.selectAnnotations.emit([nextPageAnnotations[0]]);
|
this.pdf.selectAnnotations([nextPageAnnotations[0]]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +319,7 @@ export class FileWorkloadComponent {
|
|||||||
|
|
||||||
if (idx !== 0) {
|
if (idx !== 0) {
|
||||||
// If not first item in page
|
// If not first item in page
|
||||||
return this.selectAnnotations.emit([annotationsOnPage[idx - 1]]);
|
return this.pdf.selectAnnotations([annotationsOnPage[idx - 1]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pageIdx) {
|
if (pageIdx) {
|
||||||
@ -328,7 +327,7 @@ export class FileWorkloadComponent {
|
|||||||
for (let i = previousPageIdx; i >= 0; i--) {
|
for (let i = previousPageIdx; i >= 0; i--) {
|
||||||
const prevPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]);
|
const prevPageAnnotations = this.displayedAnnotations.get(this.displayedPages[i]);
|
||||||
if (prevPageAnnotations) {
|
if (prevPageAnnotations) {
|
||||||
this.selectAnnotations.emit([prevPageAnnotations[prevPageAnnotations.length - 1]]);
|
this.pdf.selectAnnotations([prevPageAnnotations[prevPageAnnotations.length - 1]]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +375,7 @@ export class FileWorkloadComponent {
|
|||||||
this.displayedPages.indexOf(this.activeViewerPage) >= 0 &&
|
this.displayedPages.indexOf(this.activeViewerPage) >= 0 &&
|
||||||
this.activeAnnotations.length > 0
|
this.activeAnnotations.length > 0
|
||||||
) {
|
) {
|
||||||
this.selectAnnotations.emit([this.activeAnnotations[0]]);
|
this.pdf.selectAnnotations([this.activeAnnotations[0]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,6 @@
|
|||||||
|
|
||||||
<redaction-file-workload
|
<redaction-file-workload
|
||||||
#fileWorkloadComponent
|
#fileWorkloadComponent
|
||||||
(selectAnnotations)="selectAnnotations($event)"
|
|
||||||
(selectPage)="selectPage($event)"
|
(selectPage)="selectPage($event)"
|
||||||
*ngIf="!file.excluded"
|
*ngIf="!file.excluded"
|
||||||
[activeViewerPage]="pdf.currentPage"
|
[activeViewerPage]="pdf.currentPage"
|
||||||
|
|||||||
@ -243,16 +243,6 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
|||||||
this._changeDetectorRef.markForCheck();
|
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) {
|
selectPage(pageNumber: number) {
|
||||||
this.pdf.navigateToPage(pageNumber);
|
this.pdf.navigateToPage(pageNumber);
|
||||||
this._workloadComponent?.scrollAnnotationsToPage(pageNumber, 'always');
|
this._workloadComponent?.scrollAnnotationsToPage(pageNumber, 'always');
|
||||||
|
|||||||
@ -10,7 +10,8 @@ import { DISABLED_HOTKEYS } from '../shared/constants';
|
|||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import { tap } from 'rxjs/operators';
|
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;
|
import Annotation = Core.Annotations.Annotation;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -23,6 +24,8 @@ export class PdfViewer {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(BASE_HREF) private readonly _baseHref: string,
|
@Inject(BASE_HREF) private readonly _baseHref: string,
|
||||||
private readonly _viewModeService: ViewModeService,
|
private readonly _viewModeService: ViewModeService,
|
||||||
|
private readonly _multiSelectService: MultiSelectService,
|
||||||
|
private readonly _listingService: ListingService<AnnotationWrapper>,
|
||||||
private readonly _logger: NGXLogger,
|
private readonly _logger: NGXLogger,
|
||||||
) {
|
) {
|
||||||
this.documentLoaded$ = this.#documentLoaded$.asObservable().pipe(
|
this.documentLoaded$ = this.#documentLoaded$.asObservable().pipe(
|
||||||
@ -178,25 +181,15 @@ export class PdfViewer {
|
|||||||
this.annotationManager?.deselectAllAnnotations();
|
this.annotationManager?.deselectAllAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
selectAnnotations(annotations: AnnotationWrapper[], multiSelectActive: boolean = false) {
|
selectAnnotations(annotations?: AnnotationWrapper[]) {
|
||||||
if (!annotations) {
|
if (annotations) {
|
||||||
return;
|
const annotationsToSelect = this._multiSelectService.isActive
|
||||||
}
|
? [...this._listingService.selected, ...annotations]
|
||||||
|
: annotations;
|
||||||
const filteredAnnotations = annotations.filter(a => !!a);
|
this.#selectAnnotations(annotationsToSelect);
|
||||||
|
} else {
|
||||||
if (!filteredAnnotations.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!multiSelectActive) {
|
|
||||||
this.deselectAllAnnotations();
|
this.deselectAllAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
const annotationsFromViewer = this.getAnnotationsById(filteredAnnotations.map(a => a.id));
|
|
||||||
|
|
||||||
this.annotationManager.jumpToAnnotation(annotationsFromViewer[0]);
|
|
||||||
this.annotationManager.selectAnnotations(annotationsFromViewer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAnnotations(annotationsIds?: readonly string[]) {
|
deleteAnnotations(annotationsIds?: readonly string[]) {
|
||||||
@ -221,6 +214,27 @@ export class PdfViewer {
|
|||||||
this.annotationManager.deselectAnnotations(ann);
|
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) {
|
private _navigateToPage(pageNumber: number) {
|
||||||
if (this._currentInternalPage !== pageNumber) {
|
if (this._currentInternalPage !== pageNumber) {
|
||||||
this.documentViewer.displayPageLocation(pageNumber, 0, 0);
|
this.documentViewer.displayPageLocation(pageNumber, 0, 0);
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit 3c0d4368c70975255478d5ee038587c1ea97ecf8
|
Subproject commit 5adbd5342fe94e2d1292054e7f0a8c6185b9420e
|
||||||
Loading…
x
Reference in New Issue
Block a user