OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Rewrite settings page into reactive forms
Oliver Günther76e3e0d12848
diff --git a/app/services/notifications/create_from_model_service/news_strategy.rb b/app/services/notifications/create_from_model_service/news_strategy.rbindex 069d6bd359b..aaca877f991 100644--- a/app/services/notifications/create_from_model_service/news_strategy.rb+++ b/app/services/notifications/create_from_model_service/news_strategy.rb@@ -62,7 +62,6 @@ module Notifications::CreateFromModelService::NewsStrategyNotificationSetting::NEWS_ADDEDend-def self.project(journal)journal.data.projectenddiff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.tsindex c273adb60cc..6ce86a8c2c7 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts@@ -155,7 +155,9 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implpublic saveChanges():void {const prefs = this.storeService.store.getValue();const notificationSettings = (this.form.value as IFullNotificationSettingsValue);+ const globalNotification = prefs.notifications.find((notification) => !notification._links.project.href) as NotificationSetting;const globalPrefs:NotificationSetting = {+ ...globalNotification,_links: { project: { href: null } },channel: 'in_app',watched: true,@@ -181,6 +183,14 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implworkPackagePrioritized: settings.workPackagePrioritized,workPackageCommented: settings.workPackageCommented,all: false,+ newsAdded: false,+ newsCommented: false,+ documentAdded: false,+ forumMessages: false,+ wikiPageAdded: false,+ wikiPageUpdated: false,+ membershipAdded: false,+ membershipUpdated: false,}));this.storeService.update(this.userId, {diff --git a/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.html b/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.htmlindex 8b2e282f7eb..efe3f7d4e9b 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.html+++ b/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.html@@ -1,16 +1,14 @@-<ng-container- *ngIf="(globalNotification$ | async) as notification">+<ng-container [formGroup]="form"><div *ngFor="let setting of alerts">- <!-- TODO: use checkbox component for the enabled input -->- <input- [ngModel]="notification[setting]"- (ngModelChange)="toggleEnabled(setting, $event)"- type="checkbox"- id="op-alert-settings-{{ setting }}"+ <op-checkbox-field+ [control]="form.get(setting)">- <label- for="op-alert-settings-{{ setting }}"- [textContent]="text[setting]">- </label>+ <input+ slot="input"+ type="checkbox"+ [formControlName]="setting"+ />+ <p slot="description">{{ text[setting] }}</p>+ </op-checkbox-field></div></ng-container>diff --git a/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.tsindex 55daa5d2b37..0d31e1e7ff9 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.ts+++ b/frontend/src/app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component.ts@@ -1,30 +1,39 @@import {ChangeDetectionStrategy,Component,+ OnInit,} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';-import { NotificationSetting } from 'core-app/features/user-preferences/state/notification-setting.model';-import { arrayUpdate } from '@datorama/akita';+import {+ FormGroup,+ FormGroupDirective,+} from '@angular/forms';++export type EmailAlertType =+ 'newsAdded'|'newsCommented'|'documentAdded'|'forumMessages'|'wikiPageAdded'|+ 'wikiPageUpdated'|'membershipAdded'|'membershipUpdated';++export const emailAlerts:EmailAlertType[] = [+ 'newsAdded',+ 'newsCommented',+ 'documentAdded',+ 'forumMessages',+ 'wikiPageAdded',+ 'wikiPageUpdated',+ 'membershipAdded',+ 'membershipUpdated',+];@Component({selector: 'op-email-alerts-settings',templateUrl: './email-alerts-settings.component.html',changeDetection: ChangeDetectionStrategy.OnPush,})-export class EmailAlertsSettingsComponent {- globalNotification$ = this.storeService.query.globalNotification$;+export class EmailAlertsSettingsComponent implements OnInit {+ form:FormGroup;- alerts = [- 'newsAdded',- 'newsCommented',- 'documentAdded',- 'forumMessages',- 'wikiPageAdded',- 'wikiPageUpdated',- 'membershipAdded',- 'membershipUpdated',- ];+ alerts:EmailAlertType[] = emailAlerts;text = {newsAdded: this.I18n.t('js.reminders.settings.alerts.news_added'),@@ -40,19 +49,11 @@ export class EmailAlertsSettingsComponent {constructor(private I18n:I18nService,private storeService:UserPreferencesService,+ private rootFormGroup:FormGroupDirective,) {}- toggleEnabled(key:string, enabled:boolean):void {- const delta = { [key]: enabled };- this.storeService.store.update(- ({ notifications }) => ({- notifications: arrayUpdate(- notifications,- (notification:NotificationSetting) => !notification._links.project.href,- delta,- ),- }),- );+ ngOnInit():void {+ this.form = this.rootFormGroup.control.get('emailAlerts') as FormGroup;}}diff --git a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.htmlindex ad7e1e2a571..2071588ab19 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html+++ b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.html@@ -1,14 +1,13 @@-<ng-container- *ngIf="(immediateReminders$ | async) as immediateReminders">- <!-- TODO: use checkbox component for the enabled input -->- <input- [ngModel]="immediateReminders.mentioned"- (ngModelChange)="toggleEnabled('mentioned', $event)"- type="checkbox"- id="op-reminder-settings-immediate-mentioned"- >- <label- for="op-reminder-settings-immediate-mentioned"- [textContent]="text.mentioned">- </label>-</ng-container>\ No newline at end of file+<ng-container [formGroup]="form">+ <op-checkbox-field+ [control]="form.get('mentioned')"+ >+ <input+ slot="input"+ type="checkbox"+ formControlName="mentioned"+ data-qa-immediate-reminder="mentioned"+ />+ <p slot="description">{{ text.mentioned }}</p>+ </op-checkbox-field>+</ng-container>diff --git a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.tsindex b528e2c305d..395716ef987 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts+++ b/frontend/src/app/features/user-preferences/reminder-settings/immediate-reminders/immediate-reminder-settings.component.ts@@ -1,18 +1,22 @@import {ChangeDetectionStrategy,Component,+ OnInit,} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';-import { ImmediateRemindersSettings } from 'core-app/features/user-preferences/state/user-preferences.model';+import {+ FormGroup,+ FormGroupDirective,+} from '@angular/forms';@Component({selector: 'op-immediate-reminder-settings',templateUrl: './immediate-reminder-settings.component.html',changeDetection: ChangeDetectionStrategy.OnPush,})-export class ImmediateReminderSettingsComponent {- immediateReminders$ = this.storeService.query.select('immediateReminders');+export class ImmediateReminderSettingsComponent implements OnInit {+ form:FormGroup;text = {mentioned: this.I18n.t('js.reminders.settings.immediate.mentioned'),@@ -21,17 +25,11 @@ export class ImmediateReminderSettingsComponent {constructor(private I18n:I18nService,private storeService:UserPreferencesService,+ private rootFormGroup:FormGroupDirective,) {}- toggleEnabled(key:keyof ImmediateRemindersSettings, enabled:boolean):void {- this.storeService.store.update(({ immediateReminders }) => (- {- immediateReminders: {- ...immediateReminders,- [key]: enabled,- },- }- ));+ ngOnInit():void {+ this.form = this.rootFormGroup.control.get('immediateReminders') as FormGroup;}}diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.htmlindex d3e0c591aca..57b2af17617 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html+++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.html@@ -1,28 +1,33 @@<div class="title-container">- <h2 [textContent]="text.title"></h2>+ <h2 [textContent]="text.title"></h2></div>-<form>- <section class="form--section">- <h5 [textContent]="text.immediate.title"></h5>- <op-immediate-reminder-settings></op-immediate-reminder-settings>- </section>- <section class="form--section">- <h5 [textContent]="text.daily.title"></h5>- <p [textContent]="text.daily.explanation"></p>+<form+ [formGroup]="form"+ (ngSubmit)="saveChanges()"+ class="op-form"+>+ <section class="form--section">+ <h5 [textContent]="text.immediate.title"></h5>+ <op-immediate-reminder-settings></op-immediate-reminder-settings>+ </section>+ <section class="form--section">+ <h5 [textContent]="text.daily.title"></h5>+ <p [textContent]="text.daily.explanation"></p>- <op-reminder-settings-daily-time>- </op-reminder-settings-daily-time>- </section>- <section class="form--section">- <h5 [textContent]="text.alerts.title"></h5>- <p [textContent]="text.alerts.explanation"></p>- <op-email-alerts-settings></op-email-alerts-settings>- </section>- <button- class="button -highlight"- [textContent]="text.save"- (click)="saveChanges()"- >- </button>+ <op-reminder-settings-daily-time>+ </op-reminder-settings-daily-time>+ </section>+ <section class="form--section">+ <h5 [textContent]="text.alerts.title"></h5>+ <p [textContent]="text.alerts.explanation"></p>+ <op-email-alerts-settings></op-email-alerts-settings>+ </section>+ <div class="generic-table--action-buttons">+ <button+ class="button -highlight"+ [textContent]="text.save"+ type="submit"+ ></button>+ </div></form>diff --git a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.tsindex 420bab27581..003bf520ab3 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts+++ b/frontend/src/app/features/user-preferences/reminder-settings/page/reminder-settings-page.component.ts@@ -1,5 +1,6 @@import {ChangeDetectionStrategy,+ ChangeDetectorRef,Component,Input,OnInit,@@ -9,18 +10,61 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.servimport { take } from 'rxjs/internal/operators/take';import { UIRouterGlobals } from '@uirouter/core';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';+import {+ FormArray,+ FormBuilder,+} from '@angular/forms';+import {+ DailyRemindersSettings,+ ImmediateRemindersSettings,+} from 'core-app/features/user-preferences/state/user-preferences.model';+import {+ emailAlerts,+ EmailAlertType,+} from 'core-app/features/user-preferences/reminder-settings/email-alerts/email-alerts-settings.component';+import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+import {+ filter,+ withLatestFrom,+} from 'rxjs/operators';export const myReminderPageComponentSelector = 'op-reminders-page';+interface IReminderSettingsFormValue {+ immediateReminders:ImmediateRemindersSettings,+ dailyReminders:DailyRemindersSettings,+ emailAlerts:Record<EmailAlertType, boolean>;+}+@Component({selector: myReminderPageComponentSelector,templateUrl: './reminder-settings-page.component.html',styleUrls: ['./reminder-settings-page.component.sass'],changeDetection: ChangeDetectionStrategy.OnPush,})-export class ReminderSettingsPageComponent implements OnInit {+export class ReminderSettingsPageComponent extends UntilDestroyedMixin implements OnInit {@Input() userId:string;+ public form = this.fb.group({+ immediateReminders: this.fb.group({+ mentioned: this.fb.control(false),+ }),+ dailyReminders: this.fb.group({+ enabled: this.fb.control(false),+ times: this.fb.array([]),+ }),+ emailAlerts: this.fb.group({+ newsAdded: this.fb.control(false),+ newsCommented: this.fb.control(false),+ documentAdded: this.fb.control(false),+ forumMessages: this.fb.control(false),+ wikiPageAdded: this.fb.control(false),+ wikiPageUpdated: this.fb.control(false),+ membershipAdded: this.fb.control(false),+ membershipUpdated: this.fb.control(false),+ }),+ });+text = {title: this.I18n.t('js.reminders.settings.title'),save: this.I18n.t('js.button_save'),@@ -43,7 +87,10 @@ export class ReminderSettingsPageComponent implements OnInit {private storeService:UserPreferencesService,private currentUserService:CurrentUserService,private uiRouterGlobals:UIRouterGlobals,+ private fb:FormBuilder,+ private cdRef:ChangeDetectorRef,) {+ super();}ngOnInit():void {@@ -56,10 +103,52 @@ export class ReminderSettingsPageComponent implements OnInit {this.userId = this.userId || user?.id as string;this.storeService.get(this.userId);});++ this.storeService.query.select()+ .pipe(+ filter((settings) => !!settings),+ withLatestFrom(this.storeService.query.globalNotification$),+ )+ .subscribe(([settings, globalSetting]) => {+ this.form.get('immediateReminders.mentioned')?.setValue(settings.immediateReminders.mentioned);++ this.form.get('dailyReminders.enabled')?.setValue(settings.dailyReminders.enabled);++ const dailyReminderTimes = this.form.get('dailyReminders.times') as FormArray;+ dailyReminderTimes.clear({ emitEvent: false });+ settings.dailyReminders.times.forEach((time) => {+ dailyReminderTimes.push(this.fb.control(time), { emitEvent: false });+ });++ dailyReminderTimes.enable({ emitEvent: true });++ emailAlerts.forEach((alert) => {+ this.form.get(`emailAlerts.${alert}`)?.setValue(globalSetting[alert]);+ });++ this.cdRef.detectChanges();+ });}public saveChanges():void {const prefs = this.storeService.query.getValue();- this.storeService.update(this.userId, prefs);+ const globalNotifications = prefs.notifications.filter((notification) => !notification._links.project.href);+ const projectNotifications = prefs.notifications.filter((notification) => !!notification._links.project.href);+ const reminderSettings = (this.form.value as IReminderSettingsFormValue);++ this.storeService.update(this.userId, {+ ...prefs,+ dailyReminders: reminderSettings.dailyReminders,+ immediateReminders: reminderSettings.immediateReminders,+ notifications: [+ ...globalNotifications.map((notification) => (+ {+ ...notification,+ ...reminderSettings.emailAlerts,+ }+ )),+ ...projectNotifications,+ ],+ });}}diff --git a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.htmlindex 82afd6fc268..27ad7a0ce92 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html+++ b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.html@@ -1,26 +1,27 @@-<ng-container- *ngIf="(dailyReminders$ | async) && (selectedTimes$ | async) as selectedTimes">- <!-- TODO: use checkbox component for the enabled input -->- <div- class="op-reminder-settings-daily-time--enable">+<ng-container *ngIf="(selectedTimes$ | async) as selectedTimes"+ [formGroup]="form"+>+ <op-checkbox-field+ [control]="form.get('enabled')"+ ><input- [ngModel]="enabled$ | async"- (ngModelChange)="toggleEnabled($event)"- type="checkbox"- id="op-reminder-settings-daily-time--enable">- <label- for="op-reminder-settings-daily-time--enable"- [textContent]="text.enable">- </label>- </div>+ slot="input"+ type="checkbox"+ formControlName="enabled"+ />+ <p slot="description">{{ text.enable }}</p>+ </op-checkbox-field><div *ngFor="let time of selectedTimes; index as i; trackBy: index"class="op-reminder-settings-daily-time--row">+<input+ *ngIf="(activeTimes$ | async) as activeTimes"type="checkbox"[ngModel]="isActive(time)"(ngModelChange)="toggleActive($event, i, selectedTimes)"- [disabled]="(activeTimes$ | async).length === 0 || (activeTimes$ | async).length === 1 && (activeTimes$ | async)[0] === time"+ [ngModelOptions]="{standalone: true}"+ [disabled]="activeTimes.length === 0 || activeTimes.length === 1 && activeTimes[0] === time"class="op-reminder-settings-daily-time--active"attr.data-qa-selector="op-settings-daily-time--active-{{i + 1}}"><label@@ -31,6 +32,7 @@<select[ngModel]="time"(ngModelChange)="changeTime($event, selectedTimes, i)"+ [ngModelOptions]="{standalone: true}"[disabled]="(enabled$ | async) === false"class="op-reminder-settings-daily-time--time form--select -narrow"attr.id="op-reminder-settings-daily-time-{{i + 1}}--time"@@ -54,9 +56,10 @@<buttonclass="button op-reminder-settings-daily-time--add"+ type="button"[disabled]="nonAddable$ | async"(click)="addTime(selectedTimes)"><i class="button--icon icon-add"></i><span class="button--text">{{text.addTime}}</span></button>-</ng-container>\ No newline at end of file+</ng-container>diff --git a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.tsindex 5dcbda63ba0..cf144838a20 100644--- a/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts+++ b/frontend/src/app/features/user-preferences/reminder-settings/reminder-time/reminder-settings-daily-time.component.ts@@ -1,14 +1,25 @@import {ChangeDetectionStrategy,Component,+ OnInit,} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import {map,- skip,+ shareReplay,} from 'rxjs/operators';-import { combineLatest } from 'rxjs';+import {+ combineLatest,+ NEVER,+ Observable,+} from 'rxjs';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';+import {+ FormArray,+ FormControl,+ FormGroup,+ FormGroupDirective,+} from '@angular/forms';@Component({selector: 'op-reminder-settings-daily-time',@@ -16,7 +27,7 @@ import { UserPreferencesService } from 'core-app/features/user-preferences/statestyleUrls: ['./reminder-settings-daily-time.component.sass'],changeDetection: ChangeDetectionStrategy.OnPush,})-export class ReminderSettingsDailyTimeComponent {+export class ReminderSettingsDailyTimeComponent implements OnInit {// All times that are available in a day with a 1 hour gap between each.// ['00:00', '01:00', ..., '24:00']public availableTimes:string[] = ReminderSettingsDailyTimeComponent.setupAvailableTimes();@@ -28,54 +39,28 @@ export class ReminderSettingsDailyTimeComponent {// Upon a reload of the page, it is accepted to loose this information.public inactiveTimes:Array<{ position:number, time:string }> = [];+ public form:FormGroup;+// Hours suggested if a new time is added by a user.public suggestedTimes = ['08:00', '12:00', '15:00', '18:00'];- // The daily reminders with the first value skipped. Only used- // for that skipping as the first value is produced by the front end (default value).- public dailyReminders$ = this.storeService.query.dailyReminders$.pipe(skip(1));-// Whether the reminder are active at all.- public enabled$ = this.storeService.query.dailyRemindersEnabled$;+ public enabled$:Observable<boolean>;// The active times as present in the store interleaved with the inactive// times.- public selectedTimes$ = this- .storeService- .query- .dailyRemindersTimes$- .pipe(map((times) => {- const activeTimes = Array(...times);-- this- .inactiveTimes- .sort((a, b) => a.position - b.position)- .forEach((inactiveTime) => {- activeTimes.splice(inactiveTime.position, 0, inactiveTime.time);- });-- return activeTimes;- }));+ public selectedTimes$:Observable<string[]> = NEVER;// Times that are truly active:// * the reminders are not disabled completely// * the times are not inactive individually.- public activeTimes$ = combineLatest([- this.storeService.query.dailyRemindersEnabled$,- this.storeService.query.dailyRemindersTimes$,- ]).pipe(map(([enabled, times]) => (enabled ? times : [])));+ public activeTimes$:Observable<string[]> = NEVER;// Times can only be removed if the element is active and if there is more than one time present.- public timeRemovable$ = combineLatest([- this.storeService.query.dailyRemindersEnabled$,- this.selectedTimes$,- ]).pipe(map(([enabled, selectedTimes]) => enabled && selectedTimes.length > 1));+ public timeRemovable$:Observable<boolean> = NEVER;// Times can not be added if the element is disabled or if all the possible times have already been added (active or not).- public nonAddable$ = combineLatest([- this.storeService.query.dailyRemindersEnabled$,- this.selectedTimes$,- ]).pipe(map(([enabled, selectedTimes]) => !enabled || selectedTimes.length === this.availableTimes.length));+ public nonAddable$:Observable<boolean> = NEVER;text = {timeLabel: (counter:number):string => this.I18n.t('js.reminders.settings.daily.time_label', { counter }),@@ -86,7 +71,59 @@ export class ReminderSettingsDailyTimeComponent {constructor(private I18n:I18nService,private storeService:UserPreferencesService,- ) { }+ private rootFormGroup:FormGroupDirective,+ ) {+ }++ ngOnInit():void {+ this.form = this.rootFormGroup.control.get('dailyReminders') as FormGroup;++ this.enabled$ = this+ .form+ .valueChanges+ .pipe(+ map(() => this.form.get('enabled')?.value as boolean),+ shareReplay(1),+ );++ this.selectedTimes$ = (this+ .form+ .get('times') as FormArray)+ .valueChanges+ .pipe(+ map(() => {+ const timesArray = this.form.get('times') as FormArray;+ const activeTimes = timesArray.controls.map((c) => c.value as string);++ this+ .inactiveTimes+ .sort((a, b) => a.position - b.position)+ .forEach((inactiveTime) => {+ activeTimes.splice(inactiveTime.position, 0, inactiveTime.time);+ });++ return activeTimes;+ }),+ shareReplay(1),+ );++ this.timeRemovable$ = combineLatest([+ this.enabled$,+ this.selectedTimes$,+ ]).pipe(map(([enabled, selectedTimes]) => enabled && selectedTimes.length > 1));++ this.nonAddable$ = combineLatest([+ this.enabled$,+ this.selectedTimes$,+ ]).pipe(map(([enabled, selectedTimes]) => !enabled || selectedTimes.length === this.availableTimes.length));++ this.activeTimes$ = combineLatest([+ this.enabled$,+ this.selectedTimes$,+ ]).pipe(+ map(([enabled, times]) => (enabled ? times : [])),+ );+ }addTime(selectedTimes:string[]):void {const time = this.firstAvailableSuggested(selectedTimes) || this.firstAfterSelected(selectedTimes);@@ -133,17 +170,6 @@ export class ReminderSettingsDailyTimeComponent {this.storeTimes(selectedTimes);}- toggleEnabled(enabled:boolean):void {- this.storeService.store.update(({ dailyReminders }) => (- {- dailyReminders: {- ...dailyReminders,- enabled,- },- }- ));- }-toggleActive(active:boolean, index:number, selectedTimes:string[]):void {if (!active) {this.inactiveTimes.push({ position: index, time: selectedTimes[index] });@@ -164,13 +190,20 @@ export class ReminderSettingsDailyTimeComponent {}private storeTimes(selectedTimes:string[]) {- this.storeService.store.update(({ dailyReminders }) => (- {- dailyReminders: {- ...dailyReminders,- times: selectedTimes.filter((selected) => !this.inactiveTimes.map((inactive) => inactive.time).includes(selected)), // .map((selected) => selected.time),- },- }));+ const times = selectedTimes+ .filter(+ (selected) => !this.inactiveTimes+ .map((inactive) => inactive.time)+ .includes(selected),+ );++ const timesForm = this.form.get('times') as FormArray;+ timesForm.clear({ emitEvent: false });+ times.forEach((time) => {+ timesForm.push(new FormControl(time), { emitEvent: false });+ });++ timesForm.enable({ emitEvent: true });}private firstAvailableSuggested(selectedTimes:string[]) {diff --git a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts b/frontend/src/app/features/user-preferences/state/notification-setting.model.tsindex 6d5b6cb4981..96020dd6cb2 100644--- a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts+++ b/frontend/src/app/features/user-preferences/state/notification-setting.model.ts@@ -13,6 +13,14 @@ export interface NotificationSetting {workPackageProcessed:boolean;workPackagePrioritized:boolean;workPackageScheduled:boolean;+ newsAdded:boolean;+ newsCommented:boolean;+ documentAdded:boolean;+ forumMessages:boolean;+ wikiPageAdded:boolean;+ wikiPageUpdated:boolean;+ membershipAdded:boolean;+ membershipUpdated:boolean;all:boolean;}@@ -32,6 +40,14 @@ export function buildNotificationSetting(project:null|HalSourceLink, params:PartworkPackageProcessed: true,workPackagePrioritized: true,workPackageScheduled: true,+ newsAdded: true,+ newsCommented: true,+ documentAdded: true,+ forumMessages: true,+ wikiPageAdded: true,+ wikiPageUpdated: true,+ membershipAdded: true,+ membershipUpdated: true,all: false,channel: 'in_app',...params,diff --git a/frontend/src/app/features/user-preferences/state/user-preferences.query.ts b/frontend/src/app/features/user-preferences/state/user-preferences.query.tsindex 0a4c2ddc61a..4243ad5c25a 100644--- a/frontend/src/app/features/user-preferences/state/user-preferences.query.ts+++ b/frontend/src/app/features/user-preferences/state/user-preferences.query.ts@@ -38,7 +38,7 @@ export class UserPreferencesQuery extends Query<UserPreferencesModel> {.pipe(map((settings) => settings.find((notification) => !notification._links.project.href)),filter((global) => !!global),- );+ ) as Observable<NotificationSetting>;/** Selected projects */selectedProjects$ = thisdiff --git a/spec/services/user_preferences/update_service_integration_spec.rb b/spec/services/user_preferences/update_service_integration_spec.rbindex 9412500ecc0..ede42f39d22 100644--- a/spec/services/user_preferences/update_service_integration_spec.rb+++ b/spec/services/user_preferences/update_service_integration_spec.rb@@ -77,15 +77,14 @@ describe UserPreferences::UpdateService, 'integration', type: :model dodefault_mail = current_user.notification_settings.find_by(channel: 'mail')default_ian = current_user.notification_settings.find_by(channel: 'in_app')- expect(default_ian.all).to eq trueexpect(default_ian.watched).to eq trueexpect(default_ian.mentioned).to eq trueexpect(default_ian.involved).to eq true- expect(default_ian.work_package_commented).to eq false- expect(default_ian.work_package_created).to eq false- expect(default_ian.work_package_processed).to eq false- expect(default_ian.work_package_prioritized).to eq false- expect(default_ian.work_package_scheduled).to eq false+ expect(default_ian.work_package_commented).to eq true+ expect(default_ian.work_package_created).to eq true+ expect(default_ian.work_package_processed).to eq true+ expect(default_ian.work_package_prioritized).to eq true+ expect(default_ian.work_package_scheduled).to eq trueexpect(subject.count).to eq 1expect(subject.first.project_id).to eq nildiff --git a/spec/support/pages/reminders/settings.rb b/spec/support/pages/reminders/settings.rbindex d9762a303fa..d47042a4f7a 100644--- a/spec/support/pages/reminders/settings.rb+++ b/spec/support/pages/reminders/settings.rb@@ -77,7 +77,7 @@ module Pagesenddef set_immediate_reminder(name, enabled)- field = page.find_field("op-reminder-settings-immediate-#{name}")+ field = page.find("input[data-qa-immediate-reminder='#{name}']")if enabledfield.check