RED-5964 - Filter the notification preferences settings by roles (RED_USER, RED_MANAGER) in UI
This commit is contained in:
parent
72b2269bc3
commit
fe951bb130
@ -13,14 +13,16 @@
|
||||
<div *ngFor="let key of notificationGroupsKeys; let i = index" class="group">
|
||||
<div [translate]="translations[key]" class="group-title"></div>
|
||||
<div class="iqser-input-group">
|
||||
<mat-checkbox
|
||||
(change)="addRemovePreference($event.checked, category, preference)"
|
||||
*ngFor="let preference of notificationGroupsValues[i]"
|
||||
[checked]="isPreferenceChecked(category, preference)"
|
||||
color="primary"
|
||||
>
|
||||
{{ translations[preference] | translate }}
|
||||
</mat-checkbox>
|
||||
<ng-container *ngFor="let preference of notificationGroupsValues[i]">
|
||||
<mat-checkbox
|
||||
*ngIf="!skipPreference(preference)"
|
||||
(change)="addRemovePreference($event.checked, category, preference)"
|
||||
[checked]="isPreferenceChecked(category, preference)"
|
||||
color="primary"
|
||||
>
|
||||
{{ translations[preference] | translate }}
|
||||
</mat-checkbox>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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<User>();
|
||||
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 {
|
||||
|
||||
@ -50,3 +50,9 @@ export const NotificationGroupsValues = [
|
||||
DocumentNotificationsTypesValues,
|
||||
OtherNotificationsTypesValues,
|
||||
] as const;
|
||||
|
||||
export const SkipSimpleUserNotifications = [
|
||||
DossierNotificationsTypes.dossierOwnerSet,
|
||||
DossierNotificationsTypes.dossierOwnerRemoved,
|
||||
DocumentNotificationsTypes.documentApproved,
|
||||
] as const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user