Hide notes and owner sort fields if needed
This commit is contained in:
parent
05c7105643
commit
ea7eaac9f5
@ -298,6 +298,12 @@ it('should construct sort fields respecting permissions', () => {
|
|||||||
...DOCUMENT_SORT_FIELDS,
|
...DOCUMENT_SORT_FIELDS,
|
||||||
...DOCUMENT_SORT_FIELDS_FULLTEXT,
|
...DOCUMENT_SORT_FIELDS_FULLTEXT,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
settingsService.set(SETTINGS_KEYS.NOTES_ENABLED, false)
|
||||||
|
service['setupSortFields']()
|
||||||
|
expect(
|
||||||
|
service.sortFields.find((f) => f.field === 'num_notes')
|
||||||
|
).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -69,15 +69,14 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
|||||||
|
|
||||||
private setupSortFields() {
|
private setupSortFields() {
|
||||||
this._sortFields = [...DOCUMENT_SORT_FIELDS]
|
this._sortFields = [...DOCUMENT_SORT_FIELDS]
|
||||||
|
let excludes = []
|
||||||
if (
|
if (
|
||||||
!this.permissionsService.currentUserCan(
|
!this.permissionsService.currentUserCan(
|
||||||
PermissionAction.View,
|
PermissionAction.View,
|
||||||
PermissionType.Correspondent
|
PermissionType.Correspondent
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this._sortFields = this._sortFields.filter(
|
excludes.push('correspondent__name')
|
||||||
(field) => field.field !== 'correspondent__name'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!this.permissionsService.currentUserCan(
|
!this.permissionsService.currentUserCan(
|
||||||
@ -85,10 +84,22 @@ export class DocumentService extends AbstractPaperlessService<Document> {
|
|||||||
PermissionType.DocumentType
|
PermissionType.DocumentType
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this._sortFields = this._sortFields.filter(
|
excludes.push('document_type__name')
|
||||||
(field) => field.field !== 'document_type__name'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
!this.permissionsService.currentUserCan(
|
||||||
|
PermissionAction.View,
|
||||||
|
PermissionType.User
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
excludes.push('owner')
|
||||||
|
}
|
||||||
|
if (!this.settingsService.get(SETTINGS_KEYS.NOTES_ENABLED)) {
|
||||||
|
excludes.push('num_notes')
|
||||||
|
}
|
||||||
|
this._sortFields = this._sortFields.filter(
|
||||||
|
(field) => !excludes.includes(field.field)
|
||||||
|
)
|
||||||
this._sortFieldsFullText = [
|
this._sortFieldsFullText = [
|
||||||
...this._sortFields,
|
...this._sortFields,
|
||||||
...DOCUMENT_SORT_FIELDS_FULLTEXT,
|
...DOCUMENT_SORT_FIELDS_FULLTEXT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user