Merge pull request #8419 from opf/fix/parent-null

Use the visible parent if the actual parent is not visible

[ci skip]
pull/8423/head
Oliver Günther 4 years ago committed by GitHub
commit d060971434
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      frontend/src/app/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts
  2. 13
      frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.directive.ts
  3. 5
      frontend/src/app/components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service.ts
  4. 2
      frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts
  5. 4
      frontend/src/app/modules/hal/resources/work-package-resource.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);

@ -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;
});
}

@ -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) => {

@ -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);
});
}
}

@ -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;
}
/**

Loading…
Cancel
Save