ng2-stable-nxtc
Version:
Angular Smart Table neXtCode Version
78 lines • 3.86 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, Output, EventEmitter, ViewChild, ComponentFactoryResolver } from '@angular/core';
import { Column } from '../../../lib/data-set/column';
import { DataSource } from '../../../lib/data-source/data-source';
import { CustomTitleDirective } from './custom-title.component/custom-title.directive';
import { CustomTitleComponent } from './custom-title.component/custom-title.component';
import { TitleComponent } from './title/title.component';
let ColumnTitleComponent = class ColumnTitleComponent {
constructor(componentFactoryResolver) {
this.componentFactoryResolver = componentFactoryResolver;
this.sort = new EventEmitter();
}
ngOnInit() {
let componentFactory, viewContainerRef, componentRef;
viewContainerRef = this.customTitleDirective.viewContainerRef;
if (this.column.titleContainer) {
let customTitleComponent = new CustomTitleComponent(this.column.titleContainer);
componentFactory = this.componentFactoryResolver.resolveComponentFactory(customTitleComponent.component);
componentRef = viewContainerRef.createComponent(componentFactory);
let componentInstance = componentRef.instance;
if (this.column.titleContainerProps) {
this.column.titleContainerProps.forEach(v => {
componentInstance.setProp(v.prop, v.value);
});
}
viewContainerRef = componentInstance.viewTitleContainerRef;
}
componentFactory = this.componentFactoryResolver.resolveComponentFactory(TitleComponent);
componentRef = viewContainerRef.createComponent(componentFactory);
this.titleComponent = componentRef.instance;
this.titleComponent.column = this.column;
this.titleComponent.source = this.source;
this.titleComponent.sort.subscribe((event) => this.sort.emit(event));
}
ngOnChanges(changes) {
if (this.titleComponent) {
this.titleComponent.column = this.column;
this.titleComponent.source = this.source;
}
}
};
__decorate([
Input(),
__metadata("design:type", Column)
], ColumnTitleComponent.prototype, "column", void 0);
__decorate([
Input(),
__metadata("design:type", DataSource)
], ColumnTitleComponent.prototype, "source", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], ColumnTitleComponent.prototype, "sort", void 0);
__decorate([
ViewChild(CustomTitleDirective),
__metadata("design:type", CustomTitleDirective)
], ColumnTitleComponent.prototype, "customTitleDirective", void 0);
ColumnTitleComponent = __decorate([
Component({
selector: 'ng2-st-column-title',
template: `
<div class="ng2-smart-title">
<ng-template customTitleDirective></ng-template>
</div>
`,
}),
__metadata("design:paramtypes", [ComponentFactoryResolver])
], ColumnTitleComponent);
export { ColumnTitleComponent };
//# sourceMappingURL=column-title.component.js.map