DM-370: Fixed assign notifications not showing.

This commit is contained in:
Nicoleta Panaghiu 2023-09-07 16:16:21 +03:00
parent b4892afff5
commit 96c16f3832

View File

@ -4,6 +4,7 @@ import { NotificationPreferencesService } from '../../../services/notification-p
import { BaseFormComponent, getConfig, LoadingService, Toaster } from '@iqser/common-ui'; import { BaseFormComponent, getConfig, 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 {
DocumentNotificationsTypes,
NotificationCategoriesValues, NotificationCategoriesValues,
NotificationGroupsKeys, NotificationGroupsKeys,
NotificationGroupsValues, NotificationGroupsValues,
@ -77,15 +78,7 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
async save() { async save() {
this.#loadingService.start(); this.#loadingService.start();
try { try {
const preferences = const preferences = this.#filterNotificationPreferences();
!this.isPreferenceChecked('inAppNotifications', 'ASSIGN_APPROVER') && this.#config.IS_DOCUMINE
? {
...this.form.value,
inAppNotifications: this.form
.get('inAppNotifications')
.value.filter((preference: string) => !RSS_EXCLUDED_SETTINGS.includes(preference)),
}
: this.form.value;
await firstValueFrom(this.#notificationPreferencesService.update(preferences)); await firstValueFrom(this.#notificationPreferencesService.update(preferences));
} catch (e) { } catch (e) {
this.#toaster.error(_('notifications-screen.error.generic')); this.#toaster.error(_('notifications-screen.error.generic'));
@ -115,4 +108,27 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
this.#loadingService.stop(); this.#loadingService.stop();
} }
#filterNotificationPreferences() {
if (!this.#config.IS_DOCUMINE) {
return this.form.value;
}
if (!this.isPreferenceChecked('inAppNotifications', DocumentNotificationsTypes.assignApprover)) {
return {
...this.form.value,
inAppNotifications: this.form
.get('inAppNotifications')
.value.filter((preference: string) => !RSS_EXCLUDED_SETTINGS.includes(preference)),
};
}
if (!this.form.get('inAppNotifications').value.includes(DocumentNotificationsTypes.assignReviewer)) {
return {
...this.form.value,
inAppNotifications: [...this.form.get('inAppNotifications').value, DocumentNotificationsTypes.assignReviewer],
};
}
return this.form.value;
}
} }