From 4f5d045960b042eb27e10bac1bdaf1c074c9fa2a Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 23 Jul 2020 21:30:04 +0200 Subject: harmonize search for libraries --- .../my-account-notifications.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts') diff --git a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts index 8a51319fe..0ec67d401 100644 --- a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts +++ b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts @@ -1,6 +1,8 @@ import { Component, ViewChild } from '@angular/core' import { UserNotificationsComponent } from '@app/shared/shared-main' +type NotificationSortType = 'createdAt' | 'read' + @Component({ templateUrl: './my-account-notifications.component.html', styleUrls: [ './my-account-notifications.component.scss' ] @@ -8,7 +10,17 @@ import { UserNotificationsComponent } from '@app/shared/shared-main' export class MyAccountNotificationsComponent { @ViewChild('userNotification', { static: true }) userNotification: UserNotificationsComponent - notificationSortType = 'created' + _notificationSortType: NotificationSortType = 'createdAt' + + get notificationSortType () { + return !this.hasUnreadNotifications() + ? 'createdAt' + : this._notificationSortType + } + + set notificationSortType (type: NotificationSortType) { + this._notificationSortType = type + } markAllAsRead () { this.userNotification.markAllAsRead() @@ -17,4 +29,8 @@ export class MyAccountNotificationsComponent { hasUnreadNotifications () { return this.userNotification.notifications.filter(n => n.read === false).length !== 0 } + + onChangeSortColumn () { + this.userNotification.changeSortColumn(this.notificationSortType) + } } -- cgit v1.2.3