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

Prevent loading parent work packages without timestamps

Oliver Günther80d36995105f
diff --git a/frontend/src/app/features/hal/resources/work-package-resource.ts b/frontend/src/app/features/hal/resources/work-package-resource.ts
index f7a07c49f41..1f2a09095f8 100644
--- a/frontend/src/app/features/hal/resources/work-package-resource.ts
+++ b/frontend/src/app/features/hal/resources/work-package-resource.ts
@@ -52,6 +52,7 @@ import { IWorkPackageTimestamp } from 'core-app/features/hal/resources/work-pack
export interface WorkPackageResourceEmbedded {
activities:CollectionResource;
+ // eslint-disable-next-line no-use-before-define
ancestors:WorkPackageResource[];
assignee:HalResource|any;
attachments:AttachmentCollectionResource;
@@ -59,7 +60,9 @@ export interface WorkPackageResourceEmbedded {
author:HalResource|any;
availableWatchers:HalResource|any;
category:HalResource|any;
+ // eslint-disable-next-line no-use-before-define
children:WorkPackageResource[];
+ // eslint-disable-next-line no-use-before-define
parent:WorkPackageResource|null;
priority:HalResource|any;
project:HalResource|any;
@@ -133,6 +136,9 @@ export class WorkPackageBaseResource extends HalResource {
public attachments:AttachmentCollectionResource;
+ // eslint-disable-next-line no-use-before-define
+ public ancestors:WorkPackageResource[];
+
public attributesByTimestamp?:IWorkPackageTimestamp[];
@InjectField() I18n!:I18nService;
@@ -155,8 +161,7 @@ export class WorkPackageBaseResource extends HalResource {
* Return the ids of all its ancestors, if any
*/
public get ancestorIds():string[] {
- const { ancestors } = this as any;
- return ancestors.map((el:WorkPackageResource) => el.id!);
+ return this.ancestors.map((el:HalResource) => (el.id as string|number).toString());
}
/**
diff --git a/frontend/src/app/features/hal/resources/work-package-timestamp-resource.ts b/frontend/src/app/features/hal/resources/work-package-timestamp-resource.ts
index 532b9008f49..7fd19ff4d90 100644
--- a/frontend/src/app/features/hal/resources/work-package-timestamp-resource.ts
+++ b/frontend/src/app/features/hal/resources/work-package-timestamp-resource.ts
@@ -36,9 +36,13 @@ export interface IWorkPackageTimestampMeta {
export class IWorkPackageTimestamp extends HalResource {
startDate?:string;
+
dueDate?:string;
+
date?:string;
+
_meta:IWorkPackageTimestampMeta;
+
$links:{
schema?:HalResource;
self:HalResource;
@@ -49,5 +53,5 @@ export class IWorkPackageTimestamp extends HalResource {
type?:HalResource;
priority?:HalResource;
version?:HalResource;
- }
+ };
}
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
index 5f197b809b3..2e8999e8b61 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
@@ -29,7 +29,10 @@
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
import { Injectable } from '@angular/core';
-import { RelationsStateValue, WorkPackageRelationsService } from 'core-app/features/work-packages/components/wp-relations/wp-relations.service';
+import {
+ RelationsStateValue,
+ WorkPackageRelationsService,
+} from 'core-app/features/work-packages/components/wp-relations/wp-relations.service';
import { WorkPackageNotificationService } from 'core-app/features/work-packages/services/notifications/work-package-notification.service';
import { WorkPackageCollectionResource } from 'core-app/features/hal/resources/wp-collection-resource';
import { QueryResource } from 'core-app/features/hal/resources/query-resource';
@@ -42,14 +45,16 @@ import { WorkPackageViewColumnsService } from './wp-view-columns.service';
@Injectable()
export class WorkPackageViewAdditionalElementsService {
- constructor(readonly querySpace:IsolatedQuerySpace,
+ constructor(
+ readonly querySpace:IsolatedQuerySpace,
readonly wpTableHierarchies:WorkPackageViewHierarchiesService,
readonly wpTableColumns:WorkPackageViewColumnsService,
readonly notificationService:WorkPackageNotificationService,
readonly halResourceService:HalResourceService,
readonly apiV3Service:ApiV3Service,
readonly schemaCache:SchemaCacheService,
- readonly wpRelations:WorkPackageRelationsService) {
+ readonly wpRelations:WorkPackageRelationsService,
+ ) {
}
public initialize(query:QueryResource, results:WorkPackageCollectionResource):void {
@@ -105,7 +110,10 @@ export class WorkPackageViewAdditionalElementsService {
return Promise.resolve([]);
}
- const ids = _.flatten(rows.map((el) => el.ancestorIds));
+ const resultIds = rows.map((el:WorkPackageResource) => (el.id as string|number).toString());
+ const ids = _.flatten(rows.map((el) => el.ancestorIds))
+ .filter((id) => !resultIds.includes(id));
+
return Promise.resolve(ids);
}