UNPKG

angular4-material-table

Version:

Angular 4 table based on @angular/cdk table structure, to allow row insertion, edition, validation and deletion.

33 lines 1.08 kB
import cloneDeep from 'lodash.clonedeep'; var TableElement = /** @class */ (function () { function TableElement(init) { Object.assign(this, init); } TableElement.prototype.delete = function () { this.source.delete(this.id); }; TableElement.prototype.confirmEditCreate = function () { this.originalData = undefined; if (this.id == -1) this.source.confirmCreate(this); else this.source.confirmEdit(this); }; TableElement.prototype.startEdit = function () { this.originalData = cloneDeep(this.currentData); this.editing = true; this.validator.enable(); }; TableElement.prototype.cancelOrDelete = function () { if (this.id == -1 || !this.editing) this.delete(); else { this.currentData = this.originalData; this.editing = false; this.validator.disable(); } }; return TableElement; }()); export { TableElement }; //# sourceMappingURL=table-element.js.map