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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[33912] Correct change detection on custom actions
Oliver Günther12e9b254857b
diff --git a/frontend/src/app/components/wp-custom-actions/wp-custom-actions.component.ts b/frontend/src/app/components/wp-custom-actions/wp-custom-actions.component.tsindex b9cd855d7e6..e2289d289f3 100644--- a/frontend/src/app/components/wp-custom-actions/wp-custom-actions.component.ts+++ b/frontend/src/app/components/wp-custom-actions/wp-custom-actions.component.ts@@ -26,18 +26,41 @@// See docs/COPYRIGHT.rdoc for more details.// ++-import {Component, Input} from '@angular/core';+import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit} from '@angular/core';import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';+import {APIV3Service} from "core-app/modules/apiv3/api-v3.service";+import {CustomActionResource} from "core-app/modules/hal/resources/custom-action-resource";+import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";@Component({selector: 'wp-custom-actions',- templateUrl: './wp-custom-actions.component.html'+ templateUrl: './wp-custom-actions.component.html',+ changeDetection: ChangeDetectionStrategy.OnPush})-export class WpCustomActionsComponent {+export class WpCustomActionsComponent extends UntilDestroyedMixin implements OnInit {@Input() workPackage:WorkPackageResource;- public get actions() {- return this.workPackage.customActions;+ actions:CustomActionResource[] = [];++ constructor(readonly apiV3Service:APIV3Service,+ readonly cdRef:ChangeDetectorRef) {+ super();+ }++ ngOnInit() {+ this+ .apiV3Service+ .work_packages+ .id(this.workPackage.id!)+ .requireAndStream()+ .pipe(+ this.untilDestroyed()+ )+ .subscribe((wp) => {+ this.actions = [...wp.customActions];+ this.cdRef.detectChanges();+ });}+}