mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	refactor constant
This commit is contained in:
		| @@ -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,21 +5,21 @@ import { PaperlessDocument } from '../data/paperless-document'; | ||||
| import { SavedViewConfig } from '../data/saved-view-config'; | ||||
| import { DocumentService } from './rest/document.service'; | ||||
|  | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
| }) | ||||
| export class DocumentListViewService { | ||||
|  | ||||
|   static DEFAULT_SORT_FIELD = 'created' | ||||
|  | ||||
|   static SORT_FIELDS = [ | ||||
| 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' | ||||
| }) | ||||
| export class DocumentListViewService { | ||||
|  | ||||
|   static DEFAULT_SORT_FIELD = 'created' | ||||
|  | ||||
|   documents: PaperlessDocument[] = [] | ||||
|   currentPage = 1 | ||||
| @@ -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) | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler