DM-340, change notification texts, hide rss specifics.

This commit is contained in:
George 2023-07-18 16:51:50 +03:00
parent 199d2ec0a2
commit 2a2cf3047a
3 changed files with 36 additions and 27 deletions

View File

@ -13,7 +13,7 @@
<div *ngFor="let key of notificationGroupsKeys; let i = index" class="group">
<div [translate]="translations[key]" class="group-title"></div>
<div class="iqser-input-group">
<ng-container *ngFor="let preference of notificationGroupsValues[i]">
<ng-container *ngFor="let preference of getRssFilteredSettings(notificationGroupsValues[i])">
<mat-checkbox
*ngIf="!skipPreference(preference)"
(change)="addRemovePreference($event.checked, category, preference)"

View File

@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, 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, IqserPermissionsService, LoadingService, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import {
NotificationCategoriesValues,
@ -13,6 +13,9 @@ import {
import { firstValueFrom } from 'rxjs';
import { notificationsSettingsTranslations } from '@translations/notifications-settings-translations';
import { getCurrentUser } from '@iqser/common-ui/lib/users';
import { Roles } from '@users/roles';
const RSS_EXCLUDED_SETTINGS = ['USER_PROMOTED_TO_APPROVER', 'USER_DEGRADED_TO_REVIEWER', 'ASSIGN_REVIEWER'];
@Component({
templateUrl: './notifications-screen.component.html',
@ -26,18 +29,24 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
readonly translations = notificationsSettingsTranslations;
readonly currentUser = getCurrentUser<User>();
constructor(
private readonly _toaster: Toaster,
private readonly _formBuilder: UntypedFormBuilder,
private readonly _loadingService: LoadingService,
private readonly _notificationPreferencesService: NotificationPreferencesService,
private readonly _changeRef: ChangeDetectorRef,
) {
readonly #toaster = inject(Toaster);
readonly #formBuilder = inject(UntypedFormBuilder);
readonly #loadingService = inject(LoadingService);
readonly #notificationPreferencesService = inject(NotificationPreferencesService);
readonly #cdRef = inject(ChangeDetectorRef);
readonly #iqserPermissionsService = inject(IqserPermissionsService);
readonly #isRss = this.#iqserPermissionsService.has(Roles.getRss);
constructor() {
super();
}
async ngOnInit(): Promise<void> {
await this._initializeForm();
await this.#initializeForm();
}
getRssFilteredSettings(settings: string[]) {
return settings.filter(s => (this.#isRss ? !RSS_EXCLUDED_SETTINGS.includes(s) : true));
}
isCategoryActive(category: string) {
@ -66,19 +75,19 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
}
async save() {
this._loadingService.start();
this.#loadingService.start();
try {
await firstValueFrom(this._notificationPreferencesService.update(this.form.value));
await firstValueFrom(this.#notificationPreferencesService.update(this.form.value));
} catch (e) {
this._toaster.error(_('notifications-screen.error.generic'));
this.#toaster.error(_('notifications-screen.error.generic'));
}
this.initialFormValue = JSON.parse(JSON.stringify(this.form.getRawValue()));
this._changeRef.markForCheck();
this._loadingService.stop();
this.#cdRef.markForCheck();
this.#loadingService.stop();
}
private _getForm(): UntypedFormGroup {
return this._formBuilder.group({
#getForm(): UntypedFormGroup {
return this.#formBuilder.group({
inAppNotificationsEnabled: [undefined],
emailNotificationsEnabled: [undefined],
emailNotificationType: [undefined],
@ -87,14 +96,14 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
});
}
private async _initializeForm() {
this._loadingService.start();
async #initializeForm() {
this.#loadingService.start();
this.form = this._getForm();
const notificationPreferences = await firstValueFrom(this._notificationPreferencesService.get());
this.form = this.#getForm();
const notificationPreferences = await firstValueFrom(this.#notificationPreferencesService.get());
this.form.patchValue(notificationPreferences);
this.initialFormValue = JSON.parse(JSON.stringify(this.form.getRawValue()));
this._loadingService.stop();
this.#loadingService.stop();
}
}

View File

@ -1717,9 +1717,9 @@
"minutes": "minutes",
"no-active-license": "Invalid or corrupt license Please contact your administrator",
"notification": {
"assign-approver": "You have been assigned as approver for <b>{fileHref, select, null{{fileName}} other{<a href=\"{fileHref}\" target=\"_blank\">{fileName}</a>}}</b> in dossier: <b>{dossierHref, select, null{{dossierName}} other{<a href=\"{dossierHref}\" target=\"_blank\">{dossierName}</a>}}</b>!",
"assign-approver": "You have been assigned to <b>{fileHref, select, null{{fileName}} other{<a href=\"{fileHref}\" target=\"_blank\">{fileName}</a>}}</b> in dossier: <b>{dossierHref, select, null{{dossierName}} other{<a href=\"{dossierHref}\" target=\"_blank\">{dossierName}</a>}}</b>!",
"assign-reviewer": "You have been assigned as reviewer for <b>{fileHref, select, null{{fileName}} other{<a href=\"{fileHref}\" target=\"_blank\">{fileName}</a>}}</b> in dossier: <b>{dossierHref, select, null{{dossierName}} other{<a href=\"{dossierHref}\" target=\"_blank\">{dossierName}</a>}}</b>!",
"document-approved": " <b>{fileHref, select, null{{fileName}} other{<a href=\"{fileHref}\" target=\"_blank\">{fileName}</a>}}</b> has been approved!",
"document-approved": " <b>{fileHref, select, null{{fileName}} other{<a href=\"{fileHref}\" target=\"_blank\">{fileName}</a>}}</b> has been moved to Done!",
"dossier-deleted": "Dossier: <b>{dossierName}</b> has been deleted!",
"dossier-owner-deleted": "The owner of dossier: <b>{dossierName}</b> has been deleted!",
"dossier-owner-removed": "You have been removed as dossier owner from <b>{dossierHref, select, null{{dossierName}} other{<a href=\"{dossierHref}\" target=\"_blank\">{dossierName}</a>}}</b>!",
@ -1747,9 +1747,9 @@
},
"options-title": "Choose on which action you want to be notified",
"options": {
"ASSIGN_APPROVER": "When I am assigned to a document as Approver",
"ASSIGN_APPROVER": "When I am assigned to a document",
"ASSIGN_REVIEWER": "When I am assigned to a document as Reviewer",
"DOCUMENT_APPROVED": "When the document status changes to Approved (only for dossier owners)",
"DOCUMENT_APPROVED": "When the document status changes to Done (only for dossier owners)",
"DOCUMENT_UNDER_APPROVAL": "When the document status changes to Under Approval",
"DOCUMENT_UNDER_REVIEW": "When the document status changes to In Progress",
"DOSSIER_DELETED": "When a dossier was deleted",