From eabd11546ad9dc180ab35a02c277297d6449f42a Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 11 Mar 2026 23:58:57 -0700 Subject: [PATCH] Only fetch all IDs on demand --- .../management-list.component.ts | 39 +++++++++++++++++-- src-ui/src/app/data/results.ts | 2 +- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts index 3738f491c..62bf0fe1f 100644 --- a/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts +++ b/src-ui/src/app/components/manage/document-attributes/management-list/management-list.component.ts @@ -13,6 +13,7 @@ import { debounceTime, delay, distinctUntilChanged, + map, takeUntil, tap, } from 'rxjs/operators' @@ -91,6 +92,7 @@ export abstract class ManagementListComponent public data: T[] = [] private unfilteredData: T[] = [] private allIDs: number[] = [] + private currentExtraParams: { [key: string]: any } = null public page = 1 @@ -150,7 +152,7 @@ export abstract class ManagementListComponent } protected getCollectionSize(results: Results): number { - return results.all?.length ?? results.count + return results.count } protected getDisplayCollectionSize(results: Results): number { @@ -171,6 +173,7 @@ export abstract class ManagementListComponent reloadData(extraParams: { [key: string]: any } = null) { this.loading = true + this.currentExtraParams = extraParams this.clearSelection() this.service .listFiltered( @@ -189,7 +192,7 @@ export abstract class ManagementListComponent this.data = this.filterData(c.results) this.collectionSize = this.getCollectionSize(c) this.displayCollectionSize = this.getDisplayCollectionSize(c) - this.allIDs = c.all + this.allIDs = [] }), delay(100) ) @@ -365,8 +368,36 @@ export abstract class ManagementListComponent this.clearSelection() return } - this.selectedObjects = new Set(this.allIDs) - this.togggleAll = this.areAllPageItemsSelected() + + if (this.allIDs.length > 0) { + this.selectedObjects = new Set(this.allIDs) + this.togggleAll = this.areAllPageItemsSelected() + return + } + + this.service + .listFiltered( + 1, + 100000, + this.sortField, + this.sortReverse, + this._nameFilter, + true, + this.currentExtraParams + ) + .pipe( + takeUntil(this.unsubscribeNotifier), + map((results) => + Array.from( + new Set(this.getSelectableIDs(this.filterData(results.results))) + ) + ) + ) + .subscribe((ids) => { + this.allIDs = ids + this.selectedObjects = new Set(ids) + this.togggleAll = this.areAllPageItemsSelected() + }) } toggleSelected(object) { diff --git a/src-ui/src/app/data/results.ts b/src-ui/src/app/data/results.ts index f985ed975..a37143669 100644 --- a/src-ui/src/app/data/results.ts +++ b/src-ui/src/app/data/results.ts @@ -5,7 +5,7 @@ export interface Results { results: T[] - all: number[] + all?: number[] } export interface SelectionDataItem {