Skip to content

Commit

Permalink
fix(CreateWorkItemOverlayComponent): allows overlay to display withou…
Browse files Browse the repository at this point in the history
…t errors

The https://api.openshift.io/api/spaces/<id>/workitemtypes API is no longer valid, but there is an alternative API we can use.
This also fixes an “Expression has changed” error when the overlay is opened.

Fixes: fabric8-ui/fabric8-planner#2571
  • Loading branch information
dlabrecq committed May 1, 2018
1 parent 7639d38 commit ed42503
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AfterViewInit, Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { Router } from '@angular/router';

import { Observable } from 'rxjs';
import { Observable, Subscription } from 'rxjs';

import { Broadcaster } from 'ngx-base';
import { Space, Spaces } from 'ngx-fabric8-wit';
Expand All @@ -19,27 +19,36 @@ import { WorkItemService } from 'fabric8-planner/app/services/work-item.service'
selector: 'fabric8-create-work-item-overlay',
templateUrl: './create-work-item-overlay.component.html'
})
export class CreateWorkItemOverlayComponent implements OnInit, AfterViewInit {

export class CreateWorkItemOverlayComponent implements OnDestroy, OnInit, AfterViewInit {
workItemSubscription: Subscription;
workItemTypes: Observable<any[]>;
space: Space;

@ViewChild('detailAddTypeSelector') overlay: WorkItemDetailAddTypeSelectorWidgetComponent;

constructor(
private router: Router,
private spaces: Spaces,
private broadcaster: Broadcaster,
private workItemService: WorkItemService
) { }
constructor(private router: Router,
private spaces: Spaces,
private broadcaster: Broadcaster,
private workItemService: WorkItemService) {
this.workItemSubscription = this.spaces.current.subscribe(space => {
this.space = space;
this.workItemTypes = this.workItemService.getWorkItemTypes2(this.space.relationships.workitemtypes.links.related);
});
}

ngOnInit() {
this.spaces.current.subscribe(space => this.space = space);
this.workItemTypes = this.workItemService.getWorkItemTypes();
}

ngOnDestroy(): void {
if (this.workItemSubscription !== undefined) {
this.workItemSubscription.unsubscribe();
}
}

ngAfterViewInit() {
this.overlay.open();
setTimeout(() => {
this.overlay.open();
}, 10);
}

onClose() {
Expand Down

0 comments on commit ed42503

Please sign in to comment.