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

Track custom actions so they don't get destroyed

Oliver Günther42bd1911afc4
diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.html b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.html
index af9ac4c6fe3..53e8081585e 100644
--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.html
+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.html
@@ -1,5 +1,5 @@
<wp-custom-action
- *ngFor="let action of actions"
+ *ngFor="let action of actions; trackBy: trackByHref"
[workPackage]="workPackage"
[action]="action"
class="custom-action">
diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts
index f27e7508bf9..744bd54b26d 100644
--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/wp-custom-actions.component.ts
@@ -33,6 +33,7 @@ import { WorkPackageResource } from 'core-app/features/hal/resources/work-packag
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { CustomActionResource } from 'core-app/features/hal/resources/custom-action-resource';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
+import { trackByHref } from 'core-app/shared/helpers/angular/tracking-functions';
@Component({
selector: 'wp-custom-actions',
@@ -42,10 +43,14 @@ import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destr
export class WpCustomActionsComponent extends UntilDestroyedMixin implements OnInit {
@Input() workPackage:WorkPackageResource;
+ trackByHref = trackByHref;
+
actions:CustomActionResource[] = [];
- constructor(readonly apiV3Service:ApiV3Service,
- readonly cdRef:ChangeDetectorRef) {
+ constructor(
+ readonly apiV3Service:ApiV3Service,
+ readonly cdRef:ChangeDetectorRef,
+ ) {
super();
}
@@ -59,7 +64,7 @@ export class WpCustomActionsComponent extends UntilDestroyedMixin implements OnI
this.untilDestroyed(),
)
.subscribe((wp) => {
- this.actions = wp.customActions ? [...wp.customActions] : [];
+ this.actions = wp.customActions as CustomActionResource[];
this.cdRef.detectChanges();
});
}