diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index 9167e9318..ae30dd271 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -424,10 +424,6 @@
src/app/components/common/permissions-select/permissions-select.component.html
22
-
- src/app/components/document-history/document-history.component.html
- 35
-
Read the documentation about this setting
@@ -451,7 +447,7 @@
src/app/components/document-detail/document-detail.component.html
- 333
+ 322
@@ -510,7 +506,7 @@
src/app/components/document-detail/document-detail.component.html
- 325
+ 314
src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.html
@@ -640,7 +636,7 @@
src/app/components/document-detail/document-detail.component.html
- 342
+ 331
src/app/components/document-list/document-list.component.html
@@ -950,12 +946,12 @@
206
- src/app/data/saved-view.ts
- 56
+ src/app/data/document.ts
+ 62
- src/app/services/rest/document.service.ts
- 33
+ src/app/data/document.ts
+ 95
@@ -985,7 +981,7 @@
src/app/components/document-detail/document-detail.component.html
- 301
+ 290
src/app/components/document-list/bulk-editor/bulk-editor.component.html
@@ -1557,21 +1553,21 @@
Use system language
src/app/components/admin/settings/settings.component.ts
- 61
+ 62
Use date format of display language
src/app/components/admin/settings/settings.component.ts
- 64
+ 65
Error retrieving users
src/app/components/admin/settings/settings.component.ts
- 187
+ 188
src/app/components/admin/users-groups/users-groups.component.ts
@@ -1582,7 +1578,7 @@
Error retrieving groups
src/app/components/admin/settings/settings.component.ts
- 206
+ 207
src/app/components/admin/users-groups/users-groups.component.ts
@@ -1593,35 +1589,35 @@
Saved view "" deleted.
src/app/components/admin/settings/settings.component.ts
- 420
+ 421
Settings were saved successfully.
src/app/components/admin/settings/settings.component.ts
- 545
+ 546
Settings were saved successfully. Reload is required to apply some changes.
src/app/components/admin/settings/settings.component.ts
- 549
+ 550
Reload now
src/app/components/admin/settings/settings.component.ts
- 550
+ 551
An error occurred while saving settings.
src/app/components/admin/settings/settings.component.ts
- 560
+ 561
src/app/components/app-frame/app-frame.component.ts
@@ -1632,7 +1628,7 @@
Error while storing settings on server.
src/app/components/admin/settings/settings.component.ts
- 594
+ 595
@@ -1791,12 +1787,12 @@
76
- src/app/data/saved-view.ts
- 32
+ src/app/data/document.ts
+ 38
- src/app/services/rest/document.service.ts
- 30
+ src/app/data/document.ts
+ 92
@@ -2146,7 +2142,7 @@
src/app/components/document-detail/document-detail.component.ts
- 769
+ 768
src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -2189,15 +2185,15 @@
src/app/components/document-detail/document-detail.component.ts
- 771
+ 770
src/app/components/document-detail/document-detail.component.ts
- 1064
+ 1052
src/app/components/document-detail/document-detail.component.ts
- 1102
+ 1090
src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -2365,7 +2361,7 @@
src/app/components/document-list/document-list.component.ts
- 127
+ 123
src/app/components/manage/management-list/management-list.component.html
@@ -2451,8 +2447,8 @@
33
- src/app/data/saved-view.ts
- 40
+ src/app/data/document.ts
+ 46
@@ -4228,7 +4224,7 @@
src/app/components/document-list/document-card-small/document-card-small.component.ts
- 83
+ 86
@@ -4379,7 +4375,7 @@
Inherited from group
src/app/components/common/permissions-select/permissions-select.component.ts
- 63
+ 61
@@ -4860,56 +4856,6 @@
39
-
- Title
-
- src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html
- 17
-
-
- src/app/components/document-detail/document-detail.component.html
- 104
-
-
- src/app/components/document-list/document-list.component.html
- 160
-
-
- src/app/components/document-list/filter-editor/filter-editor.component.ts
- 115
-
-
- src/app/services/rest/document.service.ts
- 28
-
-
-
- Correspondent
-
- src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html
- 22
-
-
- src/app/components/document-detail/document-detail.component.html
- 108
-
-
- src/app/components/document-list/bulk-editor/bulk-editor.component.html
- 36
-
-
- src/app/components/document-list/document-list.component.html
- 151
-
-
- src/app/components/document-list/filter-editor/filter-editor.component.html
- 44
-
-
- src/app/services/rest/document.service.ts
- 27
-
-
View Preview
@@ -5177,7 +5123,7 @@
src/app/components/document-detail/document-detail.component.ts
- 1120
+ 1108
src/app/guards/dirty-saved-view.guard.ts
@@ -5213,12 +5159,12 @@
115
- src/app/data/saved-view.ts
- 28
+ src/app/data/document.ts
+ 34
- src/app/services/rest/document.service.ts
- 27
+ src/app/data/document.ts
+ 90
@@ -5254,12 +5200,12 @@
44
- src/app/data/saved-view.ts
- 44
+ src/app/data/document.ts
+ 50
- src/app/services/rest/document.service.ts
- 26
+ src/app/data/document.ts
+ 89
@@ -5281,12 +5227,12 @@
54
- src/app/data/saved-view.ts
- 48
+ src/app/data/document.ts
+ 54
- src/app/services/rest/document.service.ts
- 29
+ src/app/data/document.ts
+ 91
@@ -5308,8 +5254,8 @@
64
- src/app/data/saved-view.ts
- 52
+ src/app/data/document.ts
+ 58
@@ -5428,110 +5374,103 @@
279,282
-
- History
-
- src/app/components/document-detail/document-detail.component.html
- 290
-
-
Save & next
src/app/components/document-detail/document-detail.component.html
- 327
+ 316
Save & close
src/app/components/document-detail/document-detail.component.html
- 330
+ 319
Enter Password
src/app/components/document-detail/document-detail.component.html
- 381
+ 370
An error occurred loading content:
src/app/components/document-detail/document-detail.component.ts
- 328,330
+ 327,329
Document changes detected
src/app/components/document-detail/document-detail.component.ts
- 351
+ 350
The version of this document in your browser session appears older than the existing version.
src/app/components/document-detail/document-detail.component.ts
- 352
+ 351
Saving the document here may overwrite other changes that were made. To restore the existing version, discard your changes or close the document.
src/app/components/document-detail/document-detail.component.ts
- 353
+ 352
Ok
src/app/components/document-detail/document-detail.component.ts
- 355
+ 354
Error retrieving metadata
src/app/components/document-detail/document-detail.component.ts
- 495
+ 494
Error retrieving suggestions.
src/app/components/document-detail/document-detail.component.ts
- 520
+ 519
Document saved successfully.
src/app/components/document-detail/document-detail.component.ts
- 641
+ 640
src/app/components/document-detail/document-detail.component.ts
- 652
+ 651
Error saving document
src/app/components/document-detail/document-detail.component.ts
- 656
+ 655
src/app/components/document-detail/document-detail.component.ts
- 697
+ 696
Confirm delete
src/app/components/document-detail/document-detail.component.ts
- 724
+ 723
src/app/components/manage/management-list/management-list.component.ts
@@ -5546,35 +5485,35 @@
Do you really want to delete document ""?
src/app/components/document-detail/document-detail.component.ts
- 725
+ 724
The files for this document will be deleted permanently. This operation cannot be undone.
src/app/components/document-detail/document-detail.component.ts
- 726
+ 725
Delete document
src/app/components/document-detail/document-detail.component.ts
- 728
+ 727
Error deleting document
src/app/components/document-detail/document-detail.component.ts
- 747
+ 746
Redo OCR confirm
src/app/components/document-detail/document-detail.component.ts
- 767
+ 766
src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -5585,63 +5524,63 @@
This operation will permanently redo OCR for this document.
src/app/components/document-detail/document-detail.component.ts
- 768
+ 767
Redo OCR operation will begin in the background. Close and re-open or reload this document after the operation has completed to see new content.
src/app/components/document-detail/document-detail.component.ts
- 779
+ 778
Error executing operation
src/app/components/document-detail/document-detail.component.ts
- 790
+ 789
Page Fit
src/app/components/document-detail/document-detail.component.ts
- 859
+ 858
Split confirm
src/app/components/document-detail/document-detail.component.ts
- 1062
+ 1050
This operation will split the selected document(s) into new documents.
src/app/components/document-detail/document-detail.component.ts
- 1063
+ 1051
Split operation will begin in the background.
src/app/components/document-detail/document-detail.component.ts
- 1078
+ 1066
Error executing split operation
src/app/components/document-detail/document-detail.component.ts
- 1087
+ 1075
Rotate confirm
src/app/components/document-detail/document-detail.component.ts
- 1099
+ 1087
src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -5652,14 +5591,14 @@
This operation will permanently rotate the original version of the current document.
src/app/components/document-detail/document-detail.component.ts
- 1100
+ 1088
This will alter the original copy.
src/app/components/document-detail/document-detail.component.ts
- 1101
+ 1089
src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -5670,21 +5609,14 @@
Rotation will begin in the background. Close and re-open the document after the operation has completed to see the changes.
src/app/components/document-detail/document-detail.component.ts
- 1117
+ 1105
Error executing rotate operation
src/app/components/document-detail/document-detail.component.ts
- 1129
-
-
-
- No entries found.
-
- src/app/components/document-history/document-history.component.html
- 10
+ 1117
@@ -6085,8 +6017,8 @@
94
- src/app/data/saved-view.ts
- 64
+ src/app/data/document.ts
+ 70
src/app/pipes/username.pipe.ts
@@ -6227,12 +6159,12 @@
120
- src/app/data/saved-view.ts
- 68
+ src/app/data/document.ts
+ 74
- src/app/services/rest/document.service.ts
- 26
+ src/app/data/document.ts
+ 88
@@ -6263,12 +6195,12 @@
197
- src/app/data/saved-view.ts
- 60
+ src/app/data/document.ts
+ 66
- src/app/services/rest/document.service.ts
- 34
+ src/app/data/document.ts
+ 96
@@ -6317,16 +6249,12 @@
82
- src/app/data/saved-view.ts
- 36
+ src/app/data/document.ts
+ 42
- src/app/data/saved-view.ts
- 31
-
-
- src/app/services/rest/document.service.ts
- 31
+ src/app/data/document.ts
+ 93
@@ -6340,14 +6268,14 @@
View "" saved successfully.
src/app/components/document-list/document-list.component.ts
- 241
+ 237
View "" created successfully.
src/app/components/document-list/document-list.component.ts
- 282
+ 278
@@ -7238,6 +7166,21 @@
45
+
+ Modified
+
+ src/app/data/document.ts
+ 94
+
+
+
+ Search score
+
+ src/app/data/document.ts
+ 102
+
+ Score is a value returned by the full text search engine and specifies how well a result matches the given query
+
Auto: Learn matching automatically
@@ -7520,97 +7463,6 @@
36
-
- %s year ago
-
- src/app/pipes/custom-date.pipe.ts
- 14
-
-
-
- %s years ago
-
- src/app/pipes/custom-date.pipe.ts
- 15
-
-
-
- %s month ago
-
- src/app/pipes/custom-date.pipe.ts
- 19
-
-
-
- %s months ago
-
- src/app/pipes/custom-date.pipe.ts
- 20
-
-
-
- %s week ago
-
- src/app/pipes/custom-date.pipe.ts
- 24
-
-
-
- %s weeks ago
-
- src/app/pipes/custom-date.pipe.ts
- 25
-
-
-
- %s day ago
-
- src/app/pipes/custom-date.pipe.ts
- 29
-
-
-
- %s days ago
-
- src/app/pipes/custom-date.pipe.ts
- 30
-
-
-
- %s hour ago
-
- src/app/pipes/custom-date.pipe.ts
- 34
-
-
-
- %s hours ago
-
- src/app/pipes/custom-date.pipe.ts
- 35
-
-
-
- %s minute ago
-
- src/app/pipes/custom-date.pipe.ts
- 39
-
-
-
- %s minutes ago
-
- src/app/pipes/custom-date.pipe.ts
- 40
-
-
-
- Just now
-
- src/app/pipes/custom-date.pipe.ts
- 72
-
-
(no title)
@@ -7769,271 +7621,256 @@
135
-
- Modified
-
- src/app/services/rest/document.service.ts
- 32
-
-
-
- Search score
-
- src/app/services/rest/document.service.ts
- 41
-
- Score is a value returned by the full text search engine and specifies how well a result matches the given query
-
English (US)
src/app/services/settings.service.ts
- 49
+ 46
Afrikaans
src/app/services/settings.service.ts
- 55
+ 52
Arabic
src/app/services/settings.service.ts
- 61
+ 58
Belarusian
src/app/services/settings.service.ts
- 67
+ 64
Bulgarian
src/app/services/settings.service.ts
- 73
+ 70
Catalan
src/app/services/settings.service.ts
- 79
+ 76
Czech
src/app/services/settings.service.ts
- 85
+ 82
Danish
src/app/services/settings.service.ts
- 91
+ 88
German
src/app/services/settings.service.ts
- 97
+ 94
Greek
src/app/services/settings.service.ts
- 103
+ 100
English (GB)
src/app/services/settings.service.ts
- 109
+ 106
Spanish
src/app/services/settings.service.ts
- 115
+ 112
Finnish
src/app/services/settings.service.ts
- 121
+ 118
French
src/app/services/settings.service.ts
- 127
+ 124
Hungarian
src/app/services/settings.service.ts
- 133
+ 130
Italian
src/app/services/settings.service.ts
- 139
+ 136
Japanese
src/app/services/settings.service.ts
- 145
+ 142
Luxembourgish
src/app/services/settings.service.ts
- 151
+ 148
Dutch
src/app/services/settings.service.ts
- 157
+ 154
Norwegian
src/app/services/settings.service.ts
- 163
+ 160
Polish
src/app/services/settings.service.ts
- 169
+ 166
Portuguese (Brazil)
src/app/services/settings.service.ts
- 175
+ 172
Portuguese
src/app/services/settings.service.ts
- 181
+ 178
Romanian
src/app/services/settings.service.ts
- 187
+ 184
Russian
src/app/services/settings.service.ts
- 193
+ 190
Slovak
src/app/services/settings.service.ts
- 199
+ 196
Slovenian
src/app/services/settings.service.ts
- 205
+ 202
Serbian
src/app/services/settings.service.ts
- 211
+ 208
Swedish
src/app/services/settings.service.ts
- 217
+ 214
Turkish
src/app/services/settings.service.ts
- 223
+ 220
Ukrainian
src/app/services/settings.service.ts
- 229
+ 226
Chinese Simplified
src/app/services/settings.service.ts
- 235
+ 232
ISO 8601
src/app/services/settings.service.ts
- 243
+ 240
Successfully completed one-time migratration of settings to the database!
src/app/services/settings.service.ts
- 513
+ 510
Unable to migrate settings to the database, please try saving manually.
src/app/services/settings.service.ts
- 514
+ 511
You can restart the tour from the settings page.
src/app/services/settings.service.ts
- 584
+ 581
diff --git a/src-ui/src/app/components/document-list/document-list.component.spec.ts b/src-ui/src/app/components/document-list/document-list.component.spec.ts
index ffe7def69..e8d3a1e6e 100644
--- a/src-ui/src/app/components/document-list/document-list.component.spec.ts
+++ b/src-ui/src/app/components/document-list/document-list.component.spec.ts
@@ -53,11 +53,7 @@ import {
DisplayMode,
Document,
} from 'src/app/data/document'
-import {
- DOCUMENT_SORT_FIELDS,
- DOCUMENT_SORT_FIELDS_FULLTEXT,
- DocumentService,
-} from 'src/app/services/rest/document.service'
+import { DocumentService } from 'src/app/services/rest/document.service'
import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component'
import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
import { SaveViewConfigDialogComponent } from './save-view-config-dialog/save-view-config-dialog.component'
@@ -193,7 +189,7 @@ describe('DocumentListComponent', () => {
},
]
fixture.detectChanges()
- expect(component.getSortFields()).toEqual(DOCUMENT_SORT_FIELDS)
+ expect(component.getSortFields()).toEqual(documentListService.sortFields)
documentListService.filterRules = [
{
@@ -202,7 +198,9 @@ describe('DocumentListComponent', () => {
},
]
fixture.detectChanges()
- expect(component.getSortFields()).toEqual(DOCUMENT_SORT_FIELDS_FULLTEXT)
+ expect(component.getSortFields()).toEqual(
+ documentListService.sortFieldsFullText
+ )
})
it('should determine if filtered, support reset', () => {
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 f898ba7b1..032fc79e7 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
@@ -25,10 +25,6 @@ import {
import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
-import {
- DOCUMENT_SORT_FIELDS,
- DOCUMENT_SORT_FIELDS_FULLTEXT,
-} from 'src/app/services/rest/document.service'
import { PermissionsService } from 'src/app/services/permissions.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SettingsService } from 'src/app/services/settings.service'
@@ -131,8 +127,8 @@ export class DocumentListComponent
getSortFields() {
return isFullTextFilterRule(this.list.filterRules)
- ? DOCUMENT_SORT_FIELDS_FULLTEXT
- : DOCUMENT_SORT_FIELDS
+ ? this.list.sortFieldsFullText
+ : this.list.sortFields
}
set listSortReverse(reverse: boolean) {
diff --git a/src-ui/src/app/data/document.ts b/src-ui/src/app/data/document.ts
index 7d2c550ae..7b7c6f786 100644
--- a/src-ui/src/app/data/document.ts
+++ b/src-ui/src/app/data/document.ts
@@ -84,6 +84,25 @@ export const DEFAULT_DASHBOARD_DISPLAY_FIELDS = [
DisplayField.CORRESPONDENT,
]
+export const DOCUMENT_SORT_FIELDS = [
+ { field: 'archive_serial_number', name: $localize`ASN` },
+ { field: 'correspondent__name', name: $localize`Correspondent` },
+ { field: 'title', name: $localize`Title` },
+ { field: 'document_type__name', name: $localize`Document type` },
+ { field: 'created', name: $localize`Created` },
+ { field: 'added', name: $localize`Added` },
+ { field: 'modified', name: $localize`Modified` },
+ { field: 'num_notes', name: $localize`Notes` },
+ { field: 'owner', name: $localize`Owner` },
+]
+
+export const DOCUMENT_SORT_FIELDS_FULLTEXT = [
+ {
+ field: 'score',
+ name: $localize`:Score is a value returned by the full text search engine and specifies how well a result matches the given query:Search score`,
+ },
+]
+
export interface SearchHit {
score?: number
rank?: number
diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts
index eba678cad..2ed0d610a 100644
--- a/src-ui/src/app/services/document-list-view.service.ts
+++ b/src-ui/src/app/services/document-list-view.service.ts
@@ -17,11 +17,7 @@ import { SavedView } from '../data/saved-view'
import { SETTINGS_KEYS } from '../data/ui-settings'
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'
import { paramsFromViewState, paramsToViewState } from '../utils/query-params'
-import {
- DocumentService,
- DOCUMENT_SORT_FIELDS,
- SelectionData,
-} from './rest/document.service'
+import { DocumentService, SelectionData } from './rest/document.service'
import { SettingsService } from './settings.service'
/**
@@ -302,9 +298,8 @@ export class DocumentListViewService {
errorMessage = Object.keys(error.error)
.map((fieldName) => {
const fieldError: Array = error.error[fieldName]
- return `${DOCUMENT_SORT_FIELDS.find(
- (f) => f.field == fieldName
- )?.name}: ${fieldError[0]}`
+ return `${this.sortFields.find((f) => f.field == fieldName)
+ ?.name}: ${fieldError[0]}`
})
.join(', ')
} else {
@@ -333,6 +328,14 @@ export class DocumentListViewService {
return this.activeListViewState.filterRules
}
+ get sortFields(): any[] {
+ return this.documentService.sortFields
+ }
+
+ get sortFieldsFullText(): any[] {
+ return this.documentService.sortFieldsFullText
+ }
+
set sortField(field: string) {
this.activeListViewState.sortField = field
this.reload()
diff --git a/src-ui/src/app/services/rest/document.service.spec.ts b/src-ui/src/app/services/rest/document.service.spec.ts
index c379ba010..b2bcfbe30 100644
--- a/src-ui/src/app/services/rest/document.service.spec.ts
+++ b/src-ui/src/app/services/rest/document.service.spec.ts
@@ -9,11 +9,17 @@ import { DocumentService } from './document.service'
import { FILTER_TITLE } from 'src/app/data/filter-rule-type'
import { SettingsService } from '../settings.service'
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
+import {
+ DOCUMENT_SORT_FIELDS,
+ DOCUMENT_SORT_FIELDS_FULLTEXT,
+} from 'src/app/data/document'
+import { PermissionsService } from '../permissions.service'
let httpTestingController: HttpTestingController
let service: DocumentService
let subscription: Subscription
let settingsService: SettingsService
+
const endpoint = 'documents'
const documents = [
{
@@ -275,6 +281,25 @@ describe(`DocumentService`, () => {
})
})
+it('should construct sort fields respecting permissions', () => {
+ expect(
+ service.sortFields.find((f) => f.field === 'correspondent__name')
+ ).toBeUndefined()
+ expect(
+ service.sortFields.find((f) => f.field === 'document_type__name')
+ ).toBeUndefined()
+
+ const permissionsService: PermissionsService =
+ TestBed.inject(PermissionsService)
+ jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true)
+ service['setupSortFields']()
+ expect(service.sortFields).toEqual(DOCUMENT_SORT_FIELDS)
+ expect(service.sortFieldsFullText).toEqual([
+ ...DOCUMENT_SORT_FIELDS,
+ ...DOCUMENT_SORT_FIELDS_FULLTEXT,
+ ])
+})
+
afterEach(() => {
subscription?.unsubscribe()
httpTestingController.verify()
diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.ts
index f078a8de5..5197d9c0f 100644
--- a/src-ui/src/app/services/rest/document.service.ts
+++ b/src-ui/src/app/services/rest/document.service.ts
@@ -1,5 +1,9 @@
import { Injectable } from '@angular/core'
-import { Document } from 'src/app/data/document'
+import {
+ DOCUMENT_SORT_FIELDS,
+ DOCUMENT_SORT_FIELDS_FULLTEXT,
+ Document,
+} from 'src/app/data/document'
import { DocumentMetadata } from 'src/app/data/document-metadata'
import { AbstractPaperlessService } from './abstract-paperless-service'
import { HttpClient } from '@angular/common/http'
@@ -22,26 +26,6 @@ import { SettingsService } from '../settings.service'
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { AuditLogEntry } from 'src/app/data/auditlog-entry'
-export const DOCUMENT_SORT_FIELDS = [
- { field: 'archive_serial_number', name: $localize`ASN` },
- { field: 'correspondent__name', name: $localize`Correspondent` },
- { field: 'title', name: $localize`Title` },
- { field: 'document_type__name', name: $localize`Document type` },
- { field: 'created', name: $localize`Created` },
- { field: 'added', name: $localize`Added` },
- { field: 'modified', name: $localize`Modified` },
- { field: 'num_notes', name: $localize`Notes` },
- { field: 'owner', name: $localize`Owner` },
-]
-
-export const DOCUMENT_SORT_FIELDS_FULLTEXT = [
- ...DOCUMENT_SORT_FIELDS,
- {
- field: 'score',
- name: $localize`:Score is a value returned by the full text search engine and specifies how well a result matches the given query:Search score`,
- },
-]
-
export interface SelectionDataItem {
id: number
document_count: number
@@ -60,6 +44,16 @@ export interface SelectionData {
export class DocumentService extends AbstractPaperlessService {
private _searchQuery: string
+ private _sortFields
+ get sortFields() {
+ return this._sortFields
+ }
+
+ private _sortFieldsFullText
+ get sortFieldsFullText() {
+ return this._sortFieldsFullText
+ }
+
constructor(
http: HttpClient,
private correspondentService: CorrespondentService,
@@ -70,6 +64,35 @@ export class DocumentService extends AbstractPaperlessService {
private settingsService: SettingsService
) {
super(http, 'documents')
+ this.setupSortFields()
+ }
+
+ private setupSortFields() {
+ this._sortFields = [...DOCUMENT_SORT_FIELDS]
+ if (
+ !this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.Correspondent
+ )
+ ) {
+ this._sortFields = this._sortFields.filter(
+ (field) => field.field !== 'correspondent__name'
+ )
+ }
+ if (
+ !this.permissionsService.currentUserCan(
+ PermissionAction.View,
+ PermissionType.DocumentType
+ )
+ ) {
+ this._sortFields = this._sortFields.filter(
+ (field) => field.field !== 'document_type__name'
+ )
+ }
+ this._sortFieldsFullText = [
+ ...this._sortFields,
+ ...DOCUMENT_SORT_FIELDS_FULLTEXT,
+ ]
}
addObservablesToDocument(doc: Document) {