rb-data-table
Version:
Angular Smart Table
63 lines • 3.03 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component, Input, ComponentFactoryResolver, ViewChild, ViewContainerRef, } from '@angular/core';
import { Cell } from '../../../lib/data-set/cell';
var CustomViewComponent = /** @class */ (function () {
function CustomViewComponent(resolver) {
this.resolver = resolver;
}
CustomViewComponent.prototype.ngOnInit = function () {
if (this.cell && !this.customComponent) {
this.createCustomComponent();
this.callOnComponentInit();
this.patchInstance();
}
};
CustomViewComponent.prototype.ngOnDestroy = function () {
if (this.customComponent) {
this.customComponent.destroy();
}
};
CustomViewComponent.prototype.createCustomComponent = function () {
var componentFactory = this.resolver.resolveComponentFactory(this.cell.getColumn().renderComponent);
this.customComponent = this.dynamicTarget.createComponent(componentFactory);
};
CustomViewComponent.prototype.callOnComponentInit = function () {
var onComponentInitFunction = this.cell.getColumn().getOnComponentInitFunction();
onComponentInitFunction && onComponentInitFunction(this.customComponent.instance);
};
CustomViewComponent.prototype.patchInstance = function () {
Object.assign(this.customComponent.instance, this.getPatch());
};
CustomViewComponent.prototype.getPatch = function () {
return {
value: this.cell.getValue(),
rowData: this.cell.getRow().getData()
};
};
__decorate([
Input(),
__metadata("design:type", Cell)
], CustomViewComponent.prototype, "cell", void 0);
__decorate([
ViewChild('dynamicTarget', { read: ViewContainerRef }),
__metadata("design:type", Object)
], CustomViewComponent.prototype, "dynamicTarget", void 0);
CustomViewComponent = __decorate([
Component({
selector: 'custom-view-component',
template: "\n <ng-template #dynamicTarget></ng-template>\n ",
}),
__metadata("design:paramtypes", [ComponentFactoryResolver])
], CustomViewComponent);
return CustomViewComponent;
}());
export { CustomViewComponent };
//# sourceMappingURL=custom-view.component.js.map