From d4d680777d4f17f3dd7550008946067df6c7a9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 6 Dec 2018 14:24:02 +0100 Subject: [PATCH] [29153] Accept that the WP state can be pristine temporarily https://community.openproject.com/wp/29153 --- .../container/wp-timeline-container.directive.ts | 12 ++++++++---- .../app/components/wp-table/timeline/wp-timeline.ts | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts index d6c981660b..7d221f646f 100644 --- a/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts +++ b/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts @@ -58,7 +58,7 @@ import { zoomLevelOrder } from '../wp-timeline'; import {DynamicCssService} from "core-app/modules/common/dynamic-css/dynamic-css.service"; -import {input} from "reactivestates"; +import {input, InputState} from "reactivestates"; import {Subject} from "rxjs"; @Component({ @@ -357,13 +357,17 @@ export class WorkPackageTimelineTableController implements AfterViewInit, OnDest this.workPackageIdOrder.forEach((renderedRow) => { const wpId = renderedRow.workPackageId; - // Not all rendered rows are work packages - if (!wpId || this.states.workPackages.get(wpId).isPristine()) { + if (!wpId) { + return; + } + const workPackageState:InputState = this.states.workPackages.get(wpId); + const workPackage:WorkPackageResource|undefined = workPackageState.value; + + if (!workPackage) { return; } // We may still have a reference to a row that, e.g., just got deleted - const workPackage = this.states.workPackages.get(wpId).value!; const startDate = workPackage.startDate ? moment(workPackage.startDate) : currentParams.now; const dueDate = workPackage.dueDate ? moment(workPackage.dueDate) : currentParams.now; const date = workPackage.date ? moment(workPackage.date) : currentParams.now; diff --git a/frontend/src/app/components/wp-table/timeline/wp-timeline.ts b/frontend/src/app/components/wp-table/timeline/wp-timeline.ts index 7edcdf221f..98a22a884b 100644 --- a/frontend/src/app/components/wp-table/timeline/wp-timeline.ts +++ b/frontend/src/app/components/wp-table/timeline/wp-timeline.ts @@ -193,7 +193,11 @@ export function calculateDaySpan(visibleWorkPackages:RenderedRow[], return; } const workPackageState:InputState = loadedWorkPackages.get(wpId); - const workPackage:WorkPackageResource = workPackageState.value!; + const workPackage:WorkPackageResource|undefined = workPackageState.value; + + if (!workPackage) { + return; + } const start = workPackage.startDate ? workPackage.startDate : workPackage.date; if (start && moment(start).isBefore(earliest)) {