Skip to content

Commit

Permalink
Track custom actions so they don't get destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Aug 21, 2023
1 parent f134a97 commit 42bd191
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
}

Expand All @@ -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();
});
}
Expand Down

0 comments on commit 42bd191

Please sign in to comment.