From e4aa8fe68ca9e63490a8951e245c6ff71b03b132 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 14 Sep 2026 20:52:47 -0700 Subject: [PATCH] The hard part, wiring into the doc list (and bulk editor) --- .../bulk-editor/bulk-editor.component.ts | 1 + .../services/document-list-view.service.ts | 45 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 02221ea263..8644eb617f 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -360,6 +360,7 @@ export class BulkEditorComponent return { all: true, filters: queryParamsFromFilterRules(this.list.filterRules), + excluded_documents: Array.from(this.list.excluded), } } diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts index de1db2be63..ab66e8d0e6 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -85,6 +85,11 @@ export interface ListViewState { */ allSelected?: boolean + /** + * Document IDs excluded from the full filtered result set. + */ + excluded?: Set + /** * The page size of the list view. */ @@ -215,6 +220,7 @@ export class DocumentListViewService { filterRules: [], selected: new Set(), allSelected: false, + excluded: new Set(), } } @@ -224,7 +230,9 @@ export class DocumentListViewService { } this.selected.clear() - this.documents?.forEach((doc) => this.selected.add(doc.id)) + this.documents + ?.filter((doc) => !this.excluded.has(doc.id)) + .forEach((doc) => this.selected.add(doc.id)) if (!this.collectionSize) { this.selectNone() @@ -491,14 +499,20 @@ export class DocumentListViewService { return this.activeListViewState.allSelected ?? false } + get excluded(): Set { + this.trackState() + return (this.activeListViewState.excluded ??= new Set()) + } + get selectedCount(): number { - return this.allSelected - ? (this.collectionSize ?? this.selected.size) - : this.selected.size + if (!this.allSelected || this.collectionSize == null) { + return this.selected.size + } + return Math.max(0, this.collectionSize - this.excluded.size) } get hasSelection(): boolean { - return this.allSelected || this.selected.size > 0 + return this.selectedCount > 0 } setSort(field: string, reverse: boolean) { @@ -663,12 +677,14 @@ export class DocumentListViewService { selectNone() { this.activeListViewState.allSelected = false this.selected.clear() + this.excluded.clear() this.rangeSelectionAnchorIndex = this.lastRangeSelectionToIndex = null this.markChanged() } reduceSelectionToFilter() { if (this.allSelected) { + this.excluded.clear() return } @@ -688,6 +704,7 @@ export class DocumentListViewService { selectAll() { this.activeListViewState.allSelected = true + this.excluded.clear() this.syncSelectedToCurrentPage() this.markChanged() } @@ -695,6 +712,7 @@ export class DocumentListViewService { selectPage() { this.activeListViewState.allSelected = false this.selected.clear() + this.excluded.clear() this.documents.forEach((doc) => { this.selected.add(doc.id) }) @@ -702,15 +720,23 @@ export class DocumentListViewService { } isSelected(d: Document) { - return this.allSelected || this.selected.has(d.id) + return this.allSelected ? !this.excluded.has(d.id) : this.selected.has(d.id) } toggleSelected(d: Document): void { if (this.allSelected) { - this.activeListViewState.allSelected = false + if (this.excluded.has(d.id)) { + this.excluded.delete(d.id) + this.selected.add(d.id) + } else { + this.excluded.add(d.id) + this.selected.delete(d.id) + } + } else if (this.selected.has(d.id)) { + this.selected.delete(d.id) + } else { + this.selected.add(d.id) } - if (this.selected.has(d.id)) this.selected.delete(d.id) - else this.selected.add(d.id) this.rangeSelectionAnchorIndex = this.documentIndexInCurrentView(d.id) this.lastRangeSelectionToIndex = null this.markChanged() @@ -719,6 +745,7 @@ export class DocumentListViewService { selectRangeTo(d: Document) { if (this.allSelected) { this.activeListViewState.allSelected = false + this.excluded.clear() } if (this.rangeSelectionAnchorIndex !== null) {