Enhancement: Hide Columns in Document List if the User does not have the permissions

This commit is contained in:
Dominik Bruhn 2024-04-16 21:39:53 +02:00
parent f009d9868e
commit 2258350fa2
2 changed files with 55 additions and 37 deletions

View File

@ -141,13 +141,15 @@
[currentSortReverse]="list.sortReverse" [currentSortReverse]="list.sortReverse"
(sort)="onSort($event)" (sort)="onSort($event)"
i18n>ASN</th> i18n>ASN</th>
<th class="d-none d-md-table-cell" @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.Correspondent)) {
pngxSortable="correspondent__name" <th class="d-none d-md-table-cell"
title="Sort by correspondent" i18n-title pngxSortable="correspondent__name"
[currentSortField]="list.sortField" title="Sort by correspondent" i18n-title
[currentSortReverse]="list.sortReverse" [currentSortField]="list.sortField"
(sort)="onSort($event)" [currentSortReverse]="list.sortReverse"
i18n>Correspondent</th> (sort)="onSort($event)"
i18n>Correspondent</th>
}
<th <th
pngxSortable="title" pngxSortable="title"
title="Sort by title" i18n-title title="Sort by title" i18n-title
@ -172,20 +174,24 @@
(sort)="onSort($event)" (sort)="onSort($event)"
i18n>Notes</th> i18n>Notes</th>
} }
<th class="d-none d-xl-table-cell" @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.DocumentType)) {
pngxSortable="document_type__name" <th class="d-none d-xl-table-cell"
title="Sort by document type" i18n-title pngxSortable="document_type__name"
[currentSortField]="list.sortField" title="Sort by document type" i18n-title
[currentSortReverse]="list.sortReverse" [currentSortField]="list.sortField"
(sort)="onSort($event)" [currentSortReverse]="list.sortReverse"
i18n>Document type</th> (sort)="onSort($event)"
<th class="d-none d-xl-table-cell" i18n>Document type</th>
pngxSortable="storage_path__name" }
title="Sort by storage path" i18n-title @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.StoragePath)) {
[currentSortField]="list.sortField" <th class="d-none d-xl-table-cell"
[currentSortReverse]="list.sortReverse" pngxSortable="storage_path__name"
(sort)="onSort($event)" title="Sort by storage path" i18n-title
i18n>Storage path</th> [currentSortField]="list.sortField"
[currentSortReverse]="list.sortReverse"
(sort)="onSort($event)"
i18n>Storage path</th>
}
<th <th
pngxSortable="created" pngxSortable="created"
title="Sort by created date" i18n-title title="Sort by created date" i18n-title
@ -213,11 +219,13 @@
<td class="d-none d-lg-table-cell"> <td class="d-none d-lg-table-cell">
{{d.archive_serial_number}} {{d.archive_serial_number}}
</td> </td>
<td class="d-none d-md-table-cell"> @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.Correspondent)) {
@if (d.correspondent) { <td class="d-none d-md-table-cell">
<a (click)="clickCorrespondent(d.correspondent);$event.stopPropagation()" title="Filter by correspondent" i18n-title>{{(d.correspondent$ | async)?.name}}</a> @if (d.correspondent) {
} <a (click)="clickCorrespondent(d.correspondent);$event.stopPropagation()" title="Filter by correspondent" i18n-title>{{(d.correspondent$ | async)?.name}}</a>
</td> }
</td>
}
<td> <td>
<a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a> <a routerLink="/documents/{{d.id}}" title="Edit document" i18n-title style="overflow-wrap: anywhere;">{{d.title | documentTitle}}</a>
@for (t of d.tags$ | async; track t) { @for (t of d.tags$ | async; track t) {
@ -238,16 +246,20 @@
} }
</td> </td>
} }
<td class="d-none d-xl-table-cell"> @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.DocumentType)) {
@if (d.document_type) { <td class="d-none d-xl-table-cell">
<a (click)="clickDocumentType(d.document_type);$event.stopPropagation()" title="Filter by document type" i18n-title>{{(d.document_type$ | async)?.name}}</a> @if (d.document_type) {
} <a (click)="clickDocumentType(d.document_type);$event.stopPropagation()" title="Filter by document type" i18n-title>{{(d.document_type$ | async)?.name}}</a>
</td> }
<td class="d-none d-xl-table-cell"> </td>
@if (d.storage_path) { }
<a (click)="clickStoragePath(d.storage_path);$event.stopPropagation()" title="Filter by storage path" i18n-title>{{(d.storage_path$ | async)?.name}}</a> @if (permissionService.currentUserCan(PermissionAction.View, PermissionType.StoragePath)) {
} <td class="d-none d-xl-table-cell">
</td> @if (d.storage_path) {
<a (click)="clickStoragePath(d.storage_path);$event.stopPropagation()" title="Filter by storage path" i18n-title>{{(d.storage_path$ | async)?.name}}</a>
}
</td>
}
<td> <td>
{{d.created_date | customDate}} {{d.created_date | customDate}}
</td> </td>

View File

@ -29,6 +29,11 @@ import {
DOCUMENT_SORT_FIELDS, DOCUMENT_SORT_FIELDS,
DOCUMENT_SORT_FIELDS_FULLTEXT, DOCUMENT_SORT_FIELDS_FULLTEXT,
} from 'src/app/services/rest/document.service' } from 'src/app/services/rest/document.service'
import {
PermissionAction,
PermissionsService,
PermissionType,
} from 'src/app/services/permissions.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service' import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
@ -54,7 +59,8 @@ export class DocumentListComponent
private modalService: NgbModal, private modalService: NgbModal,
private consumerStatusService: ConsumerStatusService, private consumerStatusService: ConsumerStatusService,
public openDocumentsService: OpenDocumentsService, public openDocumentsService: OpenDocumentsService,
private settingsService: SettingsService private settingsService: SettingsService,
public permissionService: PermissionsService
) { ) {
super() super()
} }