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

Implement aggregated reasons, count

Oliver Güntherd08fb80c64bb
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 3c85619581e..ee147469b68 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
@@ -72,9 +72,20 @@
</div>
<div
+ class="op-ian-item--reason-wrapper"
+ >
+ <span
class="op-ian-item--reason"
- [textContent]="translatedReason || notification.reason"
- ></div>
+ *ngFor="let item of translatedReasons | keyvalue; let first = first; let last = last"
+ >
+ <span
+ *ngIf="item.value > 1"
+ class="op-ian-item--reason-count"
+ [textContent]="item.value"
+ ></span>
+ {{ item.key }}<ng-container *ngIf="!last && first !== last">, </ng-container>
+ </span>
+ </div>
<div
class="op-ian-item--date"
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
index 7f2e5f7f6de..3a77ac49805 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
@@ -72,7 +72,19 @@ $subject-font-size: 14px
&--reason,
&--date
- color: var(--gray-dark)
+ color: #7f7f7f
+
+ &--reason-count
+ background: #7f7f7f
+ color: white
+ border-radius: 12px
+ font-size: 12px
+ line-height: 12px
+ font-weight: bold
+ height: 16px
+ min-width: 14px
+ padding: 0px 3px 0 3px
+ text-align: center
&--title
grid-area: title
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 a51b09219e8..fea794b3054 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
@@ -54,7 +54,7 @@ export class InAppNotificationEntryComponent implements OnInit {
actors:PrincipalLike[] = [];
// The translated reason, if available
- translatedReason?:string;
+ translatedReasons:{[reason:string]:number};
// Format relative elapsed time (n seconds/minutes/hours ago)
// at an interval for auto updating
@@ -152,10 +152,21 @@ export class InAppNotificationEntryComponent implements OnInit {
}
private buildTranslatedReason() {
- this.translatedReason = this.I18n.t(
- `js.notifications.reasons.${this.notification.reason}`,
- { defaultValue: this.notification.reason || this.text.placeholder },
- );
+ const reasons:{[reason:string]:number} = {};
+
+ this
+ .aggregatedNotifications
+ .forEach((notification) => {
+ const translatedReason = this.I18n.t(
+ `js.notifications.reasons.${notification.reason}`,
+ { defaultValue: notification.reason || this.text.placeholder },
+ );
+
+ reasons[translatedReason] = reasons[translatedReason] || 0;
+ reasons[translatedReason] += 1;
+ });
+
+ this.translatedReasons = reasons;
}
projectClicked(event:MouseEvent) {