mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-14 02:36:10 -05:00
Enhancement: custom field sorting (#8494)
This commit is contained in:
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'
|
||||
import { Observable } from 'rxjs'
|
||||
import { map, tap } from 'rxjs/operators'
|
||||
import { AuditLogEntry } from 'src/app/data/auditlog-entry'
|
||||
import { CustomField } from 'src/app/data/custom-field'
|
||||
import {
|
||||
DOCUMENT_SORT_FIELDS,
|
||||
DOCUMENT_SORT_FIELDS_FULLTEXT,
|
||||
@@ -22,6 +23,7 @@ import {
|
||||
import { SettingsService } from '../settings.service'
|
||||
import { AbstractPaperlessService } from './abstract-paperless-service'
|
||||
import { CorrespondentService } from './correspondent.service'
|
||||
import { CustomFieldsService } from './custom-fields.service'
|
||||
import { DocumentTypeService } from './document-type.service'
|
||||
import { StoragePathService } from './storage-path.service'
|
||||
import { TagService } from './tag.service'
|
||||
@@ -55,6 +57,8 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
||||
return this._sortFieldsFullText
|
||||
}
|
||||
|
||||
private customFields: CustomField[] = []
|
||||
|
||||
constructor(
|
||||
http: HttpClient,
|
||||
private correspondentService: CorrespondentService,
|
||||
@@ -62,14 +66,40 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
||||
private tagService: TagService,
|
||||
private storagePathService: StoragePathService,
|
||||
private permissionsService: PermissionsService,
|
||||
private settingsService: SettingsService
|
||||
private settingsService: SettingsService,
|
||||
private customFieldService: CustomFieldsService
|
||||
) {
|
||||
super(http, 'documents')
|
||||
if (
|
||||
this.permissionsService.currentUserCan(
|
||||
PermissionAction.View,
|
||||
PermissionType.CustomField
|
||||
)
|
||||
) {
|
||||
this.customFieldService.listAll().subscribe((fields) => {
|
||||
this.customFields = fields.results
|
||||
this.setupSortFields()
|
||||
})
|
||||
}
|
||||
|
||||
this.setupSortFields()
|
||||
}
|
||||
|
||||
private setupSortFields() {
|
||||
this._sortFields = [...DOCUMENT_SORT_FIELDS]
|
||||
if (
|
||||
this.permissionsService.currentUserCan(
|
||||
PermissionAction.View,
|
||||
PermissionType.CustomField
|
||||
)
|
||||
) {
|
||||
this.customFields.forEach((field) => {
|
||||
this._sortFields.push({
|
||||
field: `custom_field_${field.id}`,
|
||||
name: field.name,
|
||||
})
|
||||
})
|
||||
}
|
||||
let excludes = []
|
||||
if (
|
||||
!this.permissionsService.currentUserCan(
|
||||
|
Reference in New Issue
Block a user