UNPKG

ng2-smart-table-custom

Version:

Angular Smart Table with inline-validations support

104 lines 3.58 kB
import { Subject } from 'rxjs/Subject'; var DataSource = (function () { function DataSource() { this.onChangedSource = new Subject(); this.onAddedSource = new Subject(); this.onUpdatedSource = new Subject(); this.onRemovedSource = new Subject(); } DataSource.prototype.refresh = function () { this.emitOnChanged('refresh'); }; DataSource.prototype.load = function (data) { this.emitOnChanged('load'); return Promise.resolve(); }; DataSource.prototype.onChanged = function () { return this.onChangedSource.asObservable(); }; DataSource.prototype.onAdded = function () { return this.onAddedSource.asObservable(); }; DataSource.prototype.onUpdated = function () { return this.onUpdatedSource.asObservable(); }; DataSource.prototype.onRemoved = function () { return this.onRemovedSource.asObservable(); }; DataSource.prototype.prepend = function (element) { this.emitOnAdded(element); this.emitOnChanged('prepend'); return Promise.resolve(); }; DataSource.prototype.append = function (element) { this.emitOnAdded(element); this.emitOnChanged('append'); return Promise.resolve(); }; DataSource.prototype.add = function (element) { this.emitOnAdded(element); this.emitOnChanged('add'); return Promise.resolve(); }; DataSource.prototype.remove = function (element) { this.emitOnRemoved(element); this.emitOnChanged('remove'); return Promise.resolve(); }; DataSource.prototype.update = function (element, values) { this.emitOnUpdated(element); this.emitOnChanged('update'); return Promise.resolve(); }; DataSource.prototype.empty = function () { this.emitOnChanged('empty'); return Promise.resolve(); }; DataSource.prototype.setSort = function (conf, doEmit) { if (doEmit) { this.emitOnChanged('sort'); } }; DataSource.prototype.setFilter = function (conf, andOperator, doEmit) { if (doEmit) { this.emitOnChanged('filter'); } }; DataSource.prototype.addFilter = function (fieldConf, andOperator, doEmit) { if (doEmit) { this.emitOnChanged('filter'); } }; DataSource.prototype.setPaging = function (page, perPage, doEmit) { if (doEmit) { this.emitOnChanged('paging'); } }; DataSource.prototype.setPage = function (page, doEmit) { if (doEmit) { this.emitOnChanged('page'); } }; DataSource.prototype.emitOnRemoved = function (element) { this.onRemovedSource.next(element); }; DataSource.prototype.emitOnUpdated = function (element) { this.onUpdatedSource.next(element); }; DataSource.prototype.emitOnAdded = function (element) { this.onAddedSource.next(element); }; DataSource.prototype.emitOnChanged = function (action) { var _this = this; this.getElements().then(function (elements) { return _this.onChangedSource.next({ action: action, elements: elements, paging: _this.getPaging(), filter: _this.getFilter(), sort: _this.getSort(), }); }); }; return DataSource; }()); export { DataSource }; //# sourceMappingURL=data-source.js.map