From ccea2bff0527fefe69be6014db1c0cf9c0c852cd Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Wed, 27 Oct 2021 13:30:51 +0300 Subject: [PATCH 1/4] added view all (UI improvements needed) --- .../notifications/notifications.component.html | 6 +++++- .../notifications/notifications.component.scss | 7 ++++++- .../notifications/notifications.component.ts | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) 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 3b2f42e76..8c739086f 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.html +++ b/apps/red-ui/src/app/components/notifications/notifications.component.html @@ -11,7 +11,11 @@ >
-
{{ group.date }}
+
+
{{ group.date }}
+
View all
+
+
{ + $event.stopPropagation(); + const notifications = await this._notificationsService.getNotifications(false).toPromise(); + await this._readNotifications(notifications); + await this._loadData(); + } + async markRead(notification: Notification, $event, isRead = true): Promise { $event.stopPropagation(); await this._notificationsService.toggleNotificationRead([notification.id], isRead).toPromise(); await this._loadData(); } + private async _readNotifications(notifications: Notification[]): Promise { + for (const notification of notifications) { + await this._notificationsService.toggleNotificationRead([notification.id], true).toPromise(); + } + } + private async _loadData(): Promise { const notifications = await this._notificationsService.getNotifications(false).toPromise(); this._notifications$.next(notifications); From 9fcedf72724c0f89c442ed51388eb1e3b9a318ed Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Wed, 27 Oct 2021 14:55:36 +0300 Subject: [PATCH 2/4] refactored view all functionality + hover change color --- .../notifications/notifications.component.html | 4 +++- .../notifications/notifications.component.scss | 3 +++ .../notifications/notifications.component.ts | 15 +++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) 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 8c739086f..2726ea1c5 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.html +++ b/apps/red-ui/src/app/components/notifications/notifications.component.html @@ -13,7 +13,9 @@
{{ group.date }}
-
View all
+
+ View all +
{ $event.stopPropagation(); - const notifications = await this._notificationsService.getNotifications(false).toPromise(); - await this._readNotifications(notifications); + const notifications = this._notifications$.getValue(); + await this._notificationsService + .toggleNotificationRead( + notifications.map(n => n.id), + true, + ) + .toPromise(); await this._loadData(); } @@ -59,12 +64,6 @@ export class NotificationsComponent implements OnInit { await this._loadData(); } - private async _readNotifications(notifications: Notification[]): Promise { - for (const notification of notifications) { - await this._notificationsService.toggleNotificationRead([notification.id], true).toPromise(); - } - } - private async _loadData(): Promise { const notifications = await this._notificationsService.getNotifications(false).toPromise(); this._notifications$.next(notifications); From a9159eda22836ff6559556870da8472b5626722c Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Wed, 27 Oct 2021 17:51:40 +0300 Subject: [PATCH 3/4] markRead and markAllRead in one method --- .../notifications.component.html | 10 ++++------ .../notifications/notifications.component.ts | 20 +++++-------------- 2 files changed, 9 insertions(+), 21 deletions(-) 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 2726ea1c5..6547b1e45 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.html +++ b/apps/red-ui/src/app/components/notifications/notifications.component.html @@ -10,16 +10,14 @@ [verticalPadding]="0" > -
+
{{ group.date }}
-
- View all -
+
View all
{{ notification.time }}
notifications.filter(n => !n.readDate).length > 0), distinctUntilChanged(), + shareReplay(1), ); } @@ -46,21 +47,10 @@ export class NotificationsComponent implements OnInit { await this._loadData(); } - async markAllAsRead($event): Promise { + async markRead($event, notification?: Notification, isRead = true): Promise { $event.stopPropagation(); - const notifications = this._notifications$.getValue(); - await this._notificationsService - .toggleNotificationRead( - notifications.map(n => n.id), - true, - ) - .toPromise(); - await this._loadData(); - } - - async markRead(notification: Notification, $event, isRead = true): Promise { - $event.stopPropagation(); - await this._notificationsService.toggleNotificationRead([notification.id], isRead).toPromise(); + const body = notification ? [notification.id] : this._notifications$.getValue().map(n => n.id); + await this._notificationsService.toggleNotificationRead(body, isRead).toPromise(); await this._loadData(); } From 3b64e75ae2b64c61131a8cba91b85bfa48aae99d Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Thu, 28 Oct 2021 12:28:17 +0300 Subject: [PATCH 4/4] markRead method now has all notifications by default --- .../components/notifications/notifications.component.html | 4 ++-- .../app/components/notifications/notifications.component.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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 6547b1e45..a7ef00a67 100644 --- a/apps/red-ui/src/app/components/notifications/notifications.component.html +++ b/apps/red-ui/src/app/components/notifications/notifications.component.html @@ -17,7 +17,7 @@
{{ notification.time }}
{ + async markRead($event, notifications: List = this._notifications$.getValue().map(n => n.id), isRead = true): Promise { $event.stopPropagation(); - const body = notification ? [notification.id] : this._notifications$.getValue().map(n => n.id); - await this._notificationsService.toggleNotificationRead(body, isRead).toPromise(); + await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise(); await this._loadData(); }