diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html
index 8236f6291..b7c2265a4 100644
--- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html
+++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html
@@ -129,7 +129,7 @@
>
@@ -160,7 +160,7 @@
id="annotations-list"
tabindex="1"
>
-
+
this.state.file().excludedPages.includes(this.pdf.currentPage()));
protected readonly translations = workloadTranslations;
protected readonly isDocumine = getConfig().IS_DOCUMINE;
- displayedAnnotations = new Map();
+ displayedAnnotations = signal(new Map());
+ readonly activeAnnotations = computed(() => this.displayedAnnotations().get(this.pdf.currentPage()) || []);
displayedPages: number[] = [];
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() {
const file = this.state.file();
return this.isDocumine && file.excludedFromAutomaticAnalysis && file.workflowStatus !== WorkflowFileStatuses.APPROVED;
@@ -216,12 +225,14 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
}
selectAllOnActivePage() {
- this.listingService.selectAnnotations(this.activeAnnotations);
+ const activeAnnotations = untracked(this.activeAnnotations);
+ this.listingService.selectAnnotations(activeAnnotations);
}
deselectAllOnActivePage(): void {
- this.listingService.deselect(this.activeAnnotations);
- this.annotationManager.deselect(this.activeAnnotations);
+ const activeAnnotations = untracked(this.activeAnnotations);
+ this.listingService.deselect(activeAnnotations);
+ this.annotationManager.deselect(activeAnnotations);
}
@HostListener('window:keyup', ['$event'])
@@ -326,20 +337,21 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
@Debounce(15)
navigateAnnotations($event: KeyboardEvent) {
const currentPage = this.pdf.currentPage();
+ const activeAnnotations = untracked(this.activeAnnotations);
if (!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) {
if (this.displayedPages.indexOf(currentPage) !== -1) {
// 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
if ($event.key === 'ArrowDown') {
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 prevPageAnnotations = this.displayedAnnotations.get(prevPage);
+ const prevPageAnnotations = this.displayedAnnotations().get(prevPage);
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 nextPageIdx = 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);
if ($event.key === 'ArrowDown') {
@@ -358,7 +370,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
} 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]);
+ const nextPageAnnotations = this.displayedAnnotations().get(this.displayedPages[i]);
if (nextPageAnnotations) {
this.listingService.selectAnnotations(nextPageAnnotations[0]);
break;
@@ -376,7 +388,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
if (pageIdx) {
// If not first page
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) {
this.listingService.selectAnnotations(getLast(prevPageAnnotations));
break;
@@ -415,8 +427,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
annotations = annotations.filter(a => !a.isOCR);
}
- this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary);
- const pagesThatDisplayAnnotations = [...this.displayedAnnotations.keys()];
+ this.displayedAnnotations.set(this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary));
+ const pagesThatDisplayAnnotations = [...this.displayedAnnotations().keys()];
const enabledFilters = this.filterService.enabledFlatFilters;
if (enabledFilters.some(f => f.id === 'pages-without-annotations')) {
if (enabledFilters.length === 1 && !onlyPageWithAnnotations) {
@@ -424,7 +436,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
} else {
this.displayedPages = [];
}
- this.displayedAnnotations.clear();
+ this.displayedAnnotations().clear();
} else if (enabledFilters.length || onlyPageWithAnnotations) {
this.displayedPages = pagesThatDisplayAnnotations;
} else {
@@ -432,17 +444,18 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
}
this.displayedPages.sort((a, b) => a - b);
- return this.displayedAnnotations;
+ return this.displayedAnnotations();
}
#selectFirstAnnotationOnCurrentPageIfNecessary() {
const currentPage = this.pdf.currentPage();
+ const activeAnnotations = untracked(this.activeAnnotations);
if (
(!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) &&
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() {
let idx = 0;
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;
}
++idx;
@@ -493,7 +506,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
let idx = this.displayedPages.length - 1;
const reverseDisplayedPages = [...this.displayedPages].reverse();
for (const page of reverseDisplayedPages) {
- if (page < this.pdf.currentPage() && this.displayedAnnotations.get(page)) {
+ if (page < this.pdf.currentPage() && this.displayedAnnotations().get(page)) {
break;
}
--idx;