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
Render reminder inline notification entry
Kabiru Mwenjac50b436c3bd8
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex b7a4e8038a4..ff3db1234cd 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -709,6 +709,8 @@ en:new_notifications:message: "There are new notifications."link_text: "Click here to load them."+ reminders:+ note: "Note: “%{note}”"settings:change_notification_settings: 'You can modify your <a target="_blank" href="%{url}">notification settings</a> to ensure you never miss an important update.'title: "Notification settings"diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.tsindex eeae2b406f0..1a12217b389 100644--- a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts@@ -13,7 +13,7 @@ export interface IInAppNotificationHalResourceLinks extends IHalResourceLinks {activity:IHalResourceLink;}-export type IInAppNotificationDetailsAttribute = 'startDate'|'dueDate'|'date';+export type IInAppNotificationDetailsAttribute = 'startDate'|'dueDate'|'date'|'note';export interface IInAppNotificationDetailsResource {property:IInAppNotificationDetailsAttribute;diff --git a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.tsindex 877f2b592be..fd4ddb132b6 100644--- a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts+++ b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts@@ -6,9 +6,9 @@ import {OnInit,ViewEncapsulation,} from '@angular/core';-import { INotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';-import { I18nService } from 'core-app/core/i18n/i18n.service';import { TimezoneService } from 'core-app/core/datetime/timezone.service';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { IInAppNotificationDetailsAttribute, INotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import * as moment from 'moment';import { Moment } from 'moment';@@ -49,6 +49,7 @@ export class InAppNotificationDateAlertComponent implements OnInit {dueDate: this.I18n.t('js.work_packages.properties.dueDate'),date: this.I18n.t('js.notifications.date_alerts.milestone_date'),due_today: this.I18n.t('js.notifications.date_alerts.property_today'),+ note: '', // date alerts do not have notes};constructor(@@ -71,7 +72,7 @@ export class InAppNotificationDateAlertComponent implements OnInit {}}- private deriveDueDate(value:string, property:'startDate'|'dueDate'|'date') {+ private deriveDueDate(value:string, property:IInAppNotificationDetailsAttribute) {const dateValue = this.timezoneService.parseISODate(value).startOf('day');const today = moment();this.dateIsPast = dateValue.isBefore(today, 'day');diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.htmlindex 14868f1cb42..e0443e0a752 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html@@ -88,16 +88,22 @@<divclass="op-ian-item--bottom-line">- <op-in-app-notification-date-alert- *ngIf="showDateAlert"- [workPackage]="workPackage"+ <op-in-app-notification-reminder-alert+ *ngIf="hasReminderAlert"[aggregatedNotifications]="aggregatedNotifications"- ></op-in-app-notification-date-alert>- <op-in-app-notification-actors-line- *ngIf="!showDateAlert"- [notification]="notification"- [aggregatedNotifications]="aggregatedNotifications"- ></op-in-app-notification-actors-line>+ />+ <ng-container *ngIf="!hasReminderAlert">+ <op-in-app-notification-date-alert+ *ngIf="showDateAlert"+ [workPackage]="workPackage"+ [aggregatedNotifications]="aggregatedNotifications"+ ></op-in-app-notification-date-alert>+ <op-in-app-notification-actors-line+ *ngIf="!showDateAlert"+ [notification]="notification"+ [aggregatedNotifications]="aggregatedNotifications"+ ></op-in-app-notification-actors-line>+ </ng-container></div></ng-container><ng-template #workPackageLoading>diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.tsindex 762fdc75730..c7725a20c70 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts@@ -29,6 +29,7 @@ export class InAppNotificationEntryComponent implements OnInit {workPackage$:Observable<WorkPackageResource>|null = null;showDateAlert = false;+ hasReminderAlert = false;loading$ = this.storeService.query.selectLoading();@@ -62,6 +63,7 @@ export class InAppNotificationEntryComponent implements OnInit {const href = this.notification._links.resource?.href;this.workPackageId = href && HalResource.matchFromLink(href, 'work_packages');+ this.hasReminderAlert = this.aggregatedNotifications.some((notification) => notification.reason === 'reminder');this.showDateAlert = this.hasActiveDateAlert();this.buildTranslatedReason();this.buildProject();diff --git a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.html b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.htmlnew file mode 100644index 00000000000..cf1106d3595--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.html@@ -0,0 +1,7 @@+<op-in-app-notification-relative-time+ [notification]="reminderAlert"+/>+<span+ class="op-ian-reminder-alert--note"+ [textContent]="reminderNote"+></span>diff --git a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.sass b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.sassnew file mode 100644index 00000000000..62a064806cf--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.sass@@ -0,0 +1,17 @@+@import "helpers"++.op-ian-reminder-alert+ display: grid+ grid-template-columns: auto 1fr+ grid-column-gap: $spot-spacing-0_25+ align-items: center+ color: var(--fgColor-muted)++ &--note+ @include text-shortener+ display: flex+ white-space: pre-wrap+ line-height: 1rem++ > *+ flex-shrink: 0diff --git a/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.ts b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.tsnew file mode 100644index 00000000000..84392aeabde--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/reminder-alert/in-app-notification-reminder-alert.component.ts@@ -0,0 +1,59 @@+import {+ ChangeDetectionStrategy,+ Component,+ HostBinding,+ Input,+ OnInit,+ ViewEncapsulation,+} from '@angular/core';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { IInAppNotificationDetailsResource, INotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';++@Component({+ selector: 'op-in-app-notification-reminder-alert',+ templateUrl: './in-app-notification-reminder-alert.component.html',+ styleUrls: ['./in-app-notification-reminder-alert.component.sass'],+ changeDetection: ChangeDetectionStrategy.OnPush,+ encapsulation: ViewEncapsulation.None,+})+export class InAppNotificationReminderAlertComponent implements OnInit {+ @Input() aggregatedNotifications:INotification[];++ @HostBinding('class.op-ian-reminder-alert') className = true;++ reminderNote:string;+ reminderAlert:INotification;++ constructor(+ private I18n:I18nService,+ ) { }++ ngOnInit():void {+ this.reminderAlert = this.deriveMostRecentReminder(this.aggregatedNotifications);+ this.reminderNote = this.extractReminderNoteValue(this.reminderAlert._embedded.details);+ }++ private deriveMostRecentReminder(aggregatedNotifications:INotification[]):INotification {+ const reminderAlerts = aggregatedNotifications.filter((notification:INotification) => notification.reason === 'reminder');++ if (reminderAlerts.length > 1) {+ const mostRecent = reminderAlerts.reduce((prev:INotification, current:INotification) => {+ const prevDate = new Date(prev.createdAt);+ const currentDate = new Date(current.createdAt);+ return prevDate > currentDate ? prev : current;+ });+ return mostRecent;+ }++ return reminderAlerts[0];+ }++ private extractReminderNoteValue(details:IInAppNotificationDetailsResource[]):string {+ const noteDetail = details.find((detail:IInAppNotificationDetailsResource) => detail.property === 'note');+ if (noteDetail?.value) {+ return this.I18n.t('js.notifications.reminders.note', { note: (noteDetail?.value) });+ }++ return '';+ }+}diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.tsindex 2839fd792a1..d921e8f48c7 100644--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts@@ -26,6 +26,7 @@ import { DynamicModule } from 'ng-dynamic-component';import { InAppNotificationActorsLineComponent } from './entry/actors-line/in-app-notification-actors-line.component';import { InAppNotificationDateAlertComponent } from './entry/date-alert/in-app-notification-date-alert.component';import { InAppNotificationRelativeTimeComponent } from './entry/relative-time/in-app-notification-relative-time.component';+import { InAppNotificationReminderAlertComponent } from './entry/reminder-alert/in-app-notification-reminder-alert.component';import { InAppNotificationStatusComponent } from './entry/status/in-app-notification-status.component';@NgModule({@@ -38,6 +39,7 @@ import { InAppNotificationStatusComponent } from './entry/status/in-app-notificaInAppNotificationDateAlertComponent,InAppNotificationsDateAlertsUpsaleComponent,InAppNotificationRelativeTimeComponent,+ InAppNotificationReminderAlertComponent,],imports: [OpSharedModule,