A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Refactor selection functions to two separate ones for clarity
Michael Shamoon48220ceeb8cd
diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.tsindex a3ec2d664..509c0a735 100644--- a/src-ui/src/app/components/document-list/document-list.component.ts+++ b/src-ui/src/app/components/document-list/document-list.component.ts@@ -161,7 +161,8 @@ export class DocumentListComponent implements OnInit {}toggleSelected(document: PaperlessDocument, event: MouseEvent): void {- this.list.toggleSelected(document, event.shiftKey)+ if (!event.shiftKey) this.list.toggleSelected(document)+ else this.list.selectRangeTo(document)}clickTag(tagID: number) {diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.tsindex bcfb5468f..d2b9d75c2 100644--- a/src-ui/src/app/services/document-list-view.service.ts+++ b/src-ui/src/app/services/document-list-view.service.ts@@ -253,19 +253,21 @@ export class DocumentListViewService {return this.selected.has(d.id)}- toggleSelected(d: PaperlessDocument, includeRange: boolean): void {- if (!includeRange) {- // regular i.e. no shift key toggle- if (this.selected.has(d.id)) this.selected.delete(d.id)- else this.selected.add(d.id)- } else if (includeRange && this.lastSelectedDocumentIndex !== null) {+ toggleSelected(d: PaperlessDocument): void {+ if (this.selected.has(d.id)) this.selected.delete(d.id)+ else this.selected.add(d.id)+ this.lastSelectedDocumentIndex = this.documentIndexInCurrentView(d.id)+ }++ selectRangeTo(d: PaperlessDocument) {+ if (this.lastSelectedDocumentIndex !== null) {const documentToIndex = this.documentIndexInCurrentView(d.id)const fromIndex = Math.min(this.lastSelectedDocumentIndex, documentToIndex)const toIndex = Math.max(this.lastSelectedDocumentIndex, documentToIndex)if ((this.lastSelectedDocumentToIndex > this.lastSelectedDocumentIndex && documentToIndex < this.lastSelectedDocumentIndex) ||(this.lastSelectedDocumentToIndex < this.lastSelectedDocumentIndex && documentToIndex > this.lastSelectedDocumentIndex)) {- // invert last selected+ // new click is "opposite side" of anchor so we invert the old selectionthis.documents.slice(Math.min(this.lastSelectedDocumentIndex, this.lastSelectedDocumentToIndex), Math.max(this.lastSelectedDocumentIndex, this.lastSelectedDocumentToIndex) + 1).forEach(d => {this.selected.delete(d.id)})@@ -275,9 +277,7 @@ export class DocumentListViewService {this.selected.add(d.id)})this.lastSelectedDocumentToIndex = documentToIndex- }-- if (!includeRange || (includeRange && this.lastSelectedDocumentIndex == null)) { // e.g. shift key but first click+ } else { // e.g. shift key but was first clickthis.lastSelectedDocumentIndex = this.documentIndexInCurrentView(d.id)}}