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
Add reminder notification settings to projects
Benjamin Bädorff8875a58ac2c
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 95c0b9bb102..9fcaaf32326 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -627,6 +627,18 @@ en:change_notification_settings: 'To view and change your notification settings, <a target="_blank" href="%{url}">click here</a>'title: "Notification settings"notify_me: "Notify me"+ reminders:+ no_notification: No notification+ timeframes:+ normal:+ PT0S: Same day+ P1D: 1 day before+ P3D: 3 days before+ P7D: a week before+ overdue:+ PT0S: everyday+ P3D: every 3 days+ P7D: every weekreasons:mentioned:title: 'Mentioned'diff --git a/frontend/src/app/features/user-preferences/notifications-settings/overdue-reminder-available-times.ts b/frontend/src/app/features/user-preferences/notifications-settings/overdue-reminder-available-times.tsnew file mode 100644index 00000000000..642a24765fb--- /dev/null+++ b/frontend/src/app/features/user-preferences/notifications-settings/overdue-reminder-available-times.ts@@ -0,0 +1,33 @@+export const REMINDER_AVAILABLE_TIMEFRAMES:{ value:string, title:string }[] = [+ {+ value: 'PT0S',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.normal.PT0S'),+ },+ {+ value: 'P1D',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.normal.P1D'),+ },+ {+ value: 'P3D',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.normal.P3D'),+ },+ {+ value: 'P7D',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.normal.P7D'),+ },+];++export const OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES:{ value:string, title:string }[] = [+ {+ value: 'PT0S',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.overdue.PT0S'),+ },+ {+ value: 'P3D',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.overdue.P3D'),+ },+ {+ value: 'P7D',+ title: window.I18n.t('js.notifications.settings.reminders.timeframes.overdue.P7D'),+ },+];diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.htmlindex af8cdcc65f4..8f6ac0f4d4f 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html@@ -77,9 +77,9 @@><option*ngFor="let availableTime of availableTimes"- [value]="availableTime"+ [value]="availableTime.value">- {{availableTime}}+ {{availableTime.title}}</option></select></div>@@ -107,8 +107,8 @@><option*ngFor="let availableTime of availableTimes"- [value]="availableTime">- {{availableTime}}+ [value]="availableTime.value">+ {{availableTime.title}}</option></select></div>@@ -135,8 +135,8 @@><option*ngFor="let availableTime of availableTimesOverdue"- [value]="availableTime">- {{availableTime}}+ [value]="availableTime.value">+ {{availableTime.title}}</option></select></div>diff --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 a1073090dfa..70b10d84379 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@@ -17,6 +17,7 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.servimport { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';import { INotificationSetting } from 'core-app/features/user-preferences/state/notification-setting.model';+import { OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES, REMINDER_AVAILABLE_TIMEFRAMES } from '../overdue-reminder-available-times';export const myNotificationsPageComponentSelector = 'op-notifications-page';@@ -28,6 +29,9 @@ interface IToastSettingsValue {workPackageScheduled:boolean;workPackagePrioritized:boolean;workPackageCommented:boolean;+ startDate:string|null;+ dueDate:string|null;+ overdue:string|null;}interface IProjectNotificationSettingsValue extends IToastSettingsValue {@@ -50,8 +54,8 @@ interface IFullNotificationSettingsValue extends IToastSettingsValue {export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implements OnInit {@Input() userId:string;- public availableTimes:string[] = ['PT0S', 'P1D', 'P3D', 'P7D'];- public availableTimesOverdue:string[] = ['PT0S', 'P3D', 'P7D'];+ public availableTimes = REMINDER_AVAILABLE_TIMEFRAMES;+ public availableTimesOverdue = OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES;public form = new FormGroup({assignee: new FormControl(false),@@ -176,13 +180,13 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implthis.form.get('workPackageCommented')?.setValue(settings.workPackageCommented);this.form.get('startDate.active')?.setValue(!!settings.startDate);- this.form.get('startDate.time')?.setValue(settings.startDate || this.availableTimes[1]);+ this.form.get('startDate.time')?.setValue(settings.startDate || this.availableTimes[1].value);this.form.get('dueDate.active')?.setValue(!!settings.dueDate);- this.form.get('dueDate.time')?.setValue(settings.dueDate || this.availableTimes[1]);+ this.form.get('dueDate.time')?.setValue(settings.dueDate || this.availableTimes[1].value);this.form.get('overdue.active')?.setValue(!!settings.overdue);- this.form.get('overdue.time')?.setValue(settings.overdue || this.availableTimesOverdue[0]);+ this.form.get('overdue.time')?.setValue(settings.overdue || this.availableTimesOverdue[0].value);this.form.enable();});@@ -209,6 +213,9 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implworkPackageScheduled: new FormControl(setting.workPackageScheduled),workPackagePrioritized: new FormControl(setting.workPackagePrioritized),workPackageCommented: new FormControl(setting.workPackageCommented),+ startDate: new FormControl(setting.startDate),+ dueDate: new FormControl(setting.dueDate),+ overdue: new FormControl(setting.overdue),})));this.form.setControl('projectSettings', projectSettings);@@ -266,9 +273,12 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implwikiPageUpdated: false,membershipAdded: false,membershipUpdated: false,- startDate: 'P1D',- dueDate: 'P1D',- overdue: null,++ // Angular cannot handle null values in select options. It will only return string values.+ // In fact, setting `undefined` will return `"undefined"` as the value!+ startDate: settings.startDate === "null" ? null : settings.startDate,+ dueDate: settings.dueDate === "null" ? null : settings.dueDate,+ overdue: settings.overdue === "null" ? null : settings.overdue,}));this.storeService.update(this.userId, {diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.htmlindex 21c21d2f5d0..6d9b62b13a8 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html@@ -42,6 +42,12 @@<td class="op-table--cell"><input type="checkbox" disabled checked /></td></ng-container></tr>+ <tr>+ <th class="op-table--cell op-table--cell_soft-heading">{{ text.watched_header }}</th>+ <ng-container *ngFor="let item of settings.controls">+ <td class="op-table--cell"><input type="checkbox" disabled checked /></td>+ </ng-container>+ </tr><tr><th class="op-table--cell op-table--cell_soft-heading">{{ text.assignee }}@@ -72,6 +78,7 @@</td></ng-container></tr>+<tr><th class="op-table--cell op-table--cell_soft-heading"><h5>{{ text.alsoNotifyFor.title }}</h5>@@ -81,6 +88,83 @@<td class="op-table--cell"></td></ng-container></tr>++ <tr>+ <th class="op-table--cell op-table--cell_soft-heading">+ Start date+ </th>+ <ng-container *ngFor="let item of settings.controls">+ <td class="op-table--cell" [formGroup]="item">+ <select+ formControlName="startDate"+ class="form--select -narrow"+ required="true"+ >+ <option+ *ngFor="let availableTime of availableTimes"+ [value]="availableTime.value"+ >+ {{availableTime.title}}+ </option>+ </select>+ </td>+ </ng-container>+ </tr>++ <tr>+ <th class="op-table--cell op-table--cell_soft-heading">+ Due date+ </th>+ <ng-container *ngFor="let item of settings.controls">+ <td class="op-table--cell" [formGroup]="item">+ <select+ formControlName="dueDate"+ class="form--select -narrow"+ required="true"+ >+ <option+ *ngFor="let availableTime of availableTimes"+ [value]="availableTime.value"+ >+ {{availableTime.title}}+ </option>+ </select>+ </td>+ </ng-container>+ </tr>++ <tr>+ <th class="op-table--cell op-table--cell_soft-heading">+ Overdue+ </th>+ <ng-container *ngFor="let item of settings.controls">+ <td class="op-table--cell" [formGroup]="item">+ <select+ formControlName="overdue"+ class="form--select -narrow"+ required="true"+ >+ <option+ *ngFor="let availableTime of availableTimesOverdue"+ [value]="availableTime.value"+ >+ {{availableTime.title}}+ </option>+ </select>+ </td>+ </ng-container>+ </tr>++ <tr>+ <th class="op-table--cell op-table--cell_soft-heading">+ <h5>Some header</h5>+ <p>Some text<p>+ </th>+ <ng-container *ngFor="let item of settings.controls">+ <td class="op-table--cell"></td>+ </ng-container>+ </tr>+<tr><th class="op-table--cell op-table--cell_soft-heading">{{ text.work_package_created_header }}</th><ng-container *ngFor="let item of settings.controls">diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.tsindex b58aa9333a8..01e9a208d08 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts@@ -10,6 +10,7 @@ import { PathHelperService } from 'core-app/core/path-helper/path-helper.serviceimport { I18nService } from 'core-app/core/i18n/i18n.service';import idFromLink from 'core-app/features/hal/helpers/id-from-link';import { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';+import { OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES, REMINDER_AVAILABLE_TIMEFRAMES } from '../overdue-reminder-available-times';@Component({selector: 'op-notification-settings-table',@@ -22,6 +23,25 @@ export class NotificationSettingsTableComponent {@Input() settings:FormArray;+ public availableTimes = [+ {+ // null is not handled well by angular as a option value, it will always return a string.+ // We might as well make this obvious+ value: "null",+ title: this.I18n.t('js.notifications.settings.reminders.no_notification'),+ },+ ...REMINDER_AVAILABLE_TIMEFRAMES,+ ];+ public availableTimesOverdue = [+ {+ // null is not handled well by angular as a option value, it will always return a string.+ // We might as well make this obvious+ value: "null",+ title: this.I18n.t('js.notifications.settings.reminders.no_notification'),+ },+ ...OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES,+ ];+text = {notify_me: this.I18n.t('js.notifications.settings.notify_me'),save: this.I18n.t('js.button_save'),@@ -67,6 +87,9 @@ export class NotificationSettingsTableComponent {workPackageScheduled: new FormControl(false),workPackagePrioritized: new FormControl(false),workPackageCommented: new FormControl(false),+ startDate: new FormControl(this.availableTimes[2].value),+ dueDate: new FormControl(this.availableTimes[2].value),+ overdue: new FormControl(this.availableTimes[1].value),}));}