From fe951bb1303c38881a5b0e7c0d33ffed3083bb46 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 17 Jan 2023 03:35:09 +0200 Subject: [PATCH] RED-5964 - Filter the notification preferences settings by roles (RED_USER, RED_MANAGER) in UI --- .../notifications-screen.component.html | 18 ++++++++++-------- .../notifications-screen.component.ts | 16 +++++++++++++--- .../src/lib/notifications-preferences/types.ts | 6 ++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.html b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.html index 8a808a3ac..281579968 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.html +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.html @@ -13,14 +13,16 @@
- - {{ translations[preference] | translate }} - + + + {{ translations[preference] | translate }} + +
diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts index 6ce71512d..f80144236 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen/notifications-screen.component.ts @@ -1,9 +1,15 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { NotificationPreferencesService } from '../../../services/notification-preferences.service'; -import { BaseFormComponent, LoadingService, Toaster } from '@iqser/common-ui'; +import { BaseFormComponent, getCurrentUser, LoadingService, Toaster } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { NotificationCategoriesValues, NotificationGroupsKeys, NotificationGroupsValues } from '@red/domain'; +import { + NotificationCategoriesValues, + NotificationGroupsKeys, + NotificationGroupsValues, + SkipSimpleUserNotifications, + User, +} from '@red/domain'; import { firstValueFrom } from 'rxjs'; import { notificationsSettingsTranslations } from '@translations/notifications-settings-translations'; @@ -17,7 +23,7 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O readonly notificationGroupsKeys = NotificationGroupsKeys; readonly notificationGroupsValues = NotificationGroupsValues; readonly translations = notificationsSettingsTranslations; - + readonly currentUser = getCurrentUser(); constructor( private readonly _toaster: Toaster, private readonly _formBuilder: UntypedFormBuilder, @@ -53,6 +59,10 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O this.form.get(category).setValue(unique); } + skipPreference(preference): boolean { + return !this.currentUser.isManager && SkipSimpleUserNotifications.includes(preference); + } + async save() { this._loadingService.start(); try { diff --git a/libs/red-domain/src/lib/notifications-preferences/types.ts b/libs/red-domain/src/lib/notifications-preferences/types.ts index a0e1a2d23..5228dd073 100644 --- a/libs/red-domain/src/lib/notifications-preferences/types.ts +++ b/libs/red-domain/src/lib/notifications-preferences/types.ts @@ -50,3 +50,9 @@ export const NotificationGroupsValues = [ DocumentNotificationsTypesValues, OtherNotificationsTypesValues, ] as const; + +export const SkipSimpleUserNotifications = [ + DossierNotificationsTypes.dossierOwnerSet, + DossierNotificationsTypes.dossierOwnerRemoved, + DocumentNotificationsTypes.documentApproved, +] as const;