RED-10396 - fixed current page active annotations re evaluation when they are updated
This commit is contained in:
parent
d59a4c02a0
commit
969e375986
@ -129,7 +129,7 @@
|
|||||||
></iqser-circle-button>
|
></iqser-circle-button>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
[translateParams]="{ page: pdf.currentPage(), count: activeAnnotations.length }"
|
[translateParams]="{ page: pdf.currentPage(), count: activeAnnotations().length }"
|
||||||
[translate]="'page'"
|
[translate]="'page'"
|
||||||
class="all-caps-label"
|
class="all-caps-label"
|
||||||
></span>
|
></span>
|
||||||
@ -160,7 +160,7 @@
|
|||||||
id="annotations-list"
|
id="annotations-list"
|
||||||
tabindex="1"
|
tabindex="1"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="pdf.currentPage() && !displayedAnnotations.get(pdf.currentPage())?.length">
|
<ng-container *ngIf="pdf.currentPage() && !displayedAnnotations().get(pdf.currentPage())?.length">
|
||||||
<iqser-empty-state
|
<iqser-empty-state
|
||||||
[horizontalPadding]="24"
|
[horizontalPadding]="24"
|
||||||
[text]="'file-preview.no-data.title' | translate"
|
[text]="'file-preview.no-data.title' | translate"
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { AsyncPipe, NgIf, NgTemplateOutlet } from '@angular/common';
|
import { AsyncPipe, NgIf, NgTemplateOutlet } from '@angular/common';
|
||||||
import { ChangeDetectorRef, Component, computed, effect, ElementRef, HostListener, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import {
|
||||||
|
ChangeDetectorRef,
|
||||||
|
Component,
|
||||||
|
computed,
|
||||||
|
effect,
|
||||||
|
ElementRef,
|
||||||
|
HostListener,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
|
signal,
|
||||||
|
untracked,
|
||||||
|
ViewChild,
|
||||||
|
} from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { MatIcon } from '@angular/material/icon';
|
import { MatIcon } from '@angular/material/icon';
|
||||||
import { MatTooltip } from '@angular/material/tooltip';
|
import { MatTooltip } from '@angular/material/tooltip';
|
||||||
@ -91,7 +103,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
protected readonly currentPageIsExcluded = computed(() => this.state.file().excludedPages.includes(this.pdf.currentPage()));
|
protected readonly currentPageIsExcluded = computed(() => this.state.file().excludedPages.includes(this.pdf.currentPage()));
|
||||||
protected readonly translations = workloadTranslations;
|
protected readonly translations = workloadTranslations;
|
||||||
protected readonly isDocumine = getConfig().IS_DOCUMINE;
|
protected readonly isDocumine = getConfig().IS_DOCUMINE;
|
||||||
displayedAnnotations = new Map<number, AnnotationWrapper[]>();
|
displayedAnnotations = signal(new Map<number, AnnotationWrapper[]>());
|
||||||
|
readonly activeAnnotations = computed(() => this.displayedAnnotations().get(this.pdf.currentPage()) || []);
|
||||||
displayedPages: number[] = [];
|
displayedPages: number[] = [];
|
||||||
pagesPanelActive = true;
|
pagesPanelActive = true;
|
||||||
|
|
||||||
@ -156,10 +169,6 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get activeAnnotations(): AnnotationWrapper[] {
|
|
||||||
return this.displayedAnnotations.get(this.pdf.currentPage()) || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get showAnalysisDisabledBanner() {
|
get showAnalysisDisabledBanner() {
|
||||||
const file = this.state.file();
|
const file = this.state.file();
|
||||||
return this.isDocumine && file.excludedFromAutomaticAnalysis && file.workflowStatus !== WorkflowFileStatuses.APPROVED;
|
return this.isDocumine && file.excludedFromAutomaticAnalysis && file.workflowStatus !== WorkflowFileStatuses.APPROVED;
|
||||||
@ -216,12 +225,14 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectAllOnActivePage() {
|
selectAllOnActivePage() {
|
||||||
this.listingService.selectAnnotations(this.activeAnnotations);
|
const activeAnnotations = untracked(this.activeAnnotations);
|
||||||
|
this.listingService.selectAnnotations(activeAnnotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
deselectAllOnActivePage(): void {
|
deselectAllOnActivePage(): void {
|
||||||
this.listingService.deselect(this.activeAnnotations);
|
const activeAnnotations = untracked(this.activeAnnotations);
|
||||||
this.annotationManager.deselect(this.activeAnnotations);
|
this.listingService.deselect(activeAnnotations);
|
||||||
|
this.annotationManager.deselect(activeAnnotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:keyup', ['$event'])
|
@HostListener('window:keyup', ['$event'])
|
||||||
@ -326,20 +337,21 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
@Debounce(15)
|
@Debounce(15)
|
||||||
navigateAnnotations($event: KeyboardEvent) {
|
navigateAnnotations($event: KeyboardEvent) {
|
||||||
const currentPage = this.pdf.currentPage();
|
const currentPage = this.pdf.currentPage();
|
||||||
|
const activeAnnotations = untracked(this.activeAnnotations);
|
||||||
if (!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) {
|
if (!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) {
|
||||||
if (this.displayedPages.indexOf(currentPage) !== -1) {
|
if (this.displayedPages.indexOf(currentPage) !== -1) {
|
||||||
// Displayed page has annotations
|
// Displayed page has annotations
|
||||||
return this.listingService.selectAnnotations(this.activeAnnotations ? this.activeAnnotations[0] : null);
|
return this.listingService.selectAnnotations(activeAnnotations ? 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();
|
||||||
|
|
||||||
return this.listingService.selectAnnotations(this.displayedAnnotations.get(nextPage)[0]);
|
return this.listingService.selectAnnotations(this.displayedAnnotations().get(nextPage)[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevPage = this.#prevPageWithAnnotations();
|
const prevPage = this.#prevPageWithAnnotations();
|
||||||
const prevPageAnnotations = this.displayedAnnotations.get(prevPage);
|
const prevPageAnnotations = this.displayedAnnotations().get(prevPage);
|
||||||
|
|
||||||
return this.listingService.selectAnnotations(getLast(prevPageAnnotations));
|
return this.listingService.selectAnnotations(getLast(prevPageAnnotations));
|
||||||
}
|
}
|
||||||
@ -348,7 +360,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
const pageIdx = this.displayedPages.indexOf(page);
|
const pageIdx = this.displayedPages.indexOf(page);
|
||||||
const nextPageIdx = pageIdx + 1;
|
const nextPageIdx = pageIdx + 1;
|
||||||
const previousPageIdx = pageIdx - 1;
|
const previousPageIdx = pageIdx - 1;
|
||||||
const annotationsOnPage = this.displayedAnnotations.get(page);
|
const annotationsOnPage = this.displayedAnnotations().get(page);
|
||||||
const idx = annotationsOnPage.findIndex(a => a.id === this._firstSelectedAnnotation.id);
|
const idx = annotationsOnPage.findIndex(a => a.id === this._firstSelectedAnnotation.id);
|
||||||
|
|
||||||
if ($event.key === 'ArrowDown') {
|
if ($event.key === 'ArrowDown') {
|
||||||
@ -358,7 +370,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
} 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.listingService.selectAnnotations(nextPageAnnotations[0]);
|
this.listingService.selectAnnotations(nextPageAnnotations[0]);
|
||||||
break;
|
break;
|
||||||
@ -376,7 +388,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
if (pageIdx) {
|
if (pageIdx) {
|
||||||
// If not first page
|
// If not first page
|
||||||
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.listingService.selectAnnotations(getLast(prevPageAnnotations));
|
this.listingService.selectAnnotations(getLast(prevPageAnnotations));
|
||||||
break;
|
break;
|
||||||
@ -415,8 +427,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
annotations = annotations.filter(a => !a.isOCR);
|
annotations = annotations.filter(a => !a.isOCR);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary);
|
this.displayedAnnotations.set(this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary));
|
||||||
const pagesThatDisplayAnnotations = [...this.displayedAnnotations.keys()];
|
const pagesThatDisplayAnnotations = [...this.displayedAnnotations().keys()];
|
||||||
const enabledFilters = this.filterService.enabledFlatFilters;
|
const enabledFilters = this.filterService.enabledFlatFilters;
|
||||||
if (enabledFilters.some(f => f.id === 'pages-without-annotations')) {
|
if (enabledFilters.some(f => f.id === 'pages-without-annotations')) {
|
||||||
if (enabledFilters.length === 1 && !onlyPageWithAnnotations) {
|
if (enabledFilters.length === 1 && !onlyPageWithAnnotations) {
|
||||||
@ -424,7 +436,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
} else {
|
} else {
|
||||||
this.displayedPages = [];
|
this.displayedPages = [];
|
||||||
}
|
}
|
||||||
this.displayedAnnotations.clear();
|
this.displayedAnnotations().clear();
|
||||||
} else if (enabledFilters.length || onlyPageWithAnnotations) {
|
} else if (enabledFilters.length || onlyPageWithAnnotations) {
|
||||||
this.displayedPages = pagesThatDisplayAnnotations;
|
this.displayedPages = pagesThatDisplayAnnotations;
|
||||||
} else {
|
} else {
|
||||||
@ -432,17 +444,18 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
}
|
}
|
||||||
this.displayedPages.sort((a, b) => a - b);
|
this.displayedPages.sort((a, b) => a - b);
|
||||||
|
|
||||||
return this.displayedAnnotations;
|
return this.displayedAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
#selectFirstAnnotationOnCurrentPageIfNecessary() {
|
#selectFirstAnnotationOnCurrentPageIfNecessary() {
|
||||||
const currentPage = this.pdf.currentPage();
|
const currentPage = this.pdf.currentPage();
|
||||||
|
const activeAnnotations = untracked(this.activeAnnotations);
|
||||||
if (
|
if (
|
||||||
(!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) &&
|
(!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) &&
|
||||||
this.displayedPages.indexOf(currentPage) >= 0 &&
|
this.displayedPages.indexOf(currentPage) >= 0 &&
|
||||||
this.activeAnnotations.length > 0
|
activeAnnotations.length > 0
|
||||||
) {
|
) {
|
||||||
this.listingService.selectAnnotations(this.activeAnnotations[0]);
|
this.listingService.selectAnnotations(activeAnnotations[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +494,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
#nextPageWithAnnotations() {
|
#nextPageWithAnnotations() {
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
for (const page of this.displayedPages) {
|
for (const page of this.displayedPages) {
|
||||||
if (page > this.pdf.currentPage() && this.displayedAnnotations.get(page)) {
|
if (page > this.pdf.currentPage() && this.displayedAnnotations().get(page)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++idx;
|
++idx;
|
||||||
@ -493,7 +506,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
|
|||||||
let idx = this.displayedPages.length - 1;
|
let idx = this.displayedPages.length - 1;
|
||||||
const reverseDisplayedPages = [...this.displayedPages].reverse();
|
const reverseDisplayedPages = [...this.displayedPages].reverse();
|
||||||
for (const page of reverseDisplayedPages) {
|
for (const page of reverseDisplayedPages) {
|
||||||
if (page < this.pdf.currentPage() && this.displayedAnnotations.get(page)) {
|
if (page < this.pdf.currentPage() && this.displayedAnnotations().get(page)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--idx;
|
--idx;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user