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

Use the visible parent if the actual parent is not visible

Oliver Güntherea3f0f0fe11f
diff --git a/frontend/src/app/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts b/frontend/src/app/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts
index 5a29b56dc33..4d061cfbb21 100644
--- a/frontend/src/app/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts
+++ b/frontend/src/app/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts
@@ -152,7 +152,7 @@ export class HierarchyRenderPass extends PrimaryRenderPass {
// If the work package has deferred children to render,
// run them through the callback
deferredChildren.forEach((child:WorkPackageResource) => {
- this.insertUnderParent(this.getOrBuildRow(child), child.parent);
+ this.insertUnderParent(this.getOrBuildRow(child), child.parent || workPackage);
// Descend into any children the child WP might have and callback
this.renderAllDeferredChildren(child);
diff --git a/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts b/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts
index c2af905afda..14dd0f09487 100644
--- a/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts
+++ b/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts
@@ -82,15 +82,14 @@ export class WorkPackageRelationsHierarchyComponent extends UntilDestroyedMixin
this.workPackage = wp;
let toLoad:string[] = [];
+ let parentId = this.workPackage.parent?.id?.toString();
- if (this.workPackage.parent) {
- toLoad.push(this.workPackage.parent.id.toString());
+ if (parentId) {
+ toLoad.push(parentId.toString());
- this.wpCacheService.loadWorkPackage(this.workPackage.parent.id).values$()
- .pipe(
- take(1)
- )
- .subscribe((parent:WorkPackageResource) => {
+ this.wpCacheService
+ .require(parentId)
+ .then((parent:WorkPackageResource) => {
this.workPackage.parent = parent;
});
}
diff --git a/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts b/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts
index cc31dfff88b..c022cdda1bd 100644
--- a/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts
+++ b/frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts
@@ -135,7 +135,10 @@ export class WorkPackageRelationsHierarchyService {
},
lockVersion: childWorkPackage.lockVersion
}).then(wp => {
- this.wpCacheService.loadWorkPackage(parentWorkPackage.id!, true);
+ if (parentWorkPackage) {
+ this.wpCacheService.require(parentWorkPackage.id!, true);
+ }
+
this.wpCacheService.updateWorkPackage(wp);
})
.catch((error) => {
diff --git a/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts b/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts
index 9b112f95787..1f41da034af 100644
--- a/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts
+++ b/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts
@@ -93,7 +93,7 @@ export class HierarchyDragActionService extends TableDragActionService {
private loadParentOfWP(wpId:string):Promise<string|null> {
return this.wpCacheService.require(wpId)
.then((wp:WorkPackageResource) => {
- return Promise.resolve(wp.parent.id);
+ return Promise.resolve(wp.parent?.id || null);
});
}
}
diff --git a/frontend/src/app/modules/hal/resources/work-package-resource.ts b/frontend/src/app/modules/hal/resources/work-package-resource.ts
index 955e7211a51..682b89e0f75 100644
--- a/frontend/src/app/modules/hal/resources/work-package-resource.ts
+++ b/frontend/src/app/modules/hal/resources/work-package-resource.ts
@@ -59,7 +59,7 @@ export interface WorkPackageResourceEmbedded {
availableWatchers:HalResource|any;
category:HalResource|any;
children:WorkPackageResource[];
- parent:HalResource|any;
+ parent:WorkPackageResource|null;
priority:HalResource|any;
project:HalResource|any;
relations:CollectionResource;
@@ -237,7 +237,7 @@ export class WorkPackageBaseResource extends HalResource {
}
public isParentOf(otherWorkPackage:WorkPackageResource) {
- return otherWorkPackage.parent.$links.self.$link.href === this.$links.self.$link.href;
+ return otherWorkPackage.parent?.$links.self.$link.href === this.$links.self.$link.href;
}
/**