From a8bdf76c39c86b66d21498154c82560fb4233c04 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Thu, 10 Mar 2022 21:18:45 +0200 Subject: [PATCH] RED-1752 -> fixed the file name in the notification message --- .../src/app/services/notifications.service.ts | 18 +++++++++++++----- .../lib/notifications/notification-target.ts | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/red-ui/src/app/services/notifications.service.ts b/apps/red-ui/src/app/services/notifications.service.ts index f47cce9c5..e81677afb 100644 --- a/apps/red-ui/src/app/services/notifications.service.ts +++ b/apps/red-ui/src/app/services/notifications.service.ts @@ -68,18 +68,26 @@ export class NotificationsService extends GenericService { const fileId = notification.target.fileId; const dossierId = notification.target.dossierId; const dossier = this._activeDossiersService.find(dossierId); - const files = this._filesMapService.get(dossierId); - const file = files?.find(f => f.fileId === fileId); + const fileName = notification.target.fileName; return this._translateService.instant(translation, { - fileHref: file?.routerLink, - dossierHref: dossier?.routerLink, + fileHref: this._getFileHref(dossierId, fileId), + dossierHref: this._getDossierHref(dossierId), dossierName: notification.target?.dossierName || dossier?.dossierName || this._translateService.instant(_('dossier')), - fileName: file?.filename || this._translateService.instant(_('file')), + fileName: fileName || this._translateService.instant(_('file')), user: this._getUsername(notification.userId), }); } + private _getFileHref(dossierId: string, fileId: string): string { + const dossierHref = this._getDossierHref(dossierId); + return `${dossierHref}/file/${fileId}`; + } + + private _getDossierHref(dossierId: string): string { + return `/ui/main/dossiers/${dossierId}`; + } + private _getUsername(userId: string | undefined) { return this._userService.getNameForId(userId) || this._translateService.instant(_('unknown')); } diff --git a/libs/red-domain/src/lib/notifications/notification-target.ts b/libs/red-domain/src/lib/notifications/notification-target.ts index 262d32f9f..cd981053b 100644 --- a/libs/red-domain/src/lib/notifications/notification-target.ts +++ b/libs/red-domain/src/lib/notifications/notification-target.ts @@ -1,6 +1,7 @@ export interface INotificationTarget { fileId: string; dossierId: string; + fileName: string; [key: string]: unknown; }