DM-340, change notification texts, hide rss specifics.
This commit is contained in:
parent
199d2ec0a2
commit
2a2cf3047a
@ -13,7 +13,7 @@
|
|||||||
<div *ngFor="let key of notificationGroupsKeys; let i = index" class="group">
|
<div *ngFor="let key of notificationGroupsKeys; let i = index" class="group">
|
||||||
<div [translate]="translations[key]" class="group-title"></div>
|
<div [translate]="translations[key]" class="group-title"></div>
|
||||||
<div class="iqser-input-group">
|
<div class="iqser-input-group">
|
||||||
<ng-container *ngFor="let preference of notificationGroupsValues[i]">
|
<ng-container *ngFor="let preference of getRssFilteredSettings(notificationGroupsValues[i])">
|
||||||
<mat-checkbox
|
<mat-checkbox
|
||||||
*ngIf="!skipPreference(preference)"
|
*ngIf="!skipPreference(preference)"
|
||||||
(change)="addRemovePreference($event.checked, category, preference)"
|
(change)="addRemovePreference($event.checked, category, preference)"
|
||||||
|
|||||||
@ -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 { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||||
import { NotificationPreferencesService } from '../../../services/notification-preferences.service';
|
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 { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import {
|
import {
|
||||||
NotificationCategoriesValues,
|
NotificationCategoriesValues,
|
||||||
@ -13,6 +13,9 @@ import {
|
|||||||
import { firstValueFrom } from 'rxjs';
|
import { firstValueFrom } from 'rxjs';
|
||||||
import { notificationsSettingsTranslations } from '@translations/notifications-settings-translations';
|
import { notificationsSettingsTranslations } from '@translations/notifications-settings-translations';
|
||||||
import { getCurrentUser } from '@iqser/common-ui/lib/users';
|
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({
|
@Component({
|
||||||
templateUrl: './notifications-screen.component.html',
|
templateUrl: './notifications-screen.component.html',
|
||||||
@ -26,18 +29,24 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
|
|||||||
readonly translations = notificationsSettingsTranslations;
|
readonly translations = notificationsSettingsTranslations;
|
||||||
readonly currentUser = getCurrentUser<User>();
|
readonly currentUser = getCurrentUser<User>();
|
||||||
|
|
||||||
constructor(
|
readonly #toaster = inject(Toaster);
|
||||||
private readonly _toaster: Toaster,
|
readonly #formBuilder = inject(UntypedFormBuilder);
|
||||||
private readonly _formBuilder: UntypedFormBuilder,
|
readonly #loadingService = inject(LoadingService);
|
||||||
private readonly _loadingService: LoadingService,
|
readonly #notificationPreferencesService = inject(NotificationPreferencesService);
|
||||||
private readonly _notificationPreferencesService: NotificationPreferencesService,
|
readonly #cdRef = inject(ChangeDetectorRef);
|
||||||
private readonly _changeRef: ChangeDetectorRef,
|
readonly #iqserPermissionsService = inject(IqserPermissionsService);
|
||||||
) {
|
readonly #isRss = this.#iqserPermissionsService.has(Roles.getRss);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
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) {
|
isCategoryActive(category: string) {
|
||||||
@ -66,19 +75,19 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save() {
|
async save() {
|
||||||
this._loadingService.start();
|
this.#loadingService.start();
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this._notificationPreferencesService.update(this.form.value));
|
await firstValueFrom(this.#notificationPreferencesService.update(this.form.value));
|
||||||
} catch (e) {
|
} 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.initialFormValue = JSON.parse(JSON.stringify(this.form.getRawValue()));
|
||||||
this._changeRef.markForCheck();
|
this.#cdRef.markForCheck();
|
||||||
this._loadingService.stop();
|
this.#loadingService.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getForm(): UntypedFormGroup {
|
#getForm(): UntypedFormGroup {
|
||||||
return this._formBuilder.group({
|
return this.#formBuilder.group({
|
||||||
inAppNotificationsEnabled: [undefined],
|
inAppNotificationsEnabled: [undefined],
|
||||||
emailNotificationsEnabled: [undefined],
|
emailNotificationsEnabled: [undefined],
|
||||||
emailNotificationType: [undefined],
|
emailNotificationType: [undefined],
|
||||||
@ -87,14 +96,14 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _initializeForm() {
|
async #initializeForm() {
|
||||||
this._loadingService.start();
|
this.#loadingService.start();
|
||||||
|
|
||||||
this.form = this._getForm();
|
this.form = this.#getForm();
|
||||||
const notificationPreferences = await firstValueFrom(this._notificationPreferencesService.get());
|
const notificationPreferences = await firstValueFrom(this.#notificationPreferencesService.get());
|
||||||
this.form.patchValue(notificationPreferences);
|
this.form.patchValue(notificationPreferences);
|
||||||
this.initialFormValue = JSON.parse(JSON.stringify(this.form.getRawValue()));
|
this.initialFormValue = JSON.parse(JSON.stringify(this.form.getRawValue()));
|
||||||
|
|
||||||
this._loadingService.stop();
|
this.#loadingService.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1717,9 +1717,9 @@
|
|||||||
"minutes": "minutes",
|
"minutes": "minutes",
|
||||||
"no-active-license": "Invalid or corrupt license – Please contact your administrator",
|
"no-active-license": "Invalid or corrupt license – Please contact your administrator",
|
||||||
"notification": {
|
"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>!",
|
"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-deleted": "Dossier: <b>{dossierName}</b> has been deleted!",
|
||||||
"dossier-owner-deleted": "The owner of 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>!",
|
"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-title": "Choose on which action you want to be notified",
|
||||||
"options": {
|
"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",
|
"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_APPROVAL": "When the document status changes to Under Approval",
|
||||||
"DOCUMENT_UNDER_REVIEW": "When the document status changes to In Progress",
|
"DOCUMENT_UNDER_REVIEW": "When the document status changes to In Progress",
|
||||||
"DOSSIER_DELETED": "When a dossier was deleted",
|
"DOSSIER_DELETED": "When a dossier was deleted",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user