RED-1752 -> fixed the file name in the notification message

This commit is contained in:
Valentin Mihai 2022-03-10 21:18:45 +02:00
parent b10d88bba7
commit a8bdf76c39
2 changed files with 14 additions and 5 deletions

View File

@ -68,18 +68,26 @@ export class NotificationsService extends GenericService<Notification> {
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'));
}

View File

@ -1,6 +1,7 @@
export interface INotificationTarget {
fileId: string;
dossierId: string;
fileName: string;
[key: string]: unknown;
}