diff --git a/apps/red-ui/src/app/components/notifications/notifications.component.html b/apps/red-ui/src/app/components/notifications/notifications.component.html index 8f99a4db8..bd15772d8 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.html +++ b/apps/red-ui/src/app/components/notifications/notifications.component.html @@ -1,9 +1,10 @@ - +
{{ group.dateString }}
{{ getTime(notification.creationDate) }}
{ - this.notifications = response.notifications; + this.notifications = response.notifications.filter(notification => this._isSupportedType(notification)); this._groupNotifications(this.notifications); }); } + get hasUnreadNotifications() { + return this.notifications?.filter(n => !n.readDate).length > 0; + } + getTime(date: string): string { moment.locale(this._translateService.currentLang); return moment(date).format('hh:mm A'); @@ -49,26 +55,39 @@ export class NotificationsComponent { getNotificationMessage(notification: Notification) { switch (notification.notificationType) { case NotificationType.ASSIGN_REVIEWER: - return this._translate(notification, 'notification.assign-reviewer'); + return this._translate(notification, _('notification.assign-reviewer')); case NotificationType.ASSIGN_APPROVER: - return this._translate(notification, 'notification.assign-approver'); + return this._translate(notification, _('notification.assign-approver')); + case NotificationType.DOCUMENT_APPROVED: + return this._translate(notification, _('notification.document-approved')); case NotificationType.UNASSIGNED_FROM_FILE: - return this._translate(notification, 'notification.unassigned-from-file'); + return this._translate(notification, _('notification.unassigned-from-file')); + case NotificationType.DOSSIER_OWNER_SET: + return this._translate(notification, _('notification.dossier-owner-set')); + case NotificationType.DOSSIER_OWNER_REMOVED: + return this._translate(notification, _('notification.dossier-owner-removed')); + case NotificationType.DOSSIER_OWNER_DELETED: + return this._translate(notification, _('notification.dossier-owner-deleted')); + case NotificationType.USER_BECOMES_DOSSIER_MEMBER: + return this._translate(notification, _('notification.user-becomes-dossier-member')); + case NotificationType.USER_REMOVED_AS_DOSSIER_MEMBER: + return this._translate(notification, _('notification.user-removed-as-dossier-member')); + case NotificationType.USER_PROMOTED_TO_APPROVER: + return this._translate(notification, _('notification.user-promoted-to-approver')); + case NotificationType.USER_DEGRADED_TO_REVIEWER: + return this._translate(notification, _('notification.user-denoted-to-reviewer')); + default: return ''; } } - toggleRead(notification: Notification, $event) { - $event.stopPropagation(); - notification.readDate = !notification.readDate ? moment().format('YYYY-MM-DDTHH:mm:ss Z') : null; - const ids = [notification.notificationId]; - const isRead = !!notification.readDate; - this._notificationControllerService.toggleNotificationRead(ids, isRead); + private _isSupportedType(notification: Notification) { + return Object.values(NotificationType).includes(notification.notificationType); } private _getDossierHref(dossierId: string) { - return `main/dossiers/${dossierId}`; + return `/ui/main/dossiers/${dossierId}`; } private _getFileHref(dossierId: string, fileId: string) { @@ -81,7 +100,10 @@ export class NotificationsComponent { const dossierId = notification.target.dossierId; return this._translateService.instant(translation, { fileHref: this._getFileHref(dossierId, fileId), - dossierHref: this._getDossierHref(dossierId) + dossierHref: this._getDossierHref(dossierId), + dossierName: this._getDossierName(notification.target?.dossierId), + fileName: this._getFileName(notification.target?.dossierId, notification.target?.fileId), + user: this._getUsername(notification.userId) }); } @@ -97,4 +119,29 @@ export class NotificationsComponent { } this.groupedNotifications = this.groupedNotifications.reverse(); } + + async markRead(notification: Notification, $event, isRead: boolean = true) { + $event.stopPropagation(); + const ids = [notification.notificationId]; + await this._notificationControllerService.toggleNotificationRead(ids, isRead).toPromise(); + if (isRead) { + notification.readDate = moment().format('YYYY-MM-DDTHH:mm:ss Z'); + } else { + notification.readDate = null; + } + } + + private _getDossierName(dossierId: string | undefined) { + const dossier = this._appStateService.getDossierById(dossierId); + return dossier?.dossierName || this._translateService.instant(_('dossier')); + } + + private _getFileName(dossierId: string | undefined, fileId: string | undefined) { + const file = this._appStateService.getFileById(dossierId, fileId); + return file?.filename || this._translateService.instant(_('file')); + } + + private _getUsername(userId: string | undefined) { + return this._userService.getNameForId(userId) || this._translateService.instant(_('unknown')); + } } diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index 5f0016685..1a75da0a2 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -277,7 +277,7 @@ export class AppStateService { return; } - await this.updateDossierDictionary(this.activeDossier.dossierTemplateId, dossierId); + this.updateDossierDictionary(this.activeDossier.dossierTemplateId, dossierId); } async updateDossierDictionary(dossierTemplateId: string, dossierId: string) { diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 0ce22733a..e298184fb 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -337,6 +337,9 @@ "title": "Confirm Action" } }, + "unknown": "Unknown", + "dossier": "Dossier", + "file": "File", "configurations": "Configurations", "confirm-delete-file-attribute": { "cancel": "Keep {type, select, single{Attribute} bulk{Attributes} other{}}", @@ -1026,7 +1029,7 @@ }, "filters": { "assigned-people": "Assignee(s)", - "dossier-templates": "Rule Sets", + "dossier-templates": "Dossier Templates", "filter-by": "Filter:", "needs-work": "Workload", "people": "Dossier Member(s)", @@ -1169,9 +1172,17 @@ "sep": "Sep." }, "notification": { - "assign-approver": "You have been assigned as approver for file in the dossier!", - "assign-reviewer": "You have been assigned as reviewer for file in the dossier!", - "unassigned-from-file": "You have been unassigned from file in the dossier!" + "assign-approver": "You have been assigned as approver for {fileName} in the {dossierName}!", + "assign-reviewer": "You have been assigned as reviewer for {fileName} in the {dossierName}!", + "unassigned-from-file": "You have been unassigned from {fileName} in the {dossierName}!", + "document-approved": " {fileName} has been approved!", + "dossier-owner-set": " {dossierName} owner changed to {user}!", + "dossier-owner-removed": "{dossierName} owner removed!", + "dossier-owner-deleted": "{dossierName} owner removed!", + "user-becomes-dossier-member": "{user} joined dossier: {dossierName}!", + "user-removed-as-dossier-member": "{user} removed as a member of: {dossierName} !", + "user-promoted-to-approver": "{user} promoted to approver in dossier: {dossierName}!", + "user-denoted-to-reviewer": "{user} denoted to reviewer in dossier: {dossierName}!" }, "notifications": { "mark-read": "Mark as read",