Pull request #300: RED-2554
Merge in RED/ui from RED-2554 to master * commit '3b64e75ae2b64c61131a8cba91b85bfa48aae99d': markRead method now has all notifications by default markRead and markAllRead in one method refactored view all functionality + hover change color added view all (UI improvements needed)
This commit is contained in:
commit
2ba635ea3c
@ -10,10 +10,14 @@
|
||||
[verticalPadding]="0"
|
||||
></iqser-empty-state>
|
||||
|
||||
<div *ngFor="let group of groups">
|
||||
<div class="all-caps-label">{{ group.date }}</div>
|
||||
<div *ngFor="let group of groups; let first = first">
|
||||
<div class="all-caps-label flex-align-items-center">
|
||||
<div>{{ group.date }}</div>
|
||||
<div *ngIf="(hasUnreadNotifications$ | async) && first" class="view-all" (click)="markRead($event)">View all</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
(click)="markRead(notification, $event)"
|
||||
(click)="markRead($event, [notification.id])"
|
||||
*ngFor="let notification of group.notifications | sortBy: 'desc':'creationDate'"
|
||||
[class.unread]="!notification.readDate"
|
||||
class="notification"
|
||||
@ -25,7 +29,7 @@
|
||||
<div class="small-label mt-2">{{ notification.time }}</div>
|
||||
</div>
|
||||
<div
|
||||
(click)="markRead(notification, $event, !notification.readDate)"
|
||||
(click)="markRead($event, [notification.id], !notification.readDate)"
|
||||
class="dot"
|
||||
matTooltip="{{ 'notifications.mark-as' | translate: { type: notification.readDate ? 'unread' : 'read' } }}"
|
||||
matTooltipPosition="before"
|
||||
|
||||
@ -15,7 +15,15 @@
|
||||
max-height: calc(100vh - 200px);
|
||||
|
||||
.all-caps-label {
|
||||
margin: 16px 0 6px 8px;
|
||||
justify-content: space-between;
|
||||
margin: 16px 8px 6px;
|
||||
|
||||
.view-all {
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: var(--iqser-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mat-menu-item.notification {
|
||||
|
||||
@ -6,8 +6,9 @@ import { UserService } from '@services/user.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { NotificationsService } from '@services/notifications.service';
|
||||
import { Notification } from '@red/domain';
|
||||
import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, map, shareReplay } from 'rxjs/operators';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { List } from '@iqser/common-ui';
|
||||
|
||||
interface NotificationsGroup {
|
||||
date: string;
|
||||
@ -39,6 +40,7 @@ export class NotificationsComponent implements OnInit {
|
||||
this.hasUnreadNotifications$ = this.notifications$.pipe(
|
||||
map(notifications => notifications.filter(n => !n.readDate).length > 0),
|
||||
distinctUntilChanged(),
|
||||
shareReplay(1),
|
||||
);
|
||||
}
|
||||
|
||||
@ -46,9 +48,9 @@ export class NotificationsComponent implements OnInit {
|
||||
await this._loadData();
|
||||
}
|
||||
|
||||
async markRead(notification: Notification, $event, isRead = true): Promise<void> {
|
||||
async markRead($event, notifications: List<string> = this._notifications$.getValue().map(n => n.id), isRead = true): Promise<void> {
|
||||
$event.stopPropagation();
|
||||
await this._notificationsService.toggleNotificationRead([notification.id], isRead).toPromise();
|
||||
await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise();
|
||||
await this._loadData();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user