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
Show unread notification count in the activity tab header, and show an unread indicator next to activities that have a notfiication associated with them
Benjamin Bädorfb23d232c5042
diff --git a/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.html b/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.htmlindex a6a6b70fde5..2d559cd9cb6 100644--- a/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.html+++ b/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.html@@ -1,15 +1,19 @@<div id="activity-{{ activityNo }}"><div [ngSwitch]="activityType">- <revision-activity *ngSwitchCase="'Revision'"- [workPackage]="workPackage"- [activity]="activity"- [activityNo]="activityNo">- </revision-activity>- <user-activity *ngSwitchDefault- [workPackage]="workPackage"- [activity]="activity"- [activityNo]="activityNo"- [isInitial]="isInitial">- </user-activity>+ <revision-activity+ *ngSwitchCase="'Revision'"+ [workPackage]="workPackage"+ [activity]="activity"+ [activityNo]="activityNo"+ [hasUnreadNotification]="hasUnreadNotification"+ ></revision-activity>+ <user-activity+ *ngSwitchDefault+ [workPackage]="workPackage"+ [activity]="activity"+ [activityNo]="activityNo"+ [isInitial]="isInitial"+ [hasUnreadNotification]="hasUnreadNotification"+ ></user-activity></div></div>diff --git a/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.ts b/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.tsindex 03d8edd5728..096356f338b 100644--- a/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-activity/activity-entry.component.ts@@ -45,6 +45,8 @@ export class ActivityEntryComponent implements OnInit {@Input() public isInitial:boolean;+ @Input() public hasUnreadNotification:boolean;+public projectId:string;public activityType:string;diff --git a/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.html b/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.htmlindex 808ddab4687..d858ab042d7 100644--- a/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.html+++ b/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.html@@ -1,9 +1,15 @@-<div class="work-package-details-activities-activity-contents"- *ngIf="workPackage">+<div+ class="work-package-details-activities-activity-contents"+ *ngIf="workPackage"+><div class="comments-number">- <activity-link [workPackage]="workPackage"- [activityNo]="activityNo">- </activity-link>+ <span+ *ngIf="hasUnreadNotification"+ >U</span>+ <activity-link+ [workPackage]="workPackage"+ [activityNo]="activityNo"+ ></activity-link></div><op-principal@@ -22,9 +28,11 @@></op-principal><span class="user" *ngIf="userActive">- <a [attr.href]="userPath"- [attr.aria-label]="userLabel"- [textContent]="userName"></a>+ <a+ [attr.href]="userPath"+ [attr.aria-label]="userLabel"+ [textContent]="userName"+ ></a></span><span class="user" *ngIf="!userActive" [textContent]="userName"></span><span class="revision-activity--revision-link date" [innerHtml]="revisionLink"></span>diff --git a/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.ts b/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.tsindex e819b43d672..2382266436d 100644--- a/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-activity/revision/revision-activity.component.ts@@ -48,6 +48,8 @@ export class RevisionActivityComponent implements OnInit {@Input() public activityNo:number;+ @Input() public hasUnreadNotification:boolean;+public userId:string | number;public userName:string;diff --git a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.html b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.htmlindex 45711c00e36..e6dd3bf8440 100644--- a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.html+++ b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.html@@ -1,8 +1,9 @@-<div class="op-user-activity work-package-details-activities-activity-contents"- *ngIf="workPackage"- (mouseenter)="focus()"- (mouseleave)="blur()">-+<div+ class="op-user-activity work-package-details-activities-activity-contents"+ *ngIf="workPackage"+ (mouseenter)="focus()"+ (mouseleave)="blur()"+><div class="op-user-activity--user-line"><op-principal*ngIf="userName"@@ -20,42 +21,51 @@</div></div><div class="comments-number">- <activity-link [workPackage]="workPackage"- [activityNo]="activityNo">- </activity-link>- <div class="comments-icons"- [hidden]="shouldHideIcons()">+ <span+ *ngIf="hasUnreadNotification"+ >U</span>+ <activity-link+ [workPackage]="workPackage"+ [activityNo]="activityNo"+ ></activity-link>+ <div+ class="comments-icons"+ [hidden]="shouldHideIcons()"+ ><button- type="button"- *ngIf="userCanQuote"- class="op-link"- [title]="text.quote_comment"- (click)="quoteComment()"+ type="button"+ *ngIf="userCanQuote"+ class="op-link"+ [title]="text.quote_comment"+ (click)="quoteComment()"><op-icon icon-classes="action-icon icon-quote"></op-icon></button><button- *ngIf="userCanEdit"- type="button"- class="op-link"- [ngClass]="'edit-activity--' + activityNo"- [title]="text.edit_comment"- (click)="activate()"+ *ngIf="userCanEdit"+ type="button"+ class="op-link"+ [ngClass]="'edit-activity--' + activityNo"+ [title]="text.edit_comment"+ (click)="activate()"><op-icon icon-classes="action-icon icon-edit"></op-icon></button></div></div>- <img *ngIf="bcfSnapshotUrl"- [src]="bcfSnapshotUrl"- class="activity-thumbnail">+ <img+ *ngIf="bcfSnapshotUrl"+ [src]="bcfSnapshotUrl"+ class="activity-thumbnail"+ /><div class="user-comment" ><div *ngIf="active" class="inplace-edit"><div class="user-comment--form inplace-edit--write-value">- <edit-form-portal [changeInput]="change"- [schemaInput]="schema"- [editFieldHandler]="handler">- </edit-form-portal>+ <edit-form-portal+ [changeInput]="change"+ [schemaInput]="schema"+ [editFieldHandler]="handler"+ ></edit-form-portal></div></div><op-dynamic-bootstrapdiff --git a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.tsindex a8286fc45e3..e668121a660 100644--- a/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-activity/user/user-activity.component.ts@@ -64,6 +64,8 @@ export class UserActivityComponent extends WorkPackageCommentFieldHandler implem@Input() public isInitial:boolean;+ @Input() public hasUnreadNotification:boolean;+public userCanEdit = false;public userCanQuote = false;diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.tsindex 0159640876e..21b708eca10 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-base.controller.ts@@ -27,14 +27,16 @@//++import { ChangeDetectorRef, Directive, OnInit } from '@angular/core';+import { Transition } from '@uirouter/core';+import { combineLatest, Observable } from 'rxjs';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { ActivityEntryInfo } from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-entry-info';import { WorkPackagesActivityService } from 'core-app/features/work-packages/components/wp-single-view-tabs/activity-panel/wp-activity.service';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { Transition } from '@uirouter/core';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';+import { InAppNotification, NOTIFICATIONS_MAX_SIZE } from 'core-app/features/in-app-notifications/store/in-app-notification.model';@Directive()export class ActivityPanelBaseController extends UntilDestroyedMixin implements OnInit {@@ -48,6 +50,8 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements// Visible activitiespublic visibleActivities:ActivityEntryInfo[] = [];+ public notifications: InAppNotification[] = [];+public reverse:boolean;public showToggler:boolean;@@ -73,15 +77,29 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements}ngOnInit() {- this- .apiV3Service- .work_packages- .id(this.workPackageId)- .requireAndStream()- .pipe(- this.untilDestroyed(),- )- .subscribe((wp:WorkPackageResource) => {+ combineLatest([+ this+ .apiV3Service+ .work_packages+ .id(this.workPackageId)+ .requireAndStream()+ .pipe(this.untilDestroyed()),+ this+ .apiV3Service+ .notifications+ .facet(+ 'unread',+ {+ pageSize: NOTIFICATIONS_MAX_SIZE,+ filters: [+ [ 'resource_id', '=', [ this.workPackageId ] ],+ [ 'resource_type', '=', [ 'work_package' ] ],+ ],+ },+ ),+ ])+ .subscribe(([wp, notificationCollection]) => {+ this.notifications = notificationCollection._embedded.elements;this.workPackage = wp;this.wpActivity.require(this.workPackage).then((activities:any) => {this.updateActivities(activities);@@ -119,6 +137,10 @@ export class ActivityPanelBaseController extends UntilDestroyedMixin implements.filter((activity:HalResource) => !!_.get(activity, 'comment.html'));}+ protected hasUnreadNotification(activityHref:string) {+ return !!this.notifications.find(notification => notification._links.activity?.href === activityHref);+ }+public toggleComments() {this.onlyComments = !this.onlyComments;this.updateActivities(this.unfilteredActivities);diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.htmlindex 0d2222d16f3..79e9437e831 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.html+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/activity-panel/activity-tab.html@@ -2,27 +2,35 @@<ng-template><div class="detail-activity"><div class="work-package-details-activities-list">- <div *ngFor="let inf of visibleActivities; trackBy:trackByHref; let first = first"- class="work-package-details-activities-activity">- <h3 class="activity-date"- [ngClass]="{'-with-toggler': first && showToggler}"- *ngIf="first || inf.isNextDate">- <span class="activity-date--label" [textContent]="inf.date"></span>+ <div+ *ngFor="let inf of visibleActivities; trackBy:trackByHref; let first = first"+ class="work-package-details-activities-activity"+ >+ <h3+ class="activity-date"+ [ngClass]="{'-with-toggler': first && showToggler}"+ *ngIf="first || inf.isNextDate"+ >+ <span+ class="activity-date--label"+ [textContent]="inf.date"+ ></span><button- *ngIf="first && showToggler"- type="button"- class="activity-comments--toggler button -small -transparent -with-icon icon-filter icon-small hide-when-print"- [textContent]="togglerText"- (click)="toggleComments()"- >- </button>+ *ngIf="first && showToggler"+ type="button"+ class="activity-comments--toggler button -small -transparent -with-icon icon-filter icon-small hide-when-print"+ [textContent]="togglerText"+ (click)="toggleComments()"+ ></button></h3>- <activity-entry [workPackage]="workPackage"- [activity]="inf.activity"- [activityNo]="inf.number(inf.isReversed)"- [isInitial]="inf.isInitial()">- </activity-entry>+ <activity-entry+ [workPackage]="workPackage"+ [activity]="inf.activity"+ [activityNo]="inf.number(inf.isReversed)"+ [hasUnreadNotification]="hasUnreadNotification(inf.href)"+ [isInitial]="inf.isInitial()"+ ></activity-entry></div></div></div>diff --git a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-notifications-count.function.ts b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-notifications-count.function.tsnew file mode 100644index 00000000000..32f0401103d--- /dev/null+++ b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-notifications-count.function.ts@@ -0,0 +1,30 @@+import { Injector } from '@angular/core';+import { Observable } from 'rxjs';+import { map } from 'rxjs/operators';+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';+import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';+import { InAppNotification, NOTIFICATIONS_MAX_SIZE } from 'core-app/features/in-app-notifications/store/in-app-notification.model';++export function workPackageNotificationsCount(+ workPackage:WorkPackageResource,+ injector:Injector,+):Observable<number> {+ const apiV3Service = injector.get(APIV3Service);+ const wpId = workPackage.id!.toString();++ return apiV3Service+ .notifications+ .facet(+ 'unread',+ {+ pageSize: NOTIFICATIONS_MAX_SIZE,+ filters: [+ [ 'resource_id', '=', [ wpId ] ],+ [ 'resource_type', '=', [ 'work_package' ] ],+ ],+ },+ )+ .pipe(+ map((data) => data._embedded.elements.length),+ );+}diff --git a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-tabs.service.tsindex 86cff214114..bbd9454b12e 100644--- a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts@@ -9,6 +9,7 @@ import { WorkPackageWatchersTabComponent } from 'core-app/features/work-packagesimport { I18nService } from 'core-app/core/i18n/i18n.service';import { workPackageWatchersCount } from 'core-app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-watchers-count.function';import { workPackageRelationsCount } from 'core-app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-relations-count.function';+import { workPackageNotificationsCount } from 'core-app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-notifications-count.function';@Injectable({providedIn: 'root',@@ -65,6 +66,7 @@ export class WorkPackageTabsService {id: 'activity',component: WorkPackageActivityTabComponent,name: I18n.t('js.work_packages.tabs.activity'),+ count: workPackageNotificationsCount,},{id: 'relations',