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
Mark items as read when opened
Oliver Günther0f3038335103
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.htmlindex ed8952e1cea..512b125757d 100644--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html@@ -2,22 +2,21 @@<div class="op-ian-center--content"><ng-container *ngIf="(hasNotifications$ | async) as notifications; else noResults"><cdk-virtual-scroll-viewport- itemSize="80"- class="op-ian-center--viewport"+ itemSize="80"+ class="op-ian-center--viewport"><op-in-app-notification-entry- *cdkVirtualFor="let records of notifications$ | async; templateCacheSize: 0"- class="op-ian-center--entry"- [notification]="records[0]"+ *cdkVirtualFor="let records of notifications$ | async; templateCacheSize: 0"+ class="op-ian-center--entry"+ [notification]="records[0]"[aggregatedNotifications]="records"- (resourceLinkClicked)="openSplitView($event)"></op-in-app-notification-entry></cdk-virtual-scroll-viewport></ng-container><ng-template #noResults><div class="generic-table--no-results-container"><span- class="generic-table--no-results-title"+ class="generic-table--no-results-title"><op-icon icon-classes="icon-info1"></op-icon>{{ noResultText$ | async }}@@ -27,9 +26,10 @@</div><div class="op-ian-center--footer"><p- class="op-ian-center--max-warning"- *ngIf="hasMoreThanPageSize$ | async"- [textContent]="totalCountWarning()">+ class="op-ian-center--max-warning"+ *ngIf="hasMoreThanPageSize$ | async"+ [textContent]="totalCountWarning()"+ ></p></div></div>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 ee147469b68..07353198248 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@@ -8,7 +8,7 @@type="button"class="op-ian-item--row"[class.op-ian-item--row_unexpandable]="unexpandable"- (click)="toggleDetails()"+ (click)="showDetails()"><div*ngIf="project"@@ -97,7 +97,10 @@class="op-ian-item--buttons"><button+ type="button"class="op-ian-item--button button -tiny"+ [disabled]="loading$ | async"+ (click)="markAsRead($event, aggregatedNotifications)"><i class="button--icon icon-yes"></i></button>@@ -112,34 +115,4 @@></span></ng-template></button>- <div- *ngIf="notification.expanded"- class="op-ian-item--details"- data-qa-selector="op-ian-details"- >- <ng-container *ngIf="body.length > 0">- <div class="op-ian-item--body">- <ng-container *ngFor="let bodyItem of body">- <div- class="op-ian-item--body-item"- [innerHTML]="bodyItem.html"- >- </div>- </ng-container>- </div>- </ng-container>- <ul- class="work-package-details-activities-messages"- *ngIf="details.length > 0"- >- <ng-container *ngFor="let detail of details">- <li *ngIf="detail.html && detail.html !== ''">- <span- class="message"- [innerHtml]="detail.html"- ></span>- </li>- </ng-container>- </ul>- </div></div>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 fea794b3054..5a86ba4c49e 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@@ -26,6 +26,9 @@ import {} from 'rxjs/operators';import { PrincipalLike } from 'core-app/shared/components/principal/principal-types';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';+import { take } from "rxjs/internal/operators/take";+import { StateService } from "@uirouter/angular";+import { InAppNotificationsQuery } from "core-app/features/in-app-notifications/store/in-app-notifications.query";@Component({selector: 'op-in-app-notification-entry',@@ -40,6 +43,7 @@ export class InAppNotificationEntryComponent implements OnInit {@Output() resourceLinkClicked = new EventEmitter<unknown>();workPackage$:Observable<WorkPackageResource>|null = null;+ loading$ = this.ianQuery.selectLoading();// Formattable body, if anybody:InAppNotificationDetail[];@@ -72,9 +76,11 @@ export class InAppNotificationEntryComponent implements OnInit {constructor(readonly apiV3Service:APIV3Service,readonly I18n:I18nService,- readonly inAppNotificationsService:InAppNotificationsService,+ readonly ianService:InAppNotificationsService,+ readonly ianQuery:InAppNotificationsQuery,readonly timezoneService:TimezoneService,readonly pathHelper:PathHelperService,+ readonly state:StateService,) {}@@ -116,19 +122,37 @@ export class InAppNotificationEntryComponent implements OnInit {);}- toggleDetails():void {- if (this.unexpandable) {+ showDetails():void {+ if (this.unexpandable || !this.workPackage$) {return;}if (!this.notification.readIAN) {- this.inAppNotificationsService.markReadKeepAndExpanded(this.notification);- }- if (this.notification.expanded) {- this.inAppNotificationsService.collapse(this.notification);- } else {- this.inAppNotificationsService.expand(this.notification);+ this.ianService.markAsRead(this.aggregatedNotifications, true);}++ this+ .workPackage$+ .pipe(+ take(1)+ ).subscribe((wp) => {+ this.state.go(+ `${this.state.current.data.baseRoute}.details`,+ { workPackageId: wp.id }+ );+ });+ }++ projectClicked(event:MouseEvent) {+ event.stopPropagation();+ }++ markAsRead(event:MouseEvent, notifications:InAppNotification[]) {+ event.stopPropagation();++ this+ .ianService+ .markAsRead(notifications);}private buildActors() {@@ -169,10 +193,6 @@ export class InAppNotificationEntryComponent implements OnInit {this.translatedReasons = reasons;}- projectClicked(event:MouseEvent) {- event.stopPropagation();- }-private buildProject() {const { project } = this.notification._links;diff --git a/frontend/src/app/features/in-app-notifications/store/in-app-notifications.query.ts b/frontend/src/app/features/in-app-notifications/store/in-app-notifications.query.tsindex 56fd2e597c5..e7e4a608e94 100644--- a/frontend/src/app/features/in-app-notifications/store/in-app-notifications.query.ts+++ b/frontend/src/app/features/in-app-notifications/store/in-app-notifications.query.ts@@ -1,7 +1,7 @@import { Injectable } from '@angular/core';import { QueryEntity } from '@datorama/akita';-import { map } from 'rxjs/operators';-import { Observable } from 'rxjs';+import { map, switchMap } from 'rxjs/operators';+import { NEVER, Observable, throwError } from 'rxjs';import {InAppNotificationsState,InAppNotificationsStore,@@ -10,9 +10,27 @@ import { InAppNotification } from 'core-app/features/in-app-notifications/store/@Injectable({ providedIn: 'root' })export class InAppNotificationsQuery extends QueryEntity<InAppNotificationsState> {+ /** Select the active filter facet */+ activeFacet$ = this.select('activeFacet');++ /** Get the faceted items */+ faceted$ = this.activeFacet$+ .pipe(+ switchMap((facet) => {+ switch (facet) {+ case 'unread':+ return this.unreadOrKept$;+ case 'all':+ return this.selectAll();+ }++ return throwError(new Error(`Invalid facet ${facet}`));+ })+ )+/** Notifications grouped by resource */aggregatedNotifications$:Observable<{ [key:string]:InAppNotification[] }> = this- .selectAll()+ .faceted$.pipe(map((notifications) => (_.groupBy(notifications, (notification) => notification._links.resource?.href || 'none')@@ -31,15 +49,13 @@ export class InAppNotificationsQuery extends QueryEntity<InAppNotificationsState});/** Get all items that shall be kept in the notification center */- keep$ = this.selectAll({- filterBy: ({ keep }) => !!keep,+ unreadOrKept$ = this.selectAll({+ filterBy: ({ readIAN, keep }) => !readIAN || !!keep,});/** Do we have any notification that shall be visible the notification center? */hasNotifications$ = this.selectCount().pipe(map((count) => count > 0));- activeFacet$ = this.select('activeFacet');-/** Determine whether the pageSize is not sufficient to load all notifcations */hasMoreThanPageSize$ = this.select()diff --git a/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts b/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.tsindex d77e0fd7648..9a4e4f940f5 100644--- a/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts+++ b/frontend/src/app/features/in-app-notifications/store/in-app-notifications.service.ts@@ -1,5 +1,5 @@import { Injectable } from '@angular/core';-import { applyTransaction, ID } from '@datorama/akita';+import { applyTransaction, ID, setLoading } from '@datorama/akita';import { Observable } from 'rxjs';import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';import { map, switchMap, tap } from 'rxjs/operators';@@ -75,6 +75,7 @@ export class InAppNotificationsService {.pipe(take(1),switchMap((events) => this.apiV3Service.notifications.markRead(events.map((event) => event.id))),+ setLoading(this.store),).subscribe(() => {applyTransaction(() => {@@ -84,6 +85,26 @@ export class InAppNotificationsService {});}+ markAsRead(notifications:InAppNotification[], keep = false) {+ const ids = notifications.map((n) => n.id);++ this+ .apiV3Service+ .notifications+ .markRead(ids)+ .pipe(+ setLoading(this.store),+ )+ .subscribe(() => {+ applyTransaction(() => {+ this.store.update(ids, { readIAN: true, keep: keep });+ this.store.update(+ ({ unreadCount }) => ({ unreadCount: unreadCount - ids.length }),+ );+ });+ });+ }+private sideLoadInvolvedWorkPackages(elements:InAppNotification[]) {const wpIds = elements.map((element) => {const href = element._links.resource?.href;@@ -113,26 +134,4 @@ export class InAppNotificationsService {},);}-- markReadKeepAndExpanded(notification:InAppNotification):void {- this- .apiV3Service- .notifications- .id(notification.id)- .markRead()- .subscribe(() => {- applyTransaction(() => {- this.store.update(- notification.id,- {- readIAN: true,- keep: true,- },- );- this.store.update(- ({ unreadCount }) => ({ unreadCount: unreadCount - 1 }),- );- });- });- }}diff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.htmlindex a18c52333db..4cf0a8fb98a 100644--- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html+++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html@@ -1,8 +1,7 @@<div class="work-packages-partitioned-query-space--container"[ngClass]="currentPartition"><ng-container *ngIf="toolbarComponent">- <ng-container *ngComponentOutlet="toolbarComponent;- ndcDynamicInjector: injector"+ <ng-container *ngComponentOutlet="toolbarComponent; injector: injector"></ng-container></ng-container><div *ngIf="!toolbarComponent"