UNPKG

igniteui-react-core

Version:
357 lines (356 loc) 12.2 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends, __values } from "tslib"; import { BaseTransactionService } from "./BaseTransactionService"; import { List$1 } from "./List$1"; import { TransactionHistory } from "./TransactionHistory"; import { Base, fromEnum, markType } from "./type"; import { Transaction } from "./Transaction"; import { TransactionCommit } from "./TransactionCommit"; import { Dictionary$2 } from "./Dictionary$2"; import { TransactionState } from "./TransactionState"; import { TransactionType } from "./TransactionType"; import { InvalidOperationException } from "./InvalidOperationException"; /** * @hidden */ var TransactionService = /** @class */ /*@__PURE__*/ (function (_super) { __extends(TransactionService, _super); function TransactionService(a, b, c) { var _this = _super.call(this, a, b, c) || this; _this.am = new List$1(Transaction.$, 0); _this.ak = new List$1(TransactionCommit.$, 0); _this.ai = null; _this.an = new List$1(TransactionHistory.$, 0); _this.al = new List$1(TransactionHistory.$, 0); _this.aj = null; _this.aj = c; if (_this.aj != null) { _this.ai = new Dictionary$2(Base.$, TransactionState.$, 2, _this.aj); } else { _this.ai = new Dictionary$2(Base.$, TransactionState.$, 0); } return _this; } TransactionService.prototype.get_l = function () { return true; }; TransactionService.prototype.set_l = function (a) { _super.prototype.set_l.call(this, a); }; TransactionService.prototype.get_k = function () { return this.an.count > 0; }; TransactionService.prototype.get_j = function () { return this.al.count > 0; }; TransactionService.prototype.af = function (a, b) { var c = null; if (a.containsKey(b.id)) { c = a.item(b.id); } if (c != null) { switch (b.type) { case TransactionType.Delete: if (c.transactionType == 0) { a.removeItem(b.id); } else if (c.transactionType == 1) { c.value = null; c.transactionType = TransactionType.Delete; } break; case 1: if (c.transactionType == 0 || c.transactionType == 1) { this.h(c.value, b.value); } break; } } else { a.addItem(b.id, new TransactionState(b.id, b.type, this.r(b.value))); } }; TransactionService.prototype.aq = function (a, b) { var c = null; if (a.containsKey(b.id)) { c = a.item(b.id); } switch (b.type) { case 0: if (c != null) { throw new InvalidOperationException(1, "Cannot add this transaction. A transaction with this ID already exists."); } break; case 1: case TransactionType.Delete: if (c != null && c.transactionType == TransactionType.Delete) { throw new InvalidOperationException(1, "Cannot add this transaction. A transaction with this ID has already been deleted."); } break; } }; TransactionService.prototype.z = function (a, b, c) { _super.prototype.z.call(this, a, b, c); switch (a) { case "IsEnabled": this.w(true, null); break; } }; TransactionService.prototype.v = function (a, b) { if (b === void 0) { b = false; } var c = (this.m || b) ? this.o : this.ai; var d = (this.m || b) ? this.q : this.am; this.aq(c, a); this.af(c, a); d.add(a); a.transactionID = TransactionService.ao++; if (!this.m && !b) { var e = new TransactionHistory(); e.transactions.add(a); this.an.insert(0, e); this.al.clear(); this.aa(3, e); } }; TransactionService.prototype.w = function (a, b) { if (b === void 0) { b = null; } if (b != null) { for (var c = 0; c < this.am.count; c++) { if (this.am._inner[c].id == b) { this.am.removeAt(c); c--; } } this.ai.removeItem(b); for (var d = 0; d < this.an.count; d++) { for (var e = 0; e < this.an._inner[d].transactions.count; e++) { if (this.an._inner[d].transactions._inner[e].id == b) { this.an._inner[d].transactions.removeAt(e); e--; } } if (this.an._inner[d].transactions.count == 0) { this.an.removeAt(d); d--; } } } else { if (this.aj != null) { this.ai = new Dictionary$2(Base.$, TransactionState.$, 2, this.aj); } else { this.ai = new Dictionary$2(Base.$, TransactionState.$, 0); } this.am.clear(); this.an.clear(); } this.al.clear(); _super.prototype.w.call(this, a, b); }; TransactionService.prototype.g = function (a) { var b = this.m ? this.o : this.ai; if (b.count > 0 && b.containsKey(a)) { return b.item(a); } return null; }; TransactionService.prototype.ah = function (a) { return _super.prototype.g.call(this, a); }; TransactionService.prototype.ag = function (a) { for (var b = this.ak.count - 1; b >= 0; b--) { if (this.ak._inner[b].b.containsKey(a)) { return this.ak._inner[b].b.item(a); } } return null; }; TransactionService.prototype.y = function (a) { this.m = false; if (a) { var b = new TransactionHistory(); for (var c = 0; c < this.q.count; c++) { var d = this.q._inner[c]; var e = this.o.item(d.id); this.am.add(d); this.af(this.ai, d); b.transactions.add(d); } this.an.insert(0, b); this.al.clear(); } _super.prototype.y.call(this, a); }; TransactionService.prototype.ap = function (a) { for (var b = 0; b < this.q.count; b++) { var c = this.q._inner[b]; if (c.transactionID == a) { this.am.add(c); this.af(this.ai, c); this.q.removeAt(b); this.o.clear(); for (var d = 0; d < this.q.count; d++) { this.af(this.o, this.q._inner[d]); } var e = new TransactionHistory(); e.transactions.add(c); this.an.insert(0, e); this.al.clear(); break; } } }; TransactionService.prototype.s = function (a, b) { var c = -1; if (this.ai.count > 0) { var d = new TransactionCommit(); d.id = TransactionService.ao++; d.a = this.a(-1); d.b = this.ai; d.d = -1; if (a) { d.d = this.ak.count; this.ak.add(d); } else { this.aa(5, d); } c = d.id; } this.w(b, null); return c; }; TransactionService.prototype.u = function (a) { var b = this.e(a); if (b != null) { this.aa(5, b); this.ak.removeAt(b.d); } }; TransactionService.prototype.ac = function (a) { var b = this.e(a); if (b != null) { this.ak.removeAt(b.d); } }; TransactionService.prototype.ae = function () { if (this.k) { var a = this.an._inner[0]; this.an.removeAt(0); var b = this.am.count - a.transactions.count; this.am.v(b, a.transactions.count); this.al.insert(0, a); this.ai.clear(); for (var c = 0; c < this.an.count; c++) { for (var d = 0; d < this.an._inner[c].transactions.count; d++) { this.af(this.ai, this.an._inner[c].transactions._inner[d]); } } this.aa(0, a); } }; TransactionService.prototype.ab = function () { if (this.j) { var a = this.al._inner[0]; this.al.removeAt(0); for (var b = 0; b < a.transactions.count; b++) { this.af(this.ai, a.transactions._inner[b]); this.am.add(a.transactions._inner[b]); } this.an.insert(0, a); this.aa(1, a); } }; TransactionService.prototype.a = function (a) { var e_1, _a, e_2, _b; if (a === void 0) { a = -1; } var b = new List$1(TransactionState.$, 0); if (a > -1) { var c = this.e(a); if (c != null) { try { for (var _c = __values(fromEnum(c.b.values)), _d = _c.next(); !_d.done; _d = _c.next()) { var d = _d.value; b.add(d); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_1) throw e_1.error; } } } } else { try { for (var _e = __values(fromEnum(this.ai.values)), _f = _e.next(); !_f.done; _f = _e.next()) { var e = _f.value; b.add(e); } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_f && !_f.done && (_b = _e.return)) _b.call(_e); } finally { if (e_2) throw e_2.error; } } } return b.toArray(); }; TransactionService.prototype.e = function (a) { for (var b = 0; b < this.ak.count; b++) { if (this.ak._inner[b].id == a) { return this.ak._inner[b]; } } return null; }; TransactionService.prototype.c = function (a) { if (a === void 0) { a = null; } if (a != null) { var b = new List$1(Transaction.$, 0); for (var c = 0; c < this.q.count; c++) { if (this.q._inner[c].id == a || this.aj.equalsC(this.q._inner[c].id, a)) { b.add(this.q._inner[c]); } } return b.toArray(); } return this.q.toArray(); }; TransactionService.$t = markType(TransactionService, 'TransactionService', BaseTransactionService.$); TransactionService.ao = 0; return TransactionService; }(BaseTransactionService)); export { TransactionService };