Skip to content

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

Find the interesting alert (use dueDate if multiple)

Oliver Güntherba5aa8b28149
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index 93c643c1358..74838230272 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
@@ -6,7 +6,6 @@ import {
debounceTime,
defaultIfEmpty,
distinctUntilChanged,
- filter,
map,
mapTo,
pluck,
@@ -86,7 +85,13 @@ export class IanCenterService extends UntilDestroyedMixin {
activeReason$:Observable<string|null> = this.uiRouterGlobals.params$!.pipe(
this.untilDestroyed(),
distinctUntilChanged(),
- map((params) => params.filter === 'reason' ? (params.name as string) : null),
+ map((params) => {
+ if (params.filter === 'reason') {
+ return params.name as string;
+ }
+
+ return null;
+ }),
shareReplay(1),
);
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.ts
index ede993fbf78..d8a696dc7aa 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
@@ -4,10 +4,7 @@ import {
Input,
OnInit,
} from '@angular/core';
-import {
- IInAppNotificationDetailsAttribute,
- INotification,
-} from 'core-app/core/state/in-app-notifications/in-app-notification.model';
+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 { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
@@ -18,13 +15,11 @@ import { Moment } from 'moment';
selector: 'op-in-app-notification-date-alert',
templateUrl: './in-app-notification-date-alert.component.html',
styleUrls: ['./in-app-notification-date-alert.component.sass'],
- changeDetection: ChangeDetectionStrategy.OnPush
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InAppNotificationDateAlertComponent implements OnInit {
@Input() aggregatedNotifications:INotification[];
- @Input() notification:INotification;
-
@Input() workPackage:WorkPackageResource;
alertText:string;
@@ -57,7 +52,10 @@ export class InAppNotificationDateAlertComponent implements OnInit {
) { }
ngOnInit():void {
- const detail = this.notification._embedded.details[0];
+ // Find the most important date alert
+ const interestingAlert = this.deriveMostRelevantAlert(this.aggregatedNotifications);
+
+ const detail = interestingAlert._embedded.details[0];
const property = detail.property;
const dateValue = this.timezoneService.parseISODate(detail.value);
this.dateIsPast = dateValue.isBefore();
@@ -85,4 +83,17 @@ export class InAppNotificationDateAlertComponent implements OnInit {
return this.I18n.t('js.units.day', { count });
}
+
+ private deriveMostRelevantAlert(aggregatedNotifications:INotification[]) {
+ // Second case: We have one date alert + some others
+ const dateAlerts = aggregatedNotifications.filter((notification) => notification.reason === 'dateAlert');
+ const first = aggregatedNotifications[0];
+ if (dateAlerts.length > 1) {
+ const found = dateAlerts.find((notification) => notification._embedded.details[0].property === 'dueDate');
+ return found || first;
+ }
+
+ // We only have one
+ return first;
+ }
}
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.html
index ad33bdf079e..2f290680d32 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
@@ -91,7 +91,6 @@
<op-in-app-notification-date-alert
*ngIf="context.showDateAlert"
[workPackage]="workPackage"
- [notification]="notification"
[aggregatedNotifications]="aggregatedNotifications"
></op-in-app-notification-date-alert>
<op-in-app-notification-actors-line
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.ts
index 945e976ac0f..a5eb6807541 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
@@ -7,20 +7,14 @@ import {
ViewEncapsulation,
} from '@angular/core';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
-import {
- Observable,
- of,
-} from 'rxjs';
+import { Observable } from 'rxjs';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import {
- defaultIfEmpty,
map,
shareReplay,
- startWith,
- tap,
} from 'rxjs/operators';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { take } from 'rxjs/internal/operators/take';