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

Update relations counter correctly in new split screen

Henriette Darge101ddbea1bbd
diff --git a/frontend/src/app/core/path-helper/path-helper.service.ts b/frontend/src/app/core/path-helper/path-helper.service.ts
index 9fbd5a869bc..a24e9fb6ab0 100644
--- a/frontend/src/app/core/path-helper/path-helper.service.ts
+++ b/frontend/src/app/core/path-helper/path-helper.service.ts
@@ -288,6 +288,10 @@ export class PathHelperService {
return `${this.workPackagePath(workPackageId)}/progress/edit`;
}
+ public workPackageUpdateCounterPath(workPackageId:string|number, counter:string) {
+ return `${this.workPackagePath(workPackageId)}/split_view/update_counter?counter=${counter}`;
+ }
+
// Work Package Bulk paths
public workPackagesBulkEditPath() {
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 9693e42f00c..6f11aa8ff1e 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
@@ -43,6 +43,7 @@ import { HalEventsService } from 'core-app/features/hal/services/hal-events.serv
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { GroupDescriptor } from 'core-app/features/work-packages/components/wp-single-view/wp-single-view.component';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
+import { WorkPackageRelationsService } from 'core-app/features/work-packages/components/wp-relations/wp-relations.service';
@Component({
selector: 'wp-children-query',
@@ -76,13 +77,16 @@ export class WorkPackageChildrenQueryComponent extends WorkPackageRelationQueryB
),
];
- constructor(protected wpRelationsHierarchyService:WorkPackageRelationsHierarchyService,
+ constructor(
+ protected wpRelationsHierarchyService:WorkPackageRelationsHierarchyService,
protected PathHelper:PathHelperService,
protected wpInlineCreate:WorkPackageInlineCreateService,
protected halEvents:HalEventsService,
protected apiV3Service:ApiV3Service,
protected queryUrlParamsHelper:UrlParamsHelperService,
- readonly I18n:I18nService) {
+ readonly I18n:I18nService,
+ readonly wpRelations:WorkPackageRelationsService,
+ ) {
super(queryUrlParamsHelper);
}
@@ -116,6 +120,9 @@ export class WorkPackageChildrenQueryComponent extends WorkPackageRelationQueryB
filter(() => !!this.embeddedTable?.isInitialized),
this.untilDestroyed(),
)
- .subscribe(() => this.refreshTable());
+ .subscribe(() => {
+ this.wpRelations.updateCounter(this.workPackage);
+ this.refreshTable();
+ });
}
}
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.component.ts
index 03c6347d03b..458088971a0 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relation-row/wp-relation-row.component.ts
@@ -197,6 +197,8 @@ export class WorkPackageRelationRowComponent extends UntilDestroyedMixin impleme
.cache
.updateWorkPackage(this.relatedWorkPackage);
+ this.wpRelations.updateCounter(this.workPackage);
+
this.notificationService.showSave(this.relatedWorkPackage);
})
.catch((err:any) => this.notificationService.handleRawError(err,
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-create.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-create.component.ts
index 38d34ad55ba..3ac9ac22230 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-create.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relations-create.component.ts
@@ -1,5 +1,8 @@
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
-import { Component, Input } from '@angular/core';
+import {
+ Component,
+ Input,
+} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalEventsService } from 'core-app/features/hal/services/hal-events.service';
import { WorkPackageNotificationService } from 'core-app/features/work-packages/services/notifications/work-package-notification.service';
@@ -29,21 +32,12 @@ export class WorkPackageRelationsCreateComponent {
addNewRelation: this.I18n.t('js.relation_buttons.add_new_relation'),
};
- constructor(readonly I18n:I18nService,
+ constructor(
+ readonly I18n:I18nService,
protected wpRelations:WorkPackageRelationsService,
protected notificationService:WorkPackageNotificationService,
- protected halEvents:HalEventsService) {
- }
-
- public createRelation() {
- if (!this.selectedRelationType || !this.selectedWpId) {
- return;
- }
-
- this.isDisabled = true;
- this.createCommonRelation()
- .catch(() => this.isDisabled = false)
- .then(() => this.isDisabled = false);
+ protected halEvents:HalEventsService,
+ ) {
}
public onSelected(workPackage?:WorkPackageResource) {
@@ -64,6 +58,7 @@ export class WorkPackageRelationsCreateComponent {
relationType: this.selectedRelationType,
});
this.notificationService.showSave(this.workPackage);
+ this.wpRelations.updateCounter(this.workPackage);
this.toggleRelationsCreateForm();
})
.catch((err) => {
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts
index 8be4945eff0..84ae3d9bfb9 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts
@@ -11,6 +11,7 @@ import {
} from 'rxjs';
import { map, take } from 'rxjs/operators';
import { RelationResource } from 'core-app/features/hal/resources/relation-resource';
+import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
export type RelationsStateValue = { [relationId:string]:RelationResource };
@@ -27,9 +28,12 @@ export class RelationStateGroup extends StatesGroup {
@Injectable()
export class WorkPackageRelationsService extends StateCacheService<RelationsStateValue> {
- constructor(private PathHelper:PathHelperService,
+ constructor(
+ private PathHelper:PathHelperService,
private apiV3Service:ApiV3Service,
- private halResource:HalResourceService) {
+ private halResource:HalResourceService,
+ readonly turboRequests:TurboRequestsService,
+ ) {
super(new RelationStateGroup().relations);
}
@@ -172,6 +176,13 @@ export class WorkPackageRelationsService extends StateCacheService<RelationsStat
});
}
+ public updateCounter(workPackage:WorkPackageResource) {
+ if (workPackage.id) {
+ const url = this.PathHelper.workPackageUpdateCounterPath(workPackage.id, 'relations');
+ void this.turboRequests.request(url);
+ }
+ }
+
/**
* Merges a single relation
* @param relation
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts
index cf6e8306999..449e3b733b7 100644
--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/watchers-tab/watchers-tab.component.ts
@@ -182,7 +182,7 @@ export class WorkPackageWatchersTabComponent extends UntilDestroyedMixin impleme
}
public updateCounter() {
- const url = `${this.pathHelper.workPackagePath(this.workPackageId)}/split_view/update_counter?counter=watchers`;
+ const url = this.pathHelper.workPackageUpdateCounterPath(this.workPackageId, 'watchers');
void this.turboRequests.request(url);
}
}