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

Wait for timeline or table to be rendered

Oliver Günther9d9955a32985
diff --git a/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts b/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts
index 1d46d8331ac..f7cabece22b 100644
--- a/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts
+++ b/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts
@@ -45,6 +45,7 @@ import {HalEventsService} from "core-app/modules/hal/services/hal-events.service
import Moment = moment.Moment;
import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";
import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";
+import {take} from "rxjs/operators";
export const classNameBar = 'bar';
export const classNameLeftHandle = 'leftHandle';
@@ -243,20 +244,22 @@ export function registerWorkPackageMouseHandler(this:void,
function saveWorkPackage(change:WorkPackageChangeset) {
const queryDm:QueryDmService = injector.get(QueryDmService);
+ const querySpace:IsolatedQuerySpace = injector.get(IsolatedQuerySpace);
// Remember the time before saving the work package to know which work packages to update
const updatedAt = moment().toISOString();
- return loadingIndicator.table.promise = halEditing.save<WorkPackageResource, WorkPackageChangeset>(change)
+ return loadingIndicator.table.promise = halEditing
+ .save<WorkPackageResource, WorkPackageChangeset>(change)
.then((result) => {
notificationService.showSave(result.resource);
const ids = _.map(querySpace.tableRendered.value!, row => row.workPackageId);
- loadingIndicator.table.promise =
- queryDm.loadIdsUpdatedSince(ids, updatedAt).then(workPackageCollection => {
- wpCacheService.updateWorkPackageList(workPackageCollection.elements);
+ return queryDm.loadIdsUpdatedSince(ids, updatedAt).then(workPackageCollection => {
+ wpCacheService.updateWorkPackageList(workPackageCollection.elements);
- halEvents.push(result.resource, { eventType: 'updated' });
- });
+ halEvents.push(result.resource, { eventType: 'updated' });
+ return querySpace.timelineRendered.pipe(take(1)).toPromise();
+ });
})
.catch((error) => {
notificationService.handleRawError(error, renderInfo.workPackage);
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 0a193126bf9..41e18828fec 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
@@ -222,7 +222,7 @@ export class WorkPackageTimelineTableController implements AfterViewInit, OnDest
// Mark rendering event in a timeout to let DOM process
setTimeout(() => {
- this.querySpace.timelineRendered.putValue(null);
+ this.querySpace.timelineRendered.next(null);
});
});
}
diff --git a/frontend/src/app/modules/work_packages/query-space/isolated-query-space.ts b/frontend/src/app/modules/work_packages/query-space/isolated-query-space.ts
index 60fa1e45874..2407402b863 100644
--- a/frontend/src/app/modules/work_packages/query-space/isolated-query-space.ts
+++ b/frontend/src/app/modules/work_packages/query-space/isolated-query-space.ts
@@ -37,8 +37,8 @@ export class IsolatedQuerySpace extends StatesGroup {
// State to be updated when the table is up to date
tableRendered = input<RenderedWorkPackage[]>();
- // State to be updated when the timeline is up to date
- timelineRendered = input<null>();
+ // Event to be raised when the timeline is up to date
+ timelineRendered = new Subject<null>();
renderedWorkPackages:State<RenderedWorkPackage[]> = derive(this.tableRendered, $ => $.pipe(
map(rows => rows.filter(row => !!row.workPackageId)))
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts b/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
index 0b81d9c3975..f29c0fa6e50 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-list/wp-list.component.ts
@@ -48,7 +48,7 @@ import {scrollHeaderOnMobile} from "core-app/globals/global-listeners/top-menu-s
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
/** We need to provide the wpNotification service here to get correct save notifications for WP resources */
- { provide: HalResourceNotificationService, useClass: WorkPackageNotificationService },
+ {provide: HalResourceNotificationService, useClass: WorkPackageNotificationService},
DragAndDropService,
CausedUpdatesService
]
@@ -184,7 +184,7 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
if (query.persisted) {
this.selectedTitle = query.name;
} else {
- this.selectedTitle = this.wpStaticQueries.getStaticName(query);
+ this.selectedTitle = this.wpStaticQueries.getStaticName(query);
}
this.titleEditingEnabled = this.authorisationService.can('query', 'updateImmediately');
@@ -205,7 +205,13 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
}
if (visibly) {
- this.loadingIndicator = promise;
+ this.loadingIndicator = promise.then(() => {
+ if (this.wpTableTimeline.isVisible) {
+ return this.querySpace.timelineRendered.toPromise();
+ } else {
+ return this.querySpace.tableRendered.valuesPromise() as Promise<unknown>;
+ }
+ });
}
return promise;
@@ -270,13 +276,6 @@ export class WorkPackagesListComponent extends WorkPackagesViewBase implements O
protected loadCurrentQuery():Promise<unknown> {
return this.loadingIndicator =
this.wpListService
- .loadCurrentQueryFromParams(this.projectIdentifier)
- .then(() => {
- if (this.wpTableTimeline.isVisible) {
- return this.querySpace.timelineRendered.valuesPromise();
- } else {
- return this.querySpace.tableRendered.valuesPromise();
- }
- });
+ .loadCurrentQueryFromParams(this.projectIdentifier);
}
}