Skip to content

Commit

Permalink
Fix endpoint table --> card error
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Mar 14, 2019
1 parent b4110f8 commit 8c78afb
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Component, ComponentFactoryResolver, Input, OnDestroy, Type, ViewChild, ViewContainerRef } from '@angular/core';
import {
Component,
ComponentFactoryResolver,
ComponentRef,
Input,
OnDestroy,
Type,
ViewChild,
ViewContainerRef,
} from '@angular/core';

import { EndpointModel } from '../../../../../../../../store/src/types/endpoint.types';
import { getEndpointType } from '../../../../../../features/endpoints/endpoint-helpers';
Expand All @@ -12,8 +21,13 @@ import { EndpointListDetailsComponent, EndpointListHelper } from '../endpoint-li
})
export class TableCellEndpointDetailsComponent extends TableCellCustom<EndpointModel> implements OnDestroy {

private componentRef: ComponentRef<EndpointListDetailsComponent>;
@Input() component: Type<EndpointListDetailsComponent>;
@ViewChild('target', { read: ViewContainerRef }) target;

private endpointDetails: ViewContainerRef;
@ViewChild('target', { read: ViewContainerRef }) set target(content: ViewContainerRef) {
this.endpointDetails = content;
}

cell: EndpointListDetailsComponent;

Expand All @@ -32,8 +46,8 @@ export class TableCellEndpointDetailsComponent extends TableCellCustom<EndpointM
}
if (!this.cell) {
const res =
this.endpointListHelper.createEndpointDetails(e.listDetailsComponent, this.target, this.componentFactoryResolver);
this.target = res.componentRef;
this.endpointListHelper.createEndpointDetails(e.listDetailsComponent, this.endpointDetails, this.componentFactoryResolver);
this.componentRef = res.componentRef;
this.cell = res.component;
}

Expand All @@ -49,9 +63,9 @@ export class TableCellEndpointDetailsComponent extends TableCellCustom<EndpointM

ngOnDestroy(): void {
this.endpointListHelper.destroyEndpointDetails({
componentRef: this.target,
componentRef: this.componentRef,
component: this.cell,
endpointDetails: this.target
endpointDetails: this.endpointDetails
});
}
}

0 comments on commit 8c78afb

Please sign in to comment.