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
Instead of introducing variables for each possible state, we use the existing observables in the template. Thus we also get rid of the manual changeDetection
Henriette Darge945a811424dc
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.htmlindex 82b13beaa22..9e2144e8e18 100644--- a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html@@ -3,11 +3,8 @@data-qa-selector="op-empty-state"><div class="work-packages-tab-view--overflow op-empty-state--content">- <ng-container *ngIf="loading; else finishedLoading">- <img [src]="image.loading" class="op-empty-state--content-image"/>- </ng-container>- <ng-template #finishedLoading>- <ng-container *ngIf="hasNotifications; else noNotification">+ <ng-container *ngIf="(dataChanged$ | async ) as currentNotificationData; else loading">+ <ng-container *ngIf="currentNotificationData[0]; else noNotification"><img [src]="image.no_selection" class="op-empty-state--content-image"/><p class="op-empty-state--content-text"><span>{{ text.no_selection }}</span>@@ -16,9 +13,13 @@<ng-template #noNotification><img [src]="image.no_notification" class="op-empty-state--content-image"/><p class="op-empty-state--content-text">- <span [textContent]="noNotificationText()"></span>+ <span [textContent]="noNotificationText(currentNotificationData[0], currentNotificationData[1])"></span></p></ng-template>++ </ng-container>+ <ng-template #loading>+ <img [src]="image.loading" class="op-empty-state--content-image"/></ng-template></div></div>diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.tsindex 86687589fee..2c81638715d 100644--- a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts@@ -28,9 +28,7 @@import {ChangeDetectionStrategy,- ChangeDetectorRef,Component,- OnInit,} from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { imagePath } from 'core-app/shared/helpers/images/path-helper';@@ -48,7 +46,7 @@ import { combineLatest } from 'rxjs';styleUrls: ['./empty-state.component.sass'],selector: 'op-empty-state',})-export class EmptyStateComponent implements OnInit {+export class EmptyStateComponent {image = {no_notification: imagePath('notification-center/empty-state-no-notification.svg'),no_selection: imagePath('notification-center/empty-state-no-selection.svg'),@@ -61,46 +59,27 @@ export class EmptyStateComponent implements OnInit {no_selection: this.I18n.t('js.notifications.center.empty_state.no_selection'),};- hasNotifications:boolean;-- notificationsFiltered = false;-- loading = true;-private hasNotifications$ = this.storeService.query.hasNotifications$;private totalCount$ = this.bellService.unread$;+ dataChanged$ = combineLatest([+ this.hasNotifications$,+ this.totalCount$,+ ])+ .pipe(+ distinctUntilChanged(),+ debounceTime(350),+ );+constructor(readonly I18n:I18nService,readonly storeService:IanCenterService,readonly bellService:IanBellService,- readonly cdRef:ChangeDetectorRef,) {}- ngOnInit():void {- combineLatest([- this.hasNotifications$,- this.totalCount$,- ])- .pipe(- distinctUntilChanged(),- debounceTime(250),- )- .subscribe(([hasNotification, total]) => {- this.loading = false;- this.hasNotifications = hasNotification;-- if (!hasNotification && total > 0) {- this.notificationsFiltered = true;- }-- this.cdRef.detectChanges();- });- }-- noNotificationText():string {- return this.notificationsFiltered ? this.text.no_notification_with_current_filter : this.text.no_notification;+ noNotificationText(hasNotifications:boolean, totalNotifications:number):string {+ return (!hasNotifications && totalNotifications > 0) ? this.text.no_notification_with_current_filter : this.text.no_notification;}}