mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
refactor constant
This commit is contained in:
parent
d1e10754a5
commit
2d974bc026
@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { cloneFilterRules, FilterRule } from 'src/app/data/filter-rule';
|
||||
import { SavedViewConfig } from 'src/app/data/saved-view-config';
|
||||
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
|
||||
import { DocumentListViewService, SORT_FIELDS } from 'src/app/services/document-list-view.service';
|
||||
import { SavedViewConfigService } from 'src/app/services/saved-view-config.service';
|
||||
import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-view-config-dialog.component';
|
||||
|
||||
@ -26,7 +26,7 @@ export class DocumentListComponent implements OnInit {
|
||||
showFilter = false
|
||||
|
||||
getSortFields() {
|
||||
return DocumentListViewService.SORT_FIELDS
|
||||
return SORT_FIELDS
|
||||
}
|
||||
|
||||
setSort(field: string) {
|
||||
|
@ -5,6 +5,15 @@ import { PaperlessDocument } from '../data/paperless-document';
|
||||
import { SavedViewConfig } from '../data/saved-view-config';
|
||||
import { DocumentService } from './rest/document.service';
|
||||
|
||||
export const SORT_FIELDS = [
|
||||
{field: "correspondent__name", name: "Correspondent"},
|
||||
{field: 'title', name: 'Title'},
|
||||
{field: 'archive_serial_number', name: 'ASN'},
|
||||
{field: 'created', name: 'Created'},
|
||||
{field: 'added', name: 'Added'},
|
||||
{field: 'modified', name: 'Modified'}
|
||||
]
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@ -12,15 +21,6 @@ export class DocumentListViewService {
|
||||
|
||||
static DEFAULT_SORT_FIELD = 'created'
|
||||
|
||||
static SORT_FIELDS = [
|
||||
{field: "correspondent__name", name: "Correspondent"},
|
||||
{field: 'title', name: 'Title'},
|
||||
{field: 'archive_serial_number', name: 'ASN'},
|
||||
{field: 'created', name: 'Created'},
|
||||
{field: 'added', name: 'Added'},
|
||||
{field: 'modified', name: 'Modified'}
|
||||
]
|
||||
|
||||
documents: PaperlessDocument[] = []
|
||||
currentPage = 1
|
||||
collectionSize: number
|
||||
@ -63,14 +63,13 @@ export class DocumentListViewService {
|
||||
}
|
||||
|
||||
getOrderingQueryParam(sortField: string, sortDirection: string) {
|
||||
if (DocumentListViewService.SORT_FIELDS.find(f => f.field == sortField)) {
|
||||
if (SORT_FIELDS.find(f => f.field == sortField)) {
|
||||
return (sortDirection == 'des' ? '-' : '') + sortField
|
||||
} else {
|
||||
return DocumentListViewService.DEFAULT_SORT_FIELD
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: refactor
|
||||
setFilterRules(filterRules: FilterRule[]) {
|
||||
this.currentFilterRules = cloneFilterRules(filterRules)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user