mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
better sorting directive
This commit is contained in:
@@ -26,7 +26,7 @@ export abstract class GenericListComponent<T extends ObjectWithId> implements On
|
||||
public collectionSize = 0
|
||||
|
||||
public sortField: string
|
||||
public sortDirection: string
|
||||
public sortReverse: boolean
|
||||
|
||||
getMatching(o: MatchingModel) {
|
||||
if (o.matching_algorithm == MATCH_AUTO) {
|
||||
@@ -40,17 +40,17 @@ export abstract class GenericListComponent<T extends ObjectWithId> implements On
|
||||
|
||||
onSort(event: SortEvent) {
|
||||
|
||||
if (event.direction && event.direction.length > 0) {
|
||||
if (event.sorted) {
|
||||
this.sortField = event.column
|
||||
this.sortDirection = event.direction
|
||||
this.sortReverse = event.reverse
|
||||
} else {
|
||||
this.sortField = null
|
||||
this.sortDirection = null
|
||||
this.sortReverse = false
|
||||
}
|
||||
|
||||
this.headers.forEach(header => {
|
||||
if (header.sortable !== this.sortField) {
|
||||
header.direction = '';
|
||||
header.sorted = false
|
||||
}
|
||||
});
|
||||
|
||||
@@ -62,8 +62,7 @@ export abstract class GenericListComponent<T extends ObjectWithId> implements On
|
||||
}
|
||||
|
||||
reloadData() {
|
||||
// TODO: this is a hack
|
||||
this.service.list(this.page, null, this.sortField, this.sortDirection == 'des').subscribe(c => {
|
||||
this.service.list(this.page, null, this.sortField, this.sortReverse).subscribe(c => {
|
||||
this.data = c.results
|
||||
this.collectionSize = c.count
|
||||
});
|
||||
|
Reference in New Issue
Block a user