From 9bbcb9319c4088e97eca002c2c33561f9964fba0 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Mon, 4 Jan 2021 17:08:52 +0100 Subject: [PATCH] fixes #128 --- .../document-list.component.html | 54 ++++++++++++++++--- .../document-list/document-list.component.ts | 10 +++- .../correspondent-list.component.html | 8 +-- .../document-type-list.component.html | 6 +-- .../generic-list/generic-list.component.ts | 17 +----- .../manage/tag-list/tag-list.component.html | 6 +-- .../src/app/directives/sortable.directive.ts | 21 ++++---- 7 files changed, 77 insertions(+), 45 deletions(-) diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html index 3bdf8a8ce..bb687632d 100644 --- a/src-ui/src/app/components/document-list/document-list.component.html +++ b/src-ui/src/app/components/document-list/document-list.component.html @@ -99,12 +99,54 @@ - - - - - - + + + + + + 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 1f29cb901..84daf7e22 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 @@ -1,8 +1,9 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { AfterViewInit, Component, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { PaperlessDocument } from 'src/app/data/paperless-document'; import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'; +import { SortableDirective, SortEvent } from 'src/app/directives/sortable.directive'; import { DocumentListViewService } from 'src/app/services/document-list-view.service'; import { DOCUMENT_SORT_FIELDS } from 'src/app/services/rest/document.service'; import { SavedViewService } from 'src/app/services/rest/saved-view.service'; @@ -28,6 +29,8 @@ export class DocumentListComponent implements OnInit { @ViewChild("filterEditor") private filterEditor: FilterEditorComponent + @ViewChildren(SortableDirective) headers: QueryList; + displayMode = 'smallCards' // largeCards, smallCards, details get isFiltered() { @@ -42,6 +45,10 @@ export class DocumentListComponent implements OnInit { return DOCUMENT_SORT_FIELDS } + onSort(event: SortEvent) { + this.list.setSort(event.column, event.reverse) + } + get isBulkEditing(): boolean { return this.list.selected.size > 0 } @@ -73,7 +80,6 @@ export class DocumentListComponent implements OnInit { }) } - loadViewConfig(view: PaperlessSavedView) { this.list.load(view) this.list.reload() diff --git a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.html b/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.html index 4abc72037..c04a0bcfe 100644 --- a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.html +++ b/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.html @@ -9,10 +9,10 @@
ASNCorrespondentTitleDocument typeCreatedAdded + ASN + + Correspondent + + Title + + Document type + + Created + + Added +
- - - - + + + + diff --git a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.html b/src-ui/src/app/components/manage/document-type-list/document-type-list.component.html index e18d3ec00..0282ae863 100644 --- a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.html +++ b/src-ui/src/app/components/manage/document-type-list/document-type-list.component.html @@ -10,9 +10,9 @@
NameMatchingDocument countLast correspondenceNameMatchingDocument countLast correspondence Actions
- - - + + + diff --git a/src-ui/src/app/components/manage/generic-list/generic-list.component.ts b/src-ui/src/app/components/manage/generic-list/generic-list.component.ts index 7f4e4dbd2..e1d5226f3 100644 --- a/src-ui/src/app/components/manage/generic-list/generic-list.component.ts +++ b/src-ui/src/app/components/manage/generic-list/generic-list.component.ts @@ -39,21 +39,8 @@ export abstract class GenericListComponent implements On } onSort(event: SortEvent) { - - if (event.sorted) { - this.sortField = event.column - this.sortReverse = event.reverse - } else { - this.sortField = null - this.sortReverse = false - } - - this.headers.forEach(header => { - if (header.sortable !== this.sortField) { - header.sorted = false - } - }); - + this.sortField = event.column + this.sortReverse = event.reverse this.reloadData() } diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.html b/src-ui/src/app/components/manage/tag-list/tag-list.component.html index 43126f7b2..4af22b3cd 100644 --- a/src-ui/src/app/components/manage/tag-list/tag-list.component.html +++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.html @@ -10,10 +10,10 @@
NameMatchingDocument countNameMatchingDocument count Actions
- + - - + + diff --git a/src-ui/src/app/directives/sortable.directive.ts b/src-ui/src/app/directives/sortable.directive.ts index 18892a846..22750273d 100644 --- a/src-ui/src/app/directives/sortable.directive.ts +++ b/src-ui/src/app/directives/sortable.directive.ts @@ -2,15 +2,14 @@ import { Directive, EventEmitter, Input, Output } from '@angular/core'; export interface SortEvent { column: string - sorted: boolean reverse: boolean } @Directive({ selector: 'th[sortable]', host: { - '[class.asc]': 'sorted && !reverse', - '[class.des]': 'sorted && reverse', + '[class.asc]': 'currentSortField == sortable && !currentSortReverse', + '[class.des]': 'currentSortField == sortable && currentSortReverse', '(click)': 'rotate()' } }) @@ -22,22 +21,20 @@ export class SortableDirective { sortable: string = ''; @Input() - sorted: boolean = false + currentSortReverse: boolean = false @Input() - reverse: boolean = false + currentSortField: string @Output() sort = new EventEmitter(); rotate() { - if (!this.sorted) { - this.sorted = true - this.reverse = false - } else if (this.sorted && !this.reverse) { - this.reverse = true + if (this.currentSortField != this.sortable) { + this.sort.emit({column: this.sortable, reverse: false}); + } else if (this.currentSortField == this.sortable && !this.currentSortReverse) { + this.sort.emit({column: this.currentSortField, reverse: true}); } else { - this.sorted = false + this.sort.emit({column: null, reverse: false}); } - this.sort.emit({column: this.sortable, sorted: this.sorted, reverse: this.reverse}); } }
NameName ColorMatchingDocument countMatchingDocument count Actions