diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html index 6f2742a8d..c2ea9980b 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html @@ -1,11 +1,11 @@ -
+
- +
- +
@@ -17,11 +17,11 @@
- {{(document.correspondent$ | async)?.name}} + {{(document.correspondent$ | async)?.name}} {{(document.correspondent$ | async)?.name}}: {{document.title | documentTitle}} - +
#{{document.archive_serial_number}}
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts index e3bd4b7f7..f8bb9f518 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts @@ -15,16 +15,11 @@ export class DocumentCardLargeComponent implements OnInit { @Input() selected = false - setSelected(value: boolean) { - this.selected = value - this.selectedChange.emit(value) - } - @Output() - selectedChange = new EventEmitter() + toggleSelected = new EventEmitter() get selectable() { - return this.selectedChange.observers.length > 0 + return this.toggleSelected.observers.length > 0 } @Input() diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html index c951bf281..4f11b2a98 100644 --- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html +++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html @@ -1,18 +1,18 @@
-
+
- +
- +
- +
+ {{moreTags}} @@ -23,7 +23,7 @@
- +
@@ -135,10 +135,10 @@ i18n>Added - +
- +
@@ -147,7 +147,7 @@ -
{{(d.correspondent$ | async)?.name}} + {{(d.correspondent$ | async)?.name}} @@ -156,7 +156,7 @@ - {{(d.document_type$ | async)?.name}} + {{(d.document_type$ | async)?.name}} @@ -170,5 +170,5 @@
- +
diff --git a/src-ui/src/app/components/document-list/document-list.component.scss b/src-ui/src/app/components/document-list/document-list.component.scss index f90a94be4..28f765e29 100644 --- a/src-ui/src/app/components/document-list/document-list.component.scss +++ b/src-ui/src/app/components/document-list/document-list.component.scss @@ -1,5 +1,9 @@ @import "/src/theme"; +tr { + user-select: none; +} + .table-row-selected { background-color: $primaryFaded; } 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.ts index fda99eb8d..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 @@ -160,6 +160,11 @@ export class DocumentListComponent implements OnInit { this.filterRulesModified = modified } + toggleSelected(document: PaperlessDocument, event: MouseEvent): void { + if (!event.shiftKey) this.list.toggleSelected(document) + else this.list.selectRangeTo(document) + } + clickTag(tagID: number) { this.list.selectNone() setTimeout(() => { 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 1bbcca38e..4eb0c276c 100644 --- a/src-ui/src/app/services/document-list-view.service.ts +++ b/src-ui/src/app/services/document-list-view.service.ts @@ -27,6 +27,8 @@ export class DocumentListViewService { currentPage = 1 currentPageSize: number = this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE) collectionSize: number + rangeSelectionAnchorIndex: number + lastRangeSelectionToIndex: number /** * This is the current config for the document list. The service will always remember the last settings used for the document list. @@ -108,6 +110,7 @@ export class DocumentListViewService { if (onFinish) { onFinish() } + this.rangeSelectionAnchorIndex = this.lastRangeSelectionToIndex = null this.isReloading = false }, error => { @@ -218,6 +221,7 @@ export class DocumentListViewService { selectNone() { this.selected.clear() + this.rangeSelectionAnchorIndex = this.lastRangeSelectionToIndex = null } reduceSelectionToFilter() { @@ -249,14 +253,39 @@ export class DocumentListViewService { return this.selected.has(d.id) } - setSelected(d: PaperlessDocument, value: boolean) { - if (value) { - this.selected.add(d.id) - } else if (!value) { - this.selected.delete(d.id) + toggleSelected(d: PaperlessDocument): void { + 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 + } + + selectRangeTo(d: PaperlessDocument) { + if (this.rangeSelectionAnchorIndex !== null) { + const documentToIndex = this.documentIndexInCurrentView(d.id) + const fromIndex = Math.min(this.rangeSelectionAnchorIndex, documentToIndex) + const toIndex = Math.max(this.rangeSelectionAnchorIndex, documentToIndex) + + if (this.lastRangeSelectionToIndex !== null) { + // revert the old selection + this.documents.slice(Math.min(this.rangeSelectionAnchorIndex, this.lastRangeSelectionToIndex), Math.max(this.rangeSelectionAnchorIndex, this.lastRangeSelectionToIndex) + 1).forEach(d => { + this.selected.delete(d.id) + }) + } + + this.documents.slice(fromIndex, toIndex + 1).forEach(d => { + this.selected.add(d.id) + }) + this.lastRangeSelectionToIndex = documentToIndex + } else { // e.g. shift key but was first click + this.toggleSelected(d) } } + documentIndexInCurrentView(documentID: number): number { + return this.documents.map(d => d.id).indexOf(documentID) + } + constructor(private documentService: DocumentService, private settings: SettingsService, private router: Router) { let documentListViewConfigJson = sessionStorage.getItem(DOCUMENT_LIST_SERVICE.CURRENT_VIEW_CONFIG) if (documentListViewConfigJson) {