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

Fix potentially undefined wpEmbeddedTable

Oliver Günther644e76041420
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/embedded/children/wp-children-query.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/embedded/children/wp-children-query.component.ts
index 76d33b5193d..4c51d2bd5bf 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/embedded/children/wp-children-query.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/embedded/children/wp-children-query.component.ts
@@ -68,7 +68,9 @@ export class WorkPackageChildrenQueryComponent extends WorkPackageRelationQueryB
'remove-child-action',
this.I18n.t('js.relation_buttons.remove_child'),
(child:WorkPackageResource) => {
- this.embeddedTable.loadingIndicator = this.wpRelationsHierarchyService.removeChild(child);
+ if (this.embeddedTable) {
+ this.embeddedTable.loadingIndicator = this.wpRelationsHierarchyService.removeChild(child);
+ }
},
(child:WorkPackageResource) => !!child.changeParent,
),
@@ -111,7 +113,7 @@ export class WorkPackageChildrenQueryComponent extends WorkPackageRelationQueryB
.id(this.workPackage)
.observe()
.pipe(
- filter(() => this.embeddedTable && this.embeddedTable.isInitialized),
+ filter(() => !!this.embeddedTable?.isInitialized),
this.untilDestroyed(),
)
.subscribe(() => this.refreshTable());
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/embedded/relations/wp-relation-query.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/embedded/relations/wp-relation-query.component.ts
index 35816acb3fc..69ab42cd7c5 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/embedded/relations/wp-relation-query.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/embedded/relations/wp-relation-query.component.ts
@@ -27,7 +27,10 @@
//++
import {
- Component, Inject, Input, OnInit,
+ Component,
+ Inject,
+ Input,
+ OnInit,
} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
@@ -65,6 +68,10 @@ export class WorkPackageRelationQueryComponent extends WorkPackageRelationQueryB
'remove-relation-action',
this.I18n.t('js.relation_buttons.remove'),
(relatedTo:WorkPackageResource) => {
+ if (!this.embeddedTable) {
+ return;
+ }
+
this.embeddedTable.loadingIndicator = this.wpRelations.require(relatedTo.id!)
.then(() => this.wpInlineCreate.remove(this.workPackage, relatedTo))
.then(() => this.refreshTable())
@@ -77,12 +84,12 @@ export class WorkPackageRelationQueryComponent extends WorkPackageRelationQueryB
public idFromLink = idFromLink;
constructor(protected readonly PathHelper:PathHelperService,
- @Inject(WorkPackageInlineCreateService) protected readonly wpInlineCreate:WpRelationInlineCreateService,
- protected readonly wpRelations:WorkPackageRelationsService,
- protected readonly halEvents:HalEventsService,
- protected readonly queryUrlParamsHelper:UrlParamsHelperService,
- protected readonly notificationService:WorkPackageNotificationService,
- protected readonly I18n:I18nService) {
+ @Inject(WorkPackageInlineCreateService) protected readonly wpInlineCreate:WpRelationInlineCreateService,
+ protected readonly wpRelations:WorkPackageRelationsService,
+ protected readonly halEvents:HalEventsService,
+ protected readonly queryUrlParamsHelper:UrlParamsHelperService,
+ protected readonly notificationService:WorkPackageNotificationService,
+ protected readonly I18n:I18nService) {
super(queryUrlParamsHelper);
}
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/embedded/wp-relation-query.base.ts b/frontend/src/app/features/work-packages/components/wp-relations/embedded/wp-relation-query.base.ts
index c8bb31f760b..c7eb1fa6c30 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/embedded/wp-relation-query.base.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/embedded/wp-relation-query.base.ts
@@ -47,7 +47,7 @@ export abstract class WorkPackageRelationQueryBase extends UntilDestroyedMixin {
public hidden = false;
/** Reference to the embedded table instance */
- @ViewChild('embeddedTable') protected embeddedTable:WorkPackageEmbeddedTableComponent;
+ @ViewChild('embeddedTable') protected embeddedTable?:WorkPackageEmbeddedTableComponent;
constructor(protected queryUrlParamsHelper:UrlParamsHelperService) {
super();
@@ -57,7 +57,7 @@ export abstract class WorkPackageRelationQueryBase extends UntilDestroyedMixin {
* Request to refresh the results of the embedded table
*/
public refreshTable() {
- this.embeddedTable.isInitialized && this.embeddedTable.loadQuery(true, false);
+ this.embeddedTable?.isInitialized && this.embeddedTable.loadQuery(true, false);
}
/**