From f0767204fc644b25aa38f53b055393188b4d2bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 10 Jan 2022 15:59:42 +0200 Subject: [PATCH] RED-2994: Adjust 'Deleted documents' tab in 'Edit Dossier' --- .../screens/audit/audit-screen.component.html | 4 +-- ...t-dossier-deleted-documents.component.html | 21 ++++++++++- ...dit-dossier-deleted-documents.component.ts | 36 +++++++++++++++---- .../assign-user-dropdown.component.html | 2 +- .../user-button/user-button.component.html | 2 +- .../initials-avatar.component.html | 2 +- apps/red-ui/src/assets/i18n/en.json | 2 ++ libs/common-ui | 2 +- 8 files changed, 56 insertions(+), 15 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html b/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html index 296eb49c8..0d7278f2d 100644 --- a/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/audit/audit-screen.component.html @@ -60,7 +60,6 @@ *ngIf="form.get('userId').value !== ALL_USERS" [user]="form.get('userId').value" [withName]="true" - size="small" >
@@ -69,7 +68,6 @@ *ngIf="userId !== ALL_USERS" [user]="userId" [withName]="true" - size="small" >
@@ -109,7 +107,7 @@
- +
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/deleted-documents/edit-dossier-deleted-documents.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/deleted-documents/edit-dossier-deleted-documents.component.html index 7319b9040..ce1c54ddc 100644 --- a/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/deleted-documents/edit-dossier-deleted-documents.component.html +++ b/apps/red-ui/src/app/modules/dossier/dialogs/edit-dossier-dialog/deleted-documents/edit-dossier-deleted-documents.component.html @@ -28,7 +28,7 @@ +
+ +
+ +
+ +
+
{{ file.softDeleted | date: 'exactDate' }}
@@ -65,6 +83,7 @@ implements EditDossierSectionInterface, OnInit { + readonly fileStatusTranslations = workflowFileStatusTranslations; @Input() dossier: Dossier; readonly changed = false; readonly valid = false; readonly canRestoreSelected$ = this._canRestoreSelected$; + readonly canDeleteSelected$ = this._canDeleteSelected$; disabled: boolean; readonly tableColumnConfigs: TableColumnConfig[] = [ { label: _('edit-dossier-dialog.deleted-documents.table-col-names.name'), width: '3fr' }, { label: _('edit-dossier-dialog.deleted-documents.table-col-names.pages') }, + { label: _('edit-dossier-dialog.deleted-documents.table-col-names.assignee'), class: 'user-column' }, + { label: _('edit-dossier-dialog.deleted-documents.table-col-names.status') }, { label: _('edit-dossier-dialog.deleted-documents.table-col-names.deleted-on'), sortByKey: 'softDeleted', width: '2fr' }, { label: _('edit-dossier-dialog.deleted-documents.table-col-names.time-to-restore'), sortByKey: 'softDeleted', width: '2fr' }, ]; @@ -59,6 +67,8 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent { + return this.listingService.selectedEntities$.pipe( + map(entities => entities.length && !entities.find(file => !file.canHardDelete)), + distinctUntilChanged(), + ); + } + hardDelete(files = this.listingService.selected) { const data = new ConfirmationDialogInput({ title: _('confirmation-dialog.permanently-delete-file.title'), @@ -133,21 +150,26 @@ export class EditDossierDeletedDocumentsComponent extends ListingComponent this._toListItem(file)); } - private _toListItem(file: IFile): FileListItem { - const restoreDate = this._getRestoreDate(file.softDeleted); + private _toListItem(_file: IFile): FileListItem { + const file = new File(_file, this._userService.getNameForId(_file.assignee)); + const restoreDate = this._getRestoreDate(_file.softDeleted); return { id: file.fileId, ...file, restoreDate, searchKey: file.filename, - canRestore: this._canRestoreFile(restoreDate), + canRestore: this._canRestore(file, restoreDate), + canHardDelete: this._canPerformActions(file), }; } - private _canRestoreFile(restoreDate: string): boolean { - const { daysLeft, hoursLeft, minutesLeft } = getLeftDateTime(restoreDate); + private _canPerformActions(file: File): boolean { + return this._userService.currentUser.isManager || this._permissionsService.canDeleteFile(file); + } - return daysLeft >= 0 && hoursLeft >= 0 && minutesLeft >= 0; + private _canRestore(file: File, restoreDate: string): boolean { + const { daysLeft, hoursLeft, minutesLeft } = getLeftDateTime(restoreDate); + return this._canPerformActions(file) && daysLeft + hoursLeft + minutesLeft > 0; } private _getRestoreDate(softDeletedTime: string): string { diff --git a/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.html b/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.html index 50fd141f2..4db38fa1d 100644 --- a/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.html +++ b/apps/red-ui/src/app/modules/shared/components/assign-user-dropdown/assign-user-dropdown.component.html @@ -28,5 +28,5 @@ - + diff --git a/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html b/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html index d336757c6..f06bc81c8 100644 --- a/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html +++ b/apps/red-ui/src/app/modules/shared/components/buttons/user-button/user-button.component.html @@ -1,5 +1,5 @@
diff --git a/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.html b/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.html index 538181b7c..027c9a0dd 100644 --- a/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.html +++ b/apps/red-ui/src/app/modules/shared/components/initials-avatar/initials-avatar.component.html @@ -6,7 +6,7 @@ > {{ _user | name: { showInitials: true } }} -
+
{{ userName }}
diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 640b61a18..62ad70561 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -875,9 +875,11 @@ "title": "There are no deleted documents." }, "table-col-names": { + "assignee": "Assignee", "deleted-on": "Deleted On", "name": "Name", "pages": "Pages", + "status": "Status", "time-to-restore": "Time To Restore" }, "table-header": { diff --git a/libs/common-ui b/libs/common-ui index 0610684e8..3d7d8d3d2 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 0610684e8fb963fab1f7dd51fd850a7b47287fca +Subproject commit 3d7d8d3d28a682cd26df7af4e6c1bbc90f640521