ng2-stable-nxtc
Version:
Angular Smart Table neXtCode Version
90 lines • 3.49 kB
JavaScript
export class Column {
constructor(id, settings, dataSet) {
this.id = id;
this.settings = settings;
this.dataSet = dataSet;
this.preTitle = '';
this.posTitle = '';
this.titleContainer = null;
this.titleContainerProps = null;
this.title = '';
this.type = '';
this.class = '';
this.width = '';
this.isSortable = false;
this.isEditable = true;
this.isAddable = true;
this.isFilterable = false;
this.sortDirection = '';
this.defaultSortDirection = '';
this.editor = { type: '', config: {}, component: null };
this.filter = { type: '', config: {} };
this.renderComponent = null;
// moneda
this.currency = {
symbol: '',
decimals: 0
};
// view class
this.viewClass = '';
this.process();
}
getOnComponentInitFunction() {
return this.onComponentInitFunction;
}
getCompareFunction() {
return this.compareFunction;
}
getValuePrepareFunction() {
return this.valuePrepareFunction;
}
getFilterFunction() {
return this.filterFunction;
}
getConfig() {
return this.editor && this.editor.config;
}
getFilterType() {
return this.filter && this.filter.type;
}
getFilterConfig() {
return this.filter && this.filter.config;
}
process() {
this.title = this.settings['title'];
this.preTitle = this.settings['preTitle'];
this.posTitle = this.settings['posTitle'];
this.titleContainer = this.settings['titleContainer'];
this.titleContainerProps = this.settings['titleContainerProps'];
this.class = this.settings['class'];
this.width = this.settings['width'];
this.type = this.prepareType();
this.editor = this.settings['editor'];
this.filter = this.settings['filter'];
this.renderComponent = this.settings['renderComponent'];
this.currency = this.settings['currency'];
this.viewClass = this.settings['viewClass'];
this.isFilterable = typeof this.settings['filter'] === 'undefined' ? true : !!this.settings['filter'];
this.defaultSortDirection = ['asc', 'desc']
.indexOf(this.settings['sortDirection']) !== -1 ? this.settings['sortDirection'] : '';
this.isSortable = typeof this.settings['sort'] === 'undefined' ? true : !!this.settings['sort'];
this.isEditable = typeof this.settings['editable'] === 'undefined' ? true : !!this.settings['editable'];
this.isAddable = typeof this.settings['addable'] === 'undefined' ? true : !!this.settings['addable'];
this.sortDirection = this.prepareSortDirection();
this.compareFunction = this.settings['compareFunction'];
this.valuePrepareFunction = this.settings['valuePrepareFunction'];
this.filterFunction = this.settings['filterFunction'];
this.onComponentInitFunction = this.settings['onComponentInitFunction'];
}
prepareType() {
return this.settings['type'] || this.determineType();
}
prepareSortDirection() {
return this.settings['sort'] === 'desc' ? 'desc' : 'asc';
}
determineType() {
// TODO: determine type by data
return 'text';
}
}
//# sourceMappingURL=column.js.map