@azrico/webobject 1.5.70 → 1.5.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/src/WebObjects/ParentWebObject.d.ts +24 -24
- package/dist/src/WebObjects/ParentWebObject.js +7 -7
- package/dist/src/WebObjects/WebObject.d.ts +153 -153
- package/dist/src/WebObjects/WebObject.js +476 -561
- package/dist/src/WebObjects/WebObjectHelper.d.ts +9 -9
- package/dist/src/WebObjects/WebObjectHelper.js +4 -4
- package/dist/src/WebObjects/WebObjectHelper.test.d.ts +1 -1
- package/dist/src/WebObjects/WebObjectHelper.test.js +1 -1
- package/dist/src/WebObjects/WebObjectManager.d.ts +68 -68
- package/dist/src/WebObjects/WebObjectManager.js +303 -350
- package/dist/src/WebObjects/WebObjectPathHelper.d.ts +36 -36
- package/dist/src/WebObjects/WebObjectPathHelper.js +31 -39
- package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -1
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +55 -61
- package/dist/src/index.d.ts +10 -10
- package/dist/src/structs/DummyObject.d.ts +5 -5
- package/dist/src/structs/DummyObject.js +1 -1
- package/dist/src/structs/MapableObject.d.ts +43 -43
- package/dist/src/structs/MapableObject.js +3 -3
- package/dist/src/structs/MetaObject.d.ts +15 -15
- package/dist/src/structs/MetaObject.js +19 -25
- package/dist/src/structs/ObjectArray.d.ts +10 -10
- package/dist/src/structs/ObjectArray.js +1 -1
- package/dist/src/structs/ObjectManager.d.ts +140 -140
- package/dist/src/structs/ObjectManager.js +202 -223
- package/dist/src/structs/ObjectWithTemp.d.ts +17 -17
- package/dist/src/structs/ObjectWithTemp.js +13 -17
- package/dist/src/structs/SimpleObject.d.ts +318 -303
- package/dist/src/structs/SimpleObject.js +423 -467
- package/package.json +63 -82
|
@@ -14,14 +14,16 @@ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArra
|
|
|
14
14
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
15
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
16
16
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
17
|
-
function
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
19
18
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
20
19
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
21
20
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
22
|
-
function
|
|
21
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
22
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
23
23
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
24
24
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
25
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
27
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
26
28
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
27
29
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
@@ -36,24 +38,15 @@ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !==
|
|
|
36
38
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
37
39
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
38
40
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
39
|
-
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
40
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
41
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
42
41
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
43
42
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
44
|
-
function _toPrimitive(t,
|
|
45
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
46
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
47
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
48
|
-
var _objectColor = /*#__PURE__*/new WeakMap();
|
|
49
|
-
var _SimpleObject_brand = /*#__PURE__*/new WeakSet();
|
|
43
|
+
function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
50
44
|
var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
51
45
|
function SimpleObject() {
|
|
52
46
|
var _this;
|
|
53
47
|
var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
54
48
|
_classCallCheck(this, SimpleObject);
|
|
55
49
|
_this = _callSuper(this, SimpleObject);
|
|
56
|
-
_classPrivateMethodInitSpec(_this, _SimpleObject_brand);
|
|
57
50
|
//an exact copy of this object is stored here
|
|
58
51
|
_defineProperty(_this, "__originalobject", void 0);
|
|
59
52
|
//changes are saved here
|
|
@@ -83,14 +76,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
83
76
|
_defineProperty(_this, "__saveResultType", void 0);
|
|
84
77
|
//init function
|
|
85
78
|
_defineProperty(_this, "__initialized", void 0);
|
|
86
|
-
|
|
79
|
+
_defineProperty(_this, "__objectColor", void 0);
|
|
87
80
|
//id in the database
|
|
88
81
|
_defineProperty(_this, "_id", "");
|
|
89
82
|
//sequence key (usually managed by the database)
|
|
90
83
|
_defineProperty(_this, "_index_key", "");
|
|
91
84
|
//sequence value , used to index the object with increasing numbers
|
|
92
85
|
_defineProperty(_this, "_index_value", -1);
|
|
93
|
-
_defineProperty(_this, "getSubValue",
|
|
86
|
+
_defineProperty(_this, "getSubValue", _this.getSubProperty);
|
|
94
87
|
_defineProperty(_this, "setDefault", _this.setDefaultValue);
|
|
95
88
|
_defineProperty(_this, "setTemp", _this.set_temp);
|
|
96
89
|
_defineProperty(_this, "get_managerClass", function () {
|
|
@@ -125,7 +118,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
125
118
|
var keysp = key.split(".");
|
|
126
119
|
var key_part = keysp.shift();
|
|
127
120
|
var subkey_part = keysp.shift();
|
|
128
|
-
used_value =
|
|
121
|
+
used_value = this.getSubProperty(key_part, subkey_part);
|
|
129
122
|
} else {
|
|
130
123
|
/* --------------------------- using this or delta -------------------------- */
|
|
131
124
|
var self_key = key;
|
|
@@ -134,21 +127,21 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
134
127
|
}
|
|
135
128
|
return is_fnc ? (0, _object.fn_eval_this)(this, used_value) : used_value;
|
|
136
129
|
}
|
|
137
|
-
/**
|
|
138
|
-
* static get method for SimpleObject
|
|
139
|
-
* @param obj
|
|
140
|
-
* @param key
|
|
141
|
-
* @param original
|
|
142
|
-
* @returns
|
|
130
|
+
/**
|
|
131
|
+
* static get method for SimpleObject
|
|
132
|
+
* @param obj
|
|
133
|
+
* @param key
|
|
134
|
+
* @param original
|
|
135
|
+
* @returns
|
|
143
136
|
*/
|
|
144
137
|
}, {
|
|
145
138
|
key: "use",
|
|
146
139
|
value:
|
|
147
|
-
/**
|
|
148
|
-
* use a property from the object, this will return latest value of the property
|
|
149
|
-
* uses `EventManager` to detect changes
|
|
150
|
-
*
|
|
151
|
-
* Only objects with a manager can use this function
|
|
140
|
+
/**
|
|
141
|
+
* use a property from the object, this will return latest value of the property
|
|
142
|
+
* uses `EventManager` to detect changes
|
|
143
|
+
*
|
|
144
|
+
* Only objects with a manager can use this function
|
|
152
145
|
*/
|
|
153
146
|
function use(key) {
|
|
154
147
|
if (this.manager == null) {
|
|
@@ -161,16 +154,24 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
161
154
|
}
|
|
162
155
|
return property_obj;
|
|
163
156
|
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "getSubProperty",
|
|
159
|
+
value: function getSubProperty(key, subkey) {
|
|
160
|
+
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
161
|
+
var subobj = this.get(key, original);
|
|
162
|
+
if (subobj == null || _typeof(subobj) !== "object") return undefined;
|
|
163
|
+
return subobj[subkey];
|
|
164
|
+
}
|
|
164
165
|
}, {
|
|
165
166
|
key: "setDefaultValue",
|
|
166
167
|
value: /* -------------------------------------------------------------------------- */
|
|
167
168
|
/* set */
|
|
168
169
|
/* -------------------------------------------------------------------------- */
|
|
169
|
-
/**
|
|
170
|
-
* set value of a key only if the value is empty (null,undef,"")
|
|
171
|
-
* @param key
|
|
172
|
-
* @param value
|
|
173
|
-
* @returns
|
|
170
|
+
/**
|
|
171
|
+
* set value of a key only if the value is empty (null,undef,"")
|
|
172
|
+
* @param key
|
|
173
|
+
* @param value
|
|
174
|
+
* @returns
|
|
174
175
|
*/
|
|
175
176
|
function setDefaultValue(key, value) {
|
|
176
177
|
//@ts-ignore
|
|
@@ -191,18 +192,54 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
191
192
|
return false;
|
|
192
193
|
}
|
|
193
194
|
}, {
|
|
194
|
-
key: "
|
|
195
|
-
value: (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
key: "setSubProperty",
|
|
196
|
+
value: function setSubProperty(key, subkey, value) {
|
|
197
|
+
var subobj = this.get(key);
|
|
198
|
+
//@ts-ignore
|
|
199
|
+
if (subobj == null || _typeof(subobj) !== "object") subobj = {};else subobj = _objectSpread({}, subobj); //make a clone so we dont update the original
|
|
200
|
+
subobj[subkey] = value;
|
|
201
|
+
this.setProperty(key, subobj);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* update a property on this object by updating the `__delta`
|
|
205
|
+
* or update the object property directly depending on `__use_delta` setting
|
|
206
|
+
*
|
|
207
|
+
* @param key
|
|
208
|
+
* @param value
|
|
203
209
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
}, {
|
|
211
|
+
key: "setProperty",
|
|
212
|
+
value: function setProperty(key, value) {
|
|
213
|
+
var checkIsChanged = false;
|
|
214
|
+
if (this.__use_delta) {
|
|
215
|
+
if (this[key] === value) {
|
|
216
|
+
/**
|
|
217
|
+
* we set something back to its original value
|
|
218
|
+
* no need to save it as delta
|
|
219
|
+
*/
|
|
220
|
+
delete this.__delta[key];
|
|
221
|
+
////checkIsChanged = true; //check if we should set __has_delta to false
|
|
222
|
+
} else {
|
|
223
|
+
this.__delta[key] = value; //always update delta to keep track of changes
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
this[key] = value; //on noDelta mode update the object itself
|
|
227
|
+
this.__delta[key] = value; //always update delta to keep track of changes
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* set value and run the event handlers if needed
|
|
233
|
+
* @param key
|
|
234
|
+
* @param value
|
|
235
|
+
* @param shouldNotify
|
|
236
|
+
* @param autoApply if the field is not in delta, instantly calls the `apply` function to remove from delta
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
239
|
+
}, {
|
|
240
|
+
key: "set",
|
|
241
|
+
value: (function () {
|
|
242
|
+
var _set = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(key, value) {
|
|
206
243
|
var shouldNotify,
|
|
207
244
|
autoApply,
|
|
208
245
|
isValueChanged,
|
|
@@ -218,30 +255,27 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
218
255
|
subval,
|
|
219
256
|
old_value,
|
|
220
257
|
_this$manager,
|
|
221
|
-
_args = arguments
|
|
222
|
-
|
|
223
|
-
|
|
258
|
+
_args = arguments,
|
|
259
|
+
_t;
|
|
260
|
+
return _regenerator().w(function (_context) {
|
|
261
|
+
while (1) switch (_context.n) {
|
|
224
262
|
case 0:
|
|
225
263
|
shouldNotify = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
|
|
226
264
|
autoApply = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
|
|
227
265
|
if (this.canModify) {
|
|
228
|
-
_context.
|
|
266
|
+
_context.n = 2;
|
|
229
267
|
break;
|
|
230
268
|
}
|
|
231
269
|
if (!(this.__throw_errors !== false)) {
|
|
232
|
-
_context.
|
|
270
|
+
_context.n = 1;
|
|
233
271
|
break;
|
|
234
272
|
}
|
|
235
273
|
throw Error("Cant use set(".concat(String(key), ") when on readonly mode"));
|
|
236
|
-
case
|
|
237
|
-
return _context.
|
|
238
|
-
case
|
|
239
|
-
keyExists = false;
|
|
240
|
-
/* -------------------------------------------------------------------------- */
|
|
241
|
-
/* set all values from object */
|
|
242
|
-
/* -------------------------------------------------------------------------- */
|
|
274
|
+
case 1:
|
|
275
|
+
return _context.a(2, false);
|
|
276
|
+
case 2:
|
|
243
277
|
if (!(_typeof(key) === "object")) {
|
|
244
|
-
_context.
|
|
278
|
+
_context.n = 7;
|
|
245
279
|
break;
|
|
246
280
|
}
|
|
247
281
|
finalResult = true;
|
|
@@ -249,28 +283,28 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
249
283
|
value = key;
|
|
250
284
|
checkKeys = changeablesOnly ? (0, _object.array_intersection)(this.__changeables, Object.keys(value)) : Object.keys(value);
|
|
251
285
|
index = 0;
|
|
252
|
-
case
|
|
286
|
+
case 3:
|
|
253
287
|
if (!(index < checkKeys.length)) {
|
|
254
|
-
_context.
|
|
288
|
+
_context.n = 6;
|
|
255
289
|
break;
|
|
256
290
|
}
|
|
257
291
|
_key = checkKeys[index];
|
|
258
|
-
_context.
|
|
292
|
+
_context.n = 4;
|
|
259
293
|
return this.set(_key, value[_key], shouldNotify, autoApply);
|
|
260
|
-
case
|
|
261
|
-
|
|
262
|
-
if (!(false ==
|
|
263
|
-
_context.
|
|
294
|
+
case 4:
|
|
295
|
+
_t = _context.v;
|
|
296
|
+
if (!(false == _t)) {
|
|
297
|
+
_context.n = 5;
|
|
264
298
|
break;
|
|
265
299
|
}
|
|
266
300
|
finalResult = false;
|
|
267
|
-
case
|
|
301
|
+
case 5:
|
|
268
302
|
index++;
|
|
269
|
-
_context.
|
|
303
|
+
_context.n = 3;
|
|
270
304
|
break;
|
|
271
|
-
case
|
|
272
|
-
return _context.
|
|
273
|
-
case
|
|
305
|
+
case 6:
|
|
306
|
+
return _context.a(2, finalResult);
|
|
307
|
+
case 7:
|
|
274
308
|
if (typeof key === "string" && key.includes(".")) {
|
|
275
309
|
/* -------------------------------------------------------------------------- */
|
|
276
310
|
/* set value of object */
|
|
@@ -279,12 +313,12 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
279
313
|
mkey = keysp.shift();
|
|
280
314
|
keyExists = mkey in this.__delta;
|
|
281
315
|
subkey_part = keysp.shift(); //if accessing subval of an object, make sure the object is not null
|
|
282
|
-
subval =
|
|
316
|
+
subval = this.getSubProperty(mkey, subkey_part);
|
|
283
317
|
isValueChanged = !(0, _object.object_equals)(subval, value, {
|
|
284
318
|
ignoredStartingWords: "_",
|
|
285
319
|
strictArrayCheck: true
|
|
286
320
|
});
|
|
287
|
-
if (isValueChanged)
|
|
321
|
+
if (isValueChanged) this.setSubProperty(mkey, subkey_part, value);
|
|
288
322
|
} else {
|
|
289
323
|
/* -------------------------------------------------------------------------- */
|
|
290
324
|
/* set basic value */
|
|
@@ -296,35 +330,32 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
296
330
|
strictArrayCheck: true,
|
|
297
331
|
ignoredStartingWords: "_"
|
|
298
332
|
});
|
|
299
|
-
if (isValueChanged)
|
|
333
|
+
if (isValueChanged) this.setProperty(mkey, value);
|
|
300
334
|
}
|
|
301
335
|
if (autoApply && keyExists === false) {
|
|
302
|
-
/**
|
|
303
|
-
* if the field is not in delta
|
|
304
|
-
* instantly calls the `apply` function to remove from delta
|
|
336
|
+
/**
|
|
337
|
+
* if the field is not in delta
|
|
338
|
+
* instantly calls the `apply` function to remove from delta
|
|
305
339
|
*/
|
|
306
340
|
this.apply(mkey);
|
|
307
341
|
if (shouldNotify === "auto") shouldNotify = false;
|
|
308
342
|
}
|
|
309
343
|
if (isValueChanged) {
|
|
310
|
-
/**
|
|
311
|
-
* notify the manager when the state of `__has_delta` is changed
|
|
312
|
-
* managers can use this to detect if they need to save
|
|
344
|
+
/**
|
|
345
|
+
* notify the manager when the state of `__has_delta` is changed
|
|
346
|
+
* managers can use this to detect if they need to save
|
|
313
347
|
*/
|
|
314
348
|
(_this$manager = this.manager) === null || _this$manager === void 0 || _this$manager.checkIsChanged();
|
|
315
349
|
}
|
|
316
350
|
/* --------------------------------- notify --------------------------------- */
|
|
317
351
|
if (!(shouldNotify === true || shouldNotify === "auto" && isValueChanged)) {
|
|
318
|
-
_context.
|
|
352
|
+
_context.n = 8;
|
|
319
353
|
break;
|
|
320
354
|
}
|
|
321
|
-
_context.
|
|
355
|
+
_context.n = 8;
|
|
322
356
|
return this.notifyChanged("", key, value);
|
|
323
|
-
case
|
|
324
|
-
return _context.
|
|
325
|
-
case 33:
|
|
326
|
-
case "end":
|
|
327
|
-
return _context.stop();
|
|
357
|
+
case 8:
|
|
358
|
+
return _context.a(2, isValueChanged);
|
|
328
359
|
}
|
|
329
360
|
}, _callee, this);
|
|
330
361
|
}));
|
|
@@ -333,31 +364,28 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
333
364
|
}
|
|
334
365
|
return set;
|
|
335
366
|
}()
|
|
336
|
-
/**
|
|
337
|
-
* @deprecated use `set`
|
|
338
|
-
* set value and run the event handlers if needed
|
|
339
|
-
* @return true if changed , false otherwise
|
|
367
|
+
/**
|
|
368
|
+
* @deprecated use `set`
|
|
369
|
+
* set value and run the event handlers if needed
|
|
370
|
+
* @return true if changed , false otherwise
|
|
340
371
|
*/
|
|
341
372
|
)
|
|
342
373
|
}, {
|
|
343
374
|
key: "setValue",
|
|
344
375
|
value: (function () {
|
|
345
|
-
var _setValue = _asyncToGenerator(/*#__PURE__*/
|
|
376
|
+
var _setValue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(key, value) {
|
|
346
377
|
var shouldNotify,
|
|
347
378
|
autoApply,
|
|
348
379
|
_args2 = arguments;
|
|
349
|
-
return
|
|
350
|
-
while (1) switch (_context2.
|
|
380
|
+
return _regenerator().w(function (_context2) {
|
|
381
|
+
while (1) switch (_context2.n) {
|
|
351
382
|
case 0:
|
|
352
383
|
shouldNotify = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : "auto";
|
|
353
384
|
autoApply = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : false;
|
|
354
|
-
_context2.
|
|
385
|
+
_context2.n = 1;
|
|
355
386
|
return this.set(key, value, shouldNotify, autoApply);
|
|
356
|
-
case
|
|
357
|
-
return _context2.
|
|
358
|
-
case 5:
|
|
359
|
-
case "end":
|
|
360
|
-
return _context2.stop();
|
|
387
|
+
case 1:
|
|
388
|
+
return _context2.a(2, _context2.v);
|
|
361
389
|
}
|
|
362
390
|
}, _callee2, this);
|
|
363
391
|
}));
|
|
@@ -366,29 +394,26 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
366
394
|
}
|
|
367
395
|
return setValue;
|
|
368
396
|
}()
|
|
369
|
-
/**
|
|
370
|
-
* @deprecated use set function
|
|
397
|
+
/**
|
|
398
|
+
* @deprecated use set function
|
|
371
399
|
*/
|
|
372
400
|
)
|
|
373
401
|
}, {
|
|
374
402
|
key: "setAll",
|
|
375
403
|
value: (function () {
|
|
376
|
-
var _setAll = _asyncToGenerator(/*#__PURE__*/
|
|
404
|
+
var _setAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(key, value) {
|
|
377
405
|
var shouldNotify,
|
|
378
406
|
autoApply,
|
|
379
407
|
_args3 = arguments;
|
|
380
|
-
return
|
|
381
|
-
while (1) switch (_context3.
|
|
408
|
+
return _regenerator().w(function (_context3) {
|
|
409
|
+
while (1) switch (_context3.n) {
|
|
382
410
|
case 0:
|
|
383
411
|
shouldNotify = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : "auto";
|
|
384
412
|
autoApply = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : false;
|
|
385
|
-
_context3.
|
|
413
|
+
_context3.n = 1;
|
|
386
414
|
return this.set(key, value, shouldNotify, autoApply);
|
|
387
|
-
case
|
|
388
|
-
return _context3.
|
|
389
|
-
case 5:
|
|
390
|
-
case "end":
|
|
391
|
-
return _context3.stop();
|
|
415
|
+
case 1:
|
|
416
|
+
return _context3.a(2, _context3.v);
|
|
392
417
|
}
|
|
393
418
|
}, _callee3, this);
|
|
394
419
|
}));
|
|
@@ -397,31 +422,28 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
397
422
|
}
|
|
398
423
|
return setAll;
|
|
399
424
|
}()
|
|
400
|
-
/**
|
|
401
|
-
* set value and run the event handlers if needed
|
|
402
|
-
*
|
|
403
|
-
* if the field is not in delta instantly calls the `apply` function to remove from delta
|
|
404
|
-
* @param key
|
|
405
|
-
* @param value
|
|
425
|
+
/**
|
|
426
|
+
* set value and run the event handlers if needed
|
|
427
|
+
*
|
|
428
|
+
* if the field is not in delta instantly calls the `apply` function to remove from delta
|
|
429
|
+
* @param key
|
|
430
|
+
* @param value
|
|
406
431
|
*/
|
|
407
432
|
)
|
|
408
433
|
}, {
|
|
409
434
|
key: "setPreferApply",
|
|
410
435
|
value: (function () {
|
|
411
|
-
var _setPreferApply = _asyncToGenerator(/*#__PURE__*/
|
|
436
|
+
var _setPreferApply = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(key, value) {
|
|
412
437
|
var shouldNotify,
|
|
413
438
|
_args4 = arguments;
|
|
414
|
-
return
|
|
415
|
-
while (1) switch (_context4.
|
|
439
|
+
return _regenerator().w(function (_context4) {
|
|
440
|
+
while (1) switch (_context4.n) {
|
|
416
441
|
case 0:
|
|
417
442
|
shouldNotify = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "auto";
|
|
418
|
-
_context4.
|
|
443
|
+
_context4.n = 1;
|
|
419
444
|
return this.set(key, value, shouldNotify, true);
|
|
420
|
-
case
|
|
421
|
-
return _context4.
|
|
422
|
-
case 4:
|
|
423
|
-
case "end":
|
|
424
|
-
return _context4.stop();
|
|
445
|
+
case 1:
|
|
446
|
+
return _context4.a(2, _context4.v);
|
|
425
447
|
}
|
|
426
448
|
}, _callee4, this);
|
|
427
449
|
}));
|
|
@@ -430,32 +452,29 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
430
452
|
}
|
|
431
453
|
return setPreferApply;
|
|
432
454
|
}()
|
|
433
|
-
/**
|
|
434
|
-
* set key of subObject
|
|
435
|
-
* @param key
|
|
436
|
-
* @param value
|
|
437
|
-
* @param subvalue
|
|
438
|
-
* @param sendChanges
|
|
439
|
-
* @return true if changed , false otherwise
|
|
455
|
+
/**
|
|
456
|
+
* set key of subObject
|
|
457
|
+
* @param key
|
|
458
|
+
* @param value
|
|
459
|
+
* @param subvalue
|
|
460
|
+
* @param sendChanges
|
|
461
|
+
* @return true if changed , false otherwise
|
|
440
462
|
*/
|
|
441
463
|
)
|
|
442
464
|
}, {
|
|
443
465
|
key: "setSubValue",
|
|
444
466
|
value: (function () {
|
|
445
|
-
var _setSubValue = _asyncToGenerator(/*#__PURE__*/
|
|
467
|
+
var _setSubValue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(key, objKey, subvalue) {
|
|
446
468
|
var sendChanges,
|
|
447
469
|
_args5 = arguments;
|
|
448
|
-
return
|
|
449
|
-
while (1) switch (_context5.
|
|
470
|
+
return _regenerator().w(function (_context5) {
|
|
471
|
+
while (1) switch (_context5.n) {
|
|
450
472
|
case 0:
|
|
451
473
|
sendChanges = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : "auto";
|
|
452
|
-
_context5.
|
|
474
|
+
_context5.n = 1;
|
|
453
475
|
return this.set("".concat(String(key), ".").concat(objKey), subvalue, sendChanges);
|
|
454
|
-
case
|
|
455
|
-
return _context5.
|
|
456
|
-
case 4:
|
|
457
|
-
case "end":
|
|
458
|
-
return _context5.stop();
|
|
476
|
+
case 1:
|
|
477
|
+
return _context5.a(2, _context5.v);
|
|
459
478
|
}
|
|
460
479
|
}, _callee5, this);
|
|
461
480
|
}));
|
|
@@ -467,29 +486,26 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
467
486
|
}, {
|
|
468
487
|
key: "set_temp",
|
|
469
488
|
value: function () {
|
|
470
|
-
var _set_temp = _asyncToGenerator(/*#__PURE__*/
|
|
489
|
+
var _set_temp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(key, value) {
|
|
471
490
|
var sendChanges,
|
|
472
491
|
isValueChanged,
|
|
473
492
|
_args6 = arguments;
|
|
474
|
-
return
|
|
475
|
-
while (1) switch (_context6.
|
|
493
|
+
return _regenerator().w(function (_context6) {
|
|
494
|
+
while (1) switch (_context6.n) {
|
|
476
495
|
case 0:
|
|
477
496
|
sendChanges = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : false;
|
|
478
|
-
_context6.
|
|
497
|
+
_context6.n = 1;
|
|
479
498
|
return _superPropGet(SimpleObject, "set_temp", this, 3)([key, value]);
|
|
480
|
-
case
|
|
481
|
-
isValueChanged = _context6.
|
|
499
|
+
case 1:
|
|
500
|
+
isValueChanged = _context6.v;
|
|
482
501
|
if (!(sendChanges === true || sendChanges === "auto" && isValueChanged)) {
|
|
483
|
-
_context6.
|
|
502
|
+
_context6.n = 2;
|
|
484
503
|
break;
|
|
485
504
|
}
|
|
486
|
-
_context6.
|
|
505
|
+
_context6.n = 2;
|
|
487
506
|
return this.notifyChanged("temp", key, value);
|
|
488
|
-
case
|
|
489
|
-
return _context6.
|
|
490
|
-
case 8:
|
|
491
|
-
case "end":
|
|
492
|
-
return _context6.stop();
|
|
507
|
+
case 2:
|
|
508
|
+
return _context6.a(2, isValueChanged);
|
|
493
509
|
}
|
|
494
510
|
}, _callee6, this);
|
|
495
511
|
}));
|
|
@@ -501,28 +517,25 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
501
517
|
}, {
|
|
502
518
|
key: "pushValue",
|
|
503
519
|
value: (
|
|
504
|
-
/**
|
|
505
|
-
* Push a single value to array property
|
|
506
|
-
* @param key
|
|
507
|
-
* @param value
|
|
508
|
-
* @param sendChanges
|
|
509
|
-
* @returns
|
|
520
|
+
/**
|
|
521
|
+
* Push a single value to array property
|
|
522
|
+
* @param key
|
|
523
|
+
* @param value
|
|
524
|
+
* @param sendChanges
|
|
525
|
+
* @returns
|
|
510
526
|
*/
|
|
511
527
|
function () {
|
|
512
|
-
var _pushValue = _asyncToGenerator(/*#__PURE__*/
|
|
528
|
+
var _pushValue = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(key, value) {
|
|
513
529
|
var sendChanges,
|
|
514
530
|
_args7 = arguments;
|
|
515
|
-
return
|
|
516
|
-
while (1) switch (_context7.
|
|
531
|
+
return _regenerator().w(function (_context7) {
|
|
532
|
+
while (1) switch (_context7.n) {
|
|
517
533
|
case 0:
|
|
518
534
|
sendChanges = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : "auto";
|
|
519
|
-
_context7.
|
|
535
|
+
_context7.n = 1;
|
|
520
536
|
return this.pushValues(key, [value], sendChanges);
|
|
521
|
-
case
|
|
522
|
-
return _context7.
|
|
523
|
-
case 4:
|
|
524
|
-
case "end":
|
|
525
|
-
return _context7.stop();
|
|
537
|
+
case 1:
|
|
538
|
+
return _context7.a(2, _context7.v);
|
|
526
539
|
}
|
|
527
540
|
}, _callee7, this);
|
|
528
541
|
}));
|
|
@@ -531,69 +544,66 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
531
544
|
}
|
|
532
545
|
return pushValue;
|
|
533
546
|
}()
|
|
534
|
-
/**
|
|
535
|
-
* Push a list of values to array property
|
|
536
|
-
* @param key
|
|
537
|
-
* @param values
|
|
538
|
-
* @param sendChanges
|
|
539
|
-
* @returns
|
|
547
|
+
/**
|
|
548
|
+
* Push a list of values to array property
|
|
549
|
+
* @param key
|
|
550
|
+
* @param values
|
|
551
|
+
* @param sendChanges
|
|
552
|
+
* @returns
|
|
540
553
|
*/
|
|
541
554
|
)
|
|
542
555
|
}, {
|
|
543
556
|
key: "pushValues",
|
|
544
557
|
value: (function () {
|
|
545
|
-
var _pushValues = _asyncToGenerator(/*#__PURE__*/
|
|
558
|
+
var _pushValues = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(key, values) {
|
|
546
559
|
var sendChanges,
|
|
547
560
|
tempArray,
|
|
548
561
|
_args8 = arguments;
|
|
549
|
-
return
|
|
550
|
-
while (1) switch (_context8.
|
|
562
|
+
return _regenerator().w(function (_context8) {
|
|
563
|
+
while (1) switch (_context8.n) {
|
|
551
564
|
case 0:
|
|
552
565
|
sendChanges = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : "auto";
|
|
553
566
|
if (!(0, _object.array_isEmpty)(values)) {
|
|
554
|
-
_context8.
|
|
567
|
+
_context8.n = 1;
|
|
555
568
|
break;
|
|
556
569
|
}
|
|
557
|
-
return _context8.
|
|
558
|
-
case
|
|
570
|
+
return _context8.a(2, false);
|
|
571
|
+
case 1:
|
|
559
572
|
if (this.canModify) {
|
|
560
|
-
_context8.
|
|
573
|
+
_context8.n = 3;
|
|
561
574
|
break;
|
|
562
575
|
}
|
|
563
576
|
if (!(this.__throw_errors !== false)) {
|
|
564
|
-
_context8.
|
|
577
|
+
_context8.n = 2;
|
|
565
578
|
break;
|
|
566
579
|
}
|
|
567
580
|
throw Error("Cant use pushValues (".concat(String(key), ") when on readonly mode"));
|
|
568
|
-
case
|
|
569
|
-
return _context8.
|
|
570
|
-
case
|
|
571
|
-
if (this.get(key) == null)
|
|
581
|
+
case 2:
|
|
582
|
+
return _context8.a(2, false);
|
|
583
|
+
case 3:
|
|
584
|
+
if (this.get(key) == null) this.setProperty(key, []);
|
|
572
585
|
tempArray = this.get(key);
|
|
573
586
|
if (Array.isArray(tempArray)) {
|
|
574
|
-
_context8.
|
|
587
|
+
_context8.n = 5;
|
|
575
588
|
break;
|
|
576
589
|
}
|
|
577
590
|
if (!(this.__throw_errors !== false)) {
|
|
578
|
-
_context8.
|
|
591
|
+
_context8.n = 4;
|
|
579
592
|
break;
|
|
580
593
|
}
|
|
581
594
|
throw Error("Cant use pushValues (".concat(String(key), ") on non Array keys"));
|
|
582
|
-
case
|
|
583
|
-
return _context8.
|
|
584
|
-
case
|
|
585
|
-
|
|
595
|
+
case 4:
|
|
596
|
+
return _context8.a(2, false);
|
|
597
|
+
case 5:
|
|
598
|
+
this.setProperty(key, (0, _object.array_merge)(tempArray, values));
|
|
586
599
|
if (!(sendChanges === true || sendChanges === "auto")) {
|
|
587
|
-
_context8.
|
|
600
|
+
_context8.n = 6;
|
|
588
601
|
break;
|
|
589
602
|
}
|
|
590
|
-
_context8.
|
|
603
|
+
_context8.n = 6;
|
|
591
604
|
return this.notifyChanged("", key, values);
|
|
592
|
-
case
|
|
593
|
-
return _context8.
|
|
594
|
-
case 22:
|
|
595
|
-
case "end":
|
|
596
|
-
return _context8.stop();
|
|
605
|
+
case 6:
|
|
606
|
+
return _context8.a(2, tempArray);
|
|
597
607
|
}
|
|
598
608
|
}, _callee8, this);
|
|
599
609
|
}));
|
|
@@ -605,11 +615,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
605
615
|
/* -------------------------------------------------------------------------- */
|
|
606
616
|
/* Load */
|
|
607
617
|
/* -------------------------------------------------------------------------- */
|
|
608
|
-
/**
|
|
609
|
-
* load all properties in `initObject` into the current object
|
|
610
|
-
* @param initObject
|
|
611
|
-
* @param fullUpdate
|
|
612
|
-
* @returns
|
|
618
|
+
/**
|
|
619
|
+
* load all properties in `initObject` into the current object
|
|
620
|
+
* @param initObject
|
|
621
|
+
* @param fullUpdate
|
|
622
|
+
* @returns
|
|
613
623
|
*/
|
|
614
624
|
)
|
|
615
625
|
}, {
|
|
@@ -625,14 +635,13 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
625
635
|
/* Refresh Functions */
|
|
626
636
|
/* -------------------------------------------------------------------------- */
|
|
627
637
|
function () {
|
|
628
|
-
var _clearRefreshFunction = _asyncToGenerator(/*#__PURE__*/
|
|
629
|
-
return
|
|
630
|
-
while (1) switch (_context9.
|
|
638
|
+
var _clearRefreshFunction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
639
|
+
return _regenerator().w(function (_context9) {
|
|
640
|
+
while (1) switch (_context9.n) {
|
|
631
641
|
case 0:
|
|
632
642
|
this.__refresh_functions = undefined;
|
|
633
643
|
case 1:
|
|
634
|
-
|
|
635
|
-
return _context9.stop();
|
|
644
|
+
return _context9.a(2);
|
|
636
645
|
}
|
|
637
646
|
}, _callee9, this);
|
|
638
647
|
}));
|
|
@@ -644,17 +653,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
644
653
|
}, {
|
|
645
654
|
key: "setRefreshFunction",
|
|
646
655
|
value: function () {
|
|
647
|
-
var _setRefreshFunction = _asyncToGenerator(/*#__PURE__*/
|
|
648
|
-
return
|
|
649
|
-
while (1) switch (_context0.
|
|
656
|
+
var _setRefreshFunction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(new_fnc) {
|
|
657
|
+
return _regenerator().w(function (_context0) {
|
|
658
|
+
while (1) switch (_context0.n) {
|
|
650
659
|
case 0:
|
|
651
|
-
_context0.
|
|
660
|
+
_context0.n = 1;
|
|
652
661
|
return this.addRefreshFunction(new_fnc);
|
|
653
|
-
case
|
|
654
|
-
return _context0.
|
|
655
|
-
case 3:
|
|
656
|
-
case "end":
|
|
657
|
-
return _context0.stop();
|
|
662
|
+
case 1:
|
|
663
|
+
return _context0.a(2, _context0.v);
|
|
658
664
|
}
|
|
659
665
|
}, _callee0, this);
|
|
660
666
|
}));
|
|
@@ -666,10 +672,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
666
672
|
}, {
|
|
667
673
|
key: "addRefreshFunction",
|
|
668
674
|
value: function () {
|
|
669
|
-
var _addRefreshFunction = _asyncToGenerator(/*#__PURE__*/
|
|
675
|
+
var _addRefreshFunction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(key, new_fnc) {
|
|
670
676
|
var oldFunctions;
|
|
671
|
-
return
|
|
672
|
-
while (1) switch (_context1.
|
|
677
|
+
return _regenerator().w(function (_context1) {
|
|
678
|
+
while (1) switch (_context1.n) {
|
|
673
679
|
case 0:
|
|
674
680
|
if (typeof key === "function") {
|
|
675
681
|
new_fnc = key;
|
|
@@ -680,9 +686,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
680
686
|
if (oldFunctions == null || _typeof(oldFunctions) !== "object") oldFunctions = {};
|
|
681
687
|
oldFunctions[key] = new_fnc;
|
|
682
688
|
this.__refresh_functions = oldFunctions;
|
|
683
|
-
case
|
|
684
|
-
|
|
685
|
-
return _context1.stop();
|
|
689
|
+
case 1:
|
|
690
|
+
return _context1.a(2);
|
|
686
691
|
}
|
|
687
692
|
}, _callee1, this);
|
|
688
693
|
}));
|
|
@@ -694,7 +699,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
694
699
|
}, {
|
|
695
700
|
key: "runRefreshFunction",
|
|
696
701
|
value: function () {
|
|
697
|
-
var _runRefreshFunction = _asyncToGenerator(/*#__PURE__*/
|
|
702
|
+
var _runRefreshFunction = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
698
703
|
var oldFunctions,
|
|
699
704
|
fncArray,
|
|
700
705
|
_len,
|
|
@@ -703,36 +708,35 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
703
708
|
index,
|
|
704
709
|
fnc,
|
|
705
710
|
_args10 = arguments;
|
|
706
|
-
return
|
|
707
|
-
while (1) switch (_context10.
|
|
711
|
+
return _regenerator().w(function (_context10) {
|
|
712
|
+
while (1) switch (_context10.n) {
|
|
708
713
|
case 0:
|
|
709
714
|
oldFunctions = this.__refresh_functions;
|
|
710
715
|
if (!(oldFunctions == null || _typeof(oldFunctions) !== "object")) {
|
|
711
|
-
_context10.
|
|
716
|
+
_context10.n = 1;
|
|
712
717
|
break;
|
|
713
718
|
}
|
|
714
|
-
return _context10.
|
|
715
|
-
case
|
|
719
|
+
return _context10.a(2);
|
|
720
|
+
case 1:
|
|
716
721
|
fncArray = Object.values(oldFunctions);
|
|
717
722
|
for (_len = _args10.length, params = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
|
|
718
723
|
params[_key2] = _args10[_key2];
|
|
719
724
|
}
|
|
720
725
|
index = 0;
|
|
721
|
-
case
|
|
726
|
+
case 2:
|
|
722
727
|
if (!(index < fncArray.length)) {
|
|
723
|
-
_context10.
|
|
728
|
+
_context10.n = 4;
|
|
724
729
|
break;
|
|
725
730
|
}
|
|
726
731
|
fnc = fncArray[index];
|
|
727
|
-
_context10.
|
|
732
|
+
_context10.n = 3;
|
|
728
733
|
return _object.fn_eval.apply(void 0, [fnc].concat(params));
|
|
729
|
-
case
|
|
734
|
+
case 3:
|
|
730
735
|
index++;
|
|
731
|
-
_context10.
|
|
736
|
+
_context10.n = 2;
|
|
732
737
|
break;
|
|
733
|
-
case
|
|
734
|
-
|
|
735
|
-
return _context10.stop();
|
|
738
|
+
case 4:
|
|
739
|
+
return _context10.a(2);
|
|
736
740
|
}
|
|
737
741
|
}, _callee10, this);
|
|
738
742
|
}));
|
|
@@ -741,21 +745,21 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
741
745
|
}
|
|
742
746
|
return runRefreshFunction;
|
|
743
747
|
}()
|
|
744
|
-
/**
|
|
745
|
-
*
|
|
746
|
-
* @param type
|
|
747
|
-
* @param key
|
|
748
|
-
* @param value
|
|
749
|
-
* @param subvalue
|
|
750
|
-
* @returns true if manager was notified. false otherwise
|
|
748
|
+
/**
|
|
749
|
+
*
|
|
750
|
+
* @param type
|
|
751
|
+
* @param key
|
|
752
|
+
* @param value
|
|
753
|
+
* @param subvalue
|
|
754
|
+
* @returns true if manager was notified. false otherwise
|
|
751
755
|
*/
|
|
752
756
|
}, {
|
|
753
757
|
key: "notifyChanged",
|
|
754
758
|
value: (function () {
|
|
755
|
-
var _notifyChanged = _asyncToGenerator(/*#__PURE__*/
|
|
759
|
+
var _notifyChanged = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(type, key, value, subvalue) {
|
|
756
760
|
var lc, manager_class;
|
|
757
|
-
return
|
|
758
|
-
while (1) switch (_context11.
|
|
761
|
+
return _regenerator().w(function (_context11) {
|
|
762
|
+
while (1) switch (_context11.n) {
|
|
759
763
|
case 0:
|
|
760
764
|
if (value === undefined && type == "") value = this.get(key);
|
|
761
765
|
lc = "";
|
|
@@ -769,18 +773,15 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
769
773
|
/* --------------------------- notify the manager --------------------------- */
|
|
770
774
|
manager_class = this.manager;
|
|
771
775
|
if (!(typeof (manager_class === null || manager_class === void 0 ? void 0 : manager_class.notifyChanged) === "function")) {
|
|
772
|
-
_context11.
|
|
776
|
+
_context11.n = 2;
|
|
773
777
|
break;
|
|
774
778
|
}
|
|
775
|
-
_context11.
|
|
779
|
+
_context11.n = 1;
|
|
776
780
|
return manager_class.notifyChanged(type, key, value, subvalue);
|
|
777
|
-
case
|
|
778
|
-
return _context11.
|
|
779
|
-
case
|
|
780
|
-
return _context11.
|
|
781
|
-
case 11:
|
|
782
|
-
case "end":
|
|
783
|
-
return _context11.stop();
|
|
781
|
+
case 1:
|
|
782
|
+
return _context11.a(2, _context11.v);
|
|
783
|
+
case 2:
|
|
784
|
+
return _context11.a(2, false);
|
|
784
785
|
}
|
|
785
786
|
}, _callee11, this);
|
|
786
787
|
}));
|
|
@@ -789,11 +790,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
789
790
|
}
|
|
790
791
|
return notifyChanged;
|
|
791
792
|
}()
|
|
792
|
-
/**
|
|
793
|
-
* get a list of all keys that can be changed in given objcet
|
|
794
|
-
* @param object
|
|
795
|
-
* @param options
|
|
796
|
-
* @returns
|
|
793
|
+
/**
|
|
794
|
+
* get a list of all keys that can be changed in given objcet
|
|
795
|
+
* @param object
|
|
796
|
+
* @param options
|
|
797
|
+
* @returns
|
|
797
798
|
*/
|
|
798
799
|
)
|
|
799
800
|
}, {
|
|
@@ -801,14 +802,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
801
802
|
value: /* -------------------------------------------------------------------------- */
|
|
802
803
|
/* Changes */
|
|
803
804
|
/* -------------------------------------------------------------------------- */
|
|
804
|
-
/**
|
|
805
|
-
* Apply all the changes and empty the delta object
|
|
805
|
+
/**
|
|
806
|
+
* Apply all the changes and empty the delta object
|
|
806
807
|
*/
|
|
807
808
|
function apply_changes() {
|
|
808
809
|
try {
|
|
809
810
|
if (!this.__use_delta) {
|
|
810
|
-
/**
|
|
811
|
-
* in this mode , we track changes by updating the original product
|
|
811
|
+
/**
|
|
812
|
+
* in this mode , we track changes by updating the original product
|
|
812
813
|
*/
|
|
813
814
|
this.setOriginal();
|
|
814
815
|
return true;
|
|
@@ -826,30 +827,30 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
826
827
|
this.clear_changes();
|
|
827
828
|
}
|
|
828
829
|
}
|
|
829
|
-
/**
|
|
830
|
-
* apply changes for the given fields
|
|
831
|
-
* @param key
|
|
832
|
-
* @returns
|
|
830
|
+
/**
|
|
831
|
+
* apply changes for the given fields
|
|
832
|
+
* @param key
|
|
833
|
+
* @returns
|
|
833
834
|
*/
|
|
834
835
|
}, {
|
|
835
836
|
key: "apply",
|
|
836
837
|
value: function apply(keylist) {
|
|
837
838
|
if (!this.__use_delta) {
|
|
838
|
-
/**
|
|
839
|
-
* in this mode , we track changes by updating the original
|
|
839
|
+
/**
|
|
840
|
+
* in this mode , we track changes by updating the original
|
|
840
841
|
*/
|
|
841
842
|
return true;
|
|
842
843
|
}
|
|
843
844
|
if (this.__delta == null || Object.keys(this.__delta).length == 0) {
|
|
844
|
-
/**
|
|
845
|
-
* nothing to apply
|
|
845
|
+
/**
|
|
846
|
+
* nothing to apply
|
|
846
847
|
*/
|
|
847
848
|
return true;
|
|
848
849
|
}
|
|
849
850
|
keylist = (0, _object.wrap_array)(keylist);
|
|
850
851
|
if (keylist.length == 0) {
|
|
851
|
-
/**
|
|
852
|
-
* nothing to apply
|
|
852
|
+
/**
|
|
853
|
+
* nothing to apply
|
|
853
854
|
*/
|
|
854
855
|
return true;
|
|
855
856
|
}
|
|
@@ -870,31 +871,28 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
870
871
|
}
|
|
871
872
|
return true;
|
|
872
873
|
}
|
|
873
|
-
/**
|
|
874
|
-
* set the value to its original
|
|
875
|
-
* @param key
|
|
874
|
+
/**
|
|
875
|
+
* set the value to its original
|
|
876
|
+
* @param key
|
|
876
877
|
*/
|
|
877
878
|
}, {
|
|
878
879
|
key: "discard",
|
|
879
880
|
value: (function () {
|
|
880
|
-
var _discard = _asyncToGenerator(/*#__PURE__*/
|
|
881
|
+
var _discard = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(key) {
|
|
881
882
|
var shouldNotify,
|
|
882
883
|
originalValue,
|
|
883
884
|
_args12 = arguments;
|
|
884
|
-
return
|
|
885
|
-
while (1) switch (_context12.
|
|
885
|
+
return _regenerator().w(function (_context12) {
|
|
886
|
+
while (1) switch (_context12.n) {
|
|
886
887
|
case 0:
|
|
887
888
|
shouldNotify = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : "auto";
|
|
888
889
|
if (this.__use_delta) {
|
|
889
890
|
originalValue = this[key];
|
|
890
891
|
} else if (this.__originalobject) originalValue = this.__originalobject[key];else originalValue = this[key];
|
|
891
|
-
_context12.
|
|
892
|
+
_context12.n = 1;
|
|
892
893
|
return this.set(key, originalValue, shouldNotify);
|
|
893
|
-
case
|
|
894
|
-
return _context12.
|
|
895
|
-
case 5:
|
|
896
|
-
case "end":
|
|
897
|
-
return _context12.stop();
|
|
894
|
+
case 1:
|
|
895
|
+
return _context12.a(2, _context12.v);
|
|
898
896
|
}
|
|
899
897
|
}, _callee12, this);
|
|
900
898
|
}));
|
|
@@ -903,52 +901,52 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
903
901
|
}
|
|
904
902
|
return discard;
|
|
905
903
|
}()
|
|
906
|
-
/**
|
|
907
|
-
* reset all values back to their original
|
|
908
|
-
*
|
|
909
|
-
* this function also calls `on_change` and then `clear_changes`
|
|
910
|
-
* @param key
|
|
904
|
+
/**
|
|
905
|
+
* reset all values back to their original
|
|
906
|
+
*
|
|
907
|
+
* this function also calls `on_change` and then `clear_changes`
|
|
908
|
+
* @param key
|
|
911
909
|
*/
|
|
912
910
|
)
|
|
913
911
|
}, {
|
|
914
912
|
key: "discardAll",
|
|
915
913
|
value: (function () {
|
|
916
|
-
var _discardAll = _asyncToGenerator(/*#__PURE__*/
|
|
914
|
+
var _discardAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
917
915
|
var shouldNotify,
|
|
918
916
|
final_result,
|
|
919
917
|
key,
|
|
920
|
-
_args13 = arguments
|
|
921
|
-
|
|
922
|
-
|
|
918
|
+
_args13 = arguments,
|
|
919
|
+
_t2,
|
|
920
|
+
_t3,
|
|
921
|
+
_t4;
|
|
922
|
+
return _regenerator().w(function (_context13) {
|
|
923
|
+
while (1) switch (_context13.n) {
|
|
923
924
|
case 0:
|
|
924
925
|
shouldNotify = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : "auto";
|
|
925
926
|
final_result = true;
|
|
926
|
-
|
|
927
|
-
case
|
|
928
|
-
if ((
|
|
929
|
-
_context13.
|
|
927
|
+
_t2 = _regeneratorKeys(this.__delta);
|
|
928
|
+
case 1:
|
|
929
|
+
if ((_t3 = _t2()).done) {
|
|
930
|
+
_context13.n = 4;
|
|
930
931
|
break;
|
|
931
932
|
}
|
|
932
|
-
key =
|
|
933
|
-
|
|
934
|
-
if (!
|
|
935
|
-
_context13.
|
|
933
|
+
key = _t3.value;
|
|
934
|
+
_t4 = final_result;
|
|
935
|
+
if (!_t4) {
|
|
936
|
+
_context13.n = 3;
|
|
936
937
|
break;
|
|
937
938
|
}
|
|
938
|
-
_context13.
|
|
939
|
+
_context13.n = 2;
|
|
939
940
|
return this.discard(key, shouldNotify);
|
|
940
|
-
case
|
|
941
|
-
|
|
942
|
-
case
|
|
943
|
-
final_result =
|
|
944
|
-
_context13.
|
|
941
|
+
case 2:
|
|
942
|
+
_t4 = _context13.v;
|
|
943
|
+
case 3:
|
|
944
|
+
final_result = _t4;
|
|
945
|
+
_context13.n = 1;
|
|
945
946
|
break;
|
|
946
|
-
case
|
|
947
|
+
case 4:
|
|
947
948
|
if (final_result) this.clear_changes();
|
|
948
|
-
return _context13.
|
|
949
|
-
case 15:
|
|
950
|
-
case "end":
|
|
951
|
-
return _context13.stop();
|
|
949
|
+
return _context13.a(2, final_result);
|
|
952
950
|
}
|
|
953
951
|
}, _callee13, this);
|
|
954
952
|
}));
|
|
@@ -957,11 +955,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
957
955
|
}
|
|
958
956
|
return discardAll;
|
|
959
957
|
}()
|
|
960
|
-
/**
|
|
961
|
-
* clear and discard all changes
|
|
962
|
-
*
|
|
963
|
-
* does not call `on_change` functions
|
|
964
|
-
* @returns
|
|
958
|
+
/**
|
|
959
|
+
* clear and discard all changes
|
|
960
|
+
*
|
|
961
|
+
* does not call `on_change` functions
|
|
962
|
+
* @returns
|
|
965
963
|
*/
|
|
966
964
|
)
|
|
967
965
|
}, {
|
|
@@ -971,11 +969,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
971
969
|
////this.__has_delta = false;
|
|
972
970
|
return true;
|
|
973
971
|
}
|
|
974
|
-
/**
|
|
975
|
-
* Sets readonly property on given objects
|
|
976
|
-
* @param objs array of given objects or a single object
|
|
977
|
-
* @param readonlyval readonly
|
|
978
|
-
* @param clearChanges should we clean the changes after setting readonly
|
|
972
|
+
/**
|
|
973
|
+
* Sets readonly property on given objects
|
|
974
|
+
* @param objs array of given objects or a single object
|
|
975
|
+
* @param readonlyval readonly
|
|
976
|
+
* @param clearChanges should we clean the changes after setting readonly
|
|
979
977
|
*/
|
|
980
978
|
}, {
|
|
981
979
|
key: "__object_name",
|
|
@@ -999,8 +997,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
999
997
|
////if (this.__use_delta) return !deltaIsBlank; //trust the delta.
|
|
1000
998
|
if (this.__use_delta) {
|
|
1001
999
|
////return this.__has_delta;
|
|
1002
|
-
/**
|
|
1003
|
-
* if there is any key in delta, then the object is changed
|
|
1000
|
+
/**
|
|
1001
|
+
* if there is any key in delta, then the object is changed
|
|
1004
1002
|
*/
|
|
1005
1003
|
for (var key in this.__delta) return true;
|
|
1006
1004
|
return false;
|
|
@@ -1008,18 +1006,20 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1008
1006
|
/* --------------------- check the properties one by one -------------------- */
|
|
1009
1007
|
var orig = this.getOriginal();
|
|
1010
1008
|
if (!orig) return false; //we dont know if anything has changed
|
|
1011
|
-
/**
|
|
1012
|
-
* if object is not using delta mode,
|
|
1013
|
-
* check changes by comparing changeable fields with original object
|
|
1009
|
+
/**
|
|
1010
|
+
* if object is not using delta mode,
|
|
1011
|
+
* check changes by comparing changeable fields with original object
|
|
1014
1012
|
*/
|
|
1015
|
-
if (
|
|
1013
|
+
if (!(0, _object.array_isEmpty)(this.__changeables)) {
|
|
1016
1014
|
return this.__changeables.find(function (c) {
|
|
1017
1015
|
return !(0, _object.object_equals)(_this2[c], orig[c]);
|
|
1018
1016
|
}) != undefined;
|
|
1019
1017
|
} else {
|
|
1020
|
-
/* check all fields */
|
|
1018
|
+
/* no changeables listed, check all fields */
|
|
1021
1019
|
for (var _key3 in this) {
|
|
1022
1020
|
if (_key3.startsWith("__")) continue;
|
|
1021
|
+
//methods like get_managerClass are reassigned per instance, they are not data
|
|
1022
|
+
if (typeof this[_key3] === "function") continue;
|
|
1023
1023
|
if (!(0, _object.object_equals)(this[_key3], orig[_key3])) return true;
|
|
1024
1024
|
}
|
|
1025
1025
|
return false;
|
|
@@ -1052,11 +1052,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1052
1052
|
}, {
|
|
1053
1053
|
key: "objectColor",
|
|
1054
1054
|
get: function get() {
|
|
1055
|
-
if (!
|
|
1055
|
+
if (!this.__objectColor) {
|
|
1056
1056
|
var lastid = this.getID();
|
|
1057
|
-
if (lastid)
|
|
1057
|
+
if (lastid) this.__objectColor = (0, _string.string_to_color)(lastid);
|
|
1058
1058
|
}
|
|
1059
|
-
return
|
|
1059
|
+
return this.__objectColor || "#000000";
|
|
1060
1060
|
}
|
|
1061
1061
|
}, {
|
|
1062
1062
|
key: "d",
|
|
@@ -1074,7 +1074,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1074
1074
|
}, {
|
|
1075
1075
|
key: "canModify",
|
|
1076
1076
|
get: function get() {
|
|
1077
|
-
return !
|
|
1077
|
+
return !this.__is_readonly;
|
|
1078
1078
|
}
|
|
1079
1079
|
}, {
|
|
1080
1080
|
key: "__changeables",
|
|
@@ -1119,16 +1119,16 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1119
1119
|
}, {
|
|
1120
1120
|
key: "set_managerClass",
|
|
1121
1121
|
value:
|
|
1122
|
-
/**
|
|
1123
|
-
* @deprecated use setManager
|
|
1124
|
-
* @param mng
|
|
1122
|
+
/**
|
|
1123
|
+
* @deprecated use setManager
|
|
1124
|
+
* @param mng
|
|
1125
1125
|
*/
|
|
1126
1126
|
function set_managerClass(mng) {
|
|
1127
1127
|
return this.setManager(mng);
|
|
1128
1128
|
}
|
|
1129
|
-
/**
|
|
1130
|
-
* update the manager class for this object
|
|
1131
|
-
* @param mng
|
|
1129
|
+
/**
|
|
1130
|
+
* update the manager class for this object
|
|
1131
|
+
* @param mng
|
|
1132
1132
|
*/
|
|
1133
1133
|
}, {
|
|
1134
1134
|
key: "setManager",
|
|
@@ -1162,32 +1162,29 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1162
1162
|
/* Events */
|
|
1163
1163
|
/* -------------------------------------------------------------------------- */
|
|
1164
1164
|
function () {
|
|
1165
|
-
var _event_run = _asyncToGenerator(/*#__PURE__*/
|
|
1165
|
+
var _event_run = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(eventName) {
|
|
1166
1166
|
var _this$manager2;
|
|
1167
1167
|
var _len2,
|
|
1168
1168
|
params,
|
|
1169
1169
|
_key4,
|
|
1170
1170
|
_args14 = arguments;
|
|
1171
|
-
return
|
|
1172
|
-
while (1) switch (_context14.
|
|
1171
|
+
return _regenerator().w(function (_context14) {
|
|
1172
|
+
while (1) switch (_context14.n) {
|
|
1173
1173
|
case 0:
|
|
1174
1174
|
if (this.manager) {
|
|
1175
|
-
_context14.
|
|
1175
|
+
_context14.n = 1;
|
|
1176
1176
|
break;
|
|
1177
1177
|
}
|
|
1178
1178
|
if (this.__showErrors === true) console.error("you cant use events (".concat(eventName, ") if your object has no manager"));
|
|
1179
|
-
return _context14.
|
|
1180
|
-
case
|
|
1179
|
+
return _context14.a(2);
|
|
1180
|
+
case 1:
|
|
1181
1181
|
for (_len2 = _args14.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key4 = 1; _key4 < _len2; _key4++) {
|
|
1182
1182
|
params[_key4 - 1] = _args14[_key4];
|
|
1183
1183
|
}
|
|
1184
|
-
_context14.
|
|
1184
|
+
_context14.n = 2;
|
|
1185
1185
|
return (_this$manager2 = this.manager).event_run.apply(_this$manager2, [eventName].concat(params));
|
|
1186
|
-
case
|
|
1187
|
-
return _context14.
|
|
1188
|
-
case 7:
|
|
1189
|
-
case "end":
|
|
1190
|
-
return _context14.stop();
|
|
1186
|
+
case 2:
|
|
1187
|
+
return _context14.a(2, _context14.v);
|
|
1191
1188
|
}
|
|
1192
1189
|
}, _callee14, this);
|
|
1193
1190
|
}));
|
|
@@ -1219,27 +1216,26 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1219
1216
|
}, {
|
|
1220
1217
|
key: "event_add",
|
|
1221
1218
|
value: function () {
|
|
1222
|
-
var _event_add = _asyncToGenerator(/*#__PURE__*/
|
|
1219
|
+
var _event_add = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(name, uname, runEvent) {
|
|
1223
1220
|
var onlyOn,
|
|
1224
1221
|
runOnce,
|
|
1225
1222
|
_args15 = arguments;
|
|
1226
|
-
return
|
|
1227
|
-
while (1) switch (_context15.
|
|
1223
|
+
return _regenerator().w(function (_context15) {
|
|
1224
|
+
while (1) switch (_context15.n) {
|
|
1228
1225
|
case 0:
|
|
1229
1226
|
onlyOn = _args15.length > 3 && _args15[3] !== undefined ? _args15[3] : null;
|
|
1230
1227
|
runOnce = _args15.length > 4 && _args15[4] !== undefined ? _args15[4] : false;
|
|
1231
1228
|
if (this.manager) {
|
|
1232
|
-
_context15.
|
|
1229
|
+
_context15.n = 1;
|
|
1233
1230
|
break;
|
|
1234
1231
|
}
|
|
1235
1232
|
if (this.__showErrors === true) console.error("you cant use events (".concat(name, ") if your object has no manager"));
|
|
1236
|
-
return _context15.
|
|
1237
|
-
case
|
|
1238
|
-
_context15.
|
|
1233
|
+
return _context15.a(2);
|
|
1234
|
+
case 1:
|
|
1235
|
+
_context15.n = 2;
|
|
1239
1236
|
return this.manager.event_add(name, uname, runEvent, onlyOn, runOnce);
|
|
1240
|
-
case
|
|
1241
|
-
|
|
1242
|
-
return _context15.stop();
|
|
1237
|
+
case 2:
|
|
1238
|
+
return _context15.a(2);
|
|
1243
1239
|
}
|
|
1244
1240
|
}, _callee15, this);
|
|
1245
1241
|
}));
|
|
@@ -1299,15 +1295,15 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1299
1295
|
}, {
|
|
1300
1296
|
key: "setSaveResult",
|
|
1301
1297
|
value:
|
|
1302
|
-
/**
|
|
1303
|
-
* set the response of last save from site
|
|
1304
|
-
* and its type
|
|
1305
|
-
* @param toObj
|
|
1298
|
+
/**
|
|
1299
|
+
* set the response of last save from site
|
|
1300
|
+
* and its type
|
|
1301
|
+
* @param toObj
|
|
1306
1302
|
*/
|
|
1307
1303
|
function setSaveResult(toObj) {
|
|
1308
1304
|
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "auto";
|
|
1309
1305
|
var registerErrors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1310
|
-
|
|
1306
|
+
this.setSaveResultObject(toObj);
|
|
1311
1307
|
//check if the given object is a valid save result
|
|
1312
1308
|
if (type === "error") this.__saveResultIsSuccess = false;else this.__saveResultIsSuccess = Boolean(type === "nothing" || this.constructor["isResultValid"](toObj));
|
|
1313
1309
|
if (type === "auto") {
|
|
@@ -1321,10 +1317,17 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1321
1317
|
this.__saveResultType = type;
|
|
1322
1318
|
return type;
|
|
1323
1319
|
}
|
|
1324
|
-
/**
|
|
1325
|
-
* set the response of last save from site
|
|
1326
|
-
* @param toObj
|
|
1320
|
+
/**
|
|
1321
|
+
* set the response of last save from site
|
|
1322
|
+
* @param toObj
|
|
1327
1323
|
*/
|
|
1324
|
+
}, {
|
|
1325
|
+
key: "setSaveResultObject",
|
|
1326
|
+
value: function setSaveResultObject(toObj) {
|
|
1327
|
+
if (toObj == null) toObj = null; //null or undefined
|
|
1328
|
+
this.__saveResultObject = toObj;
|
|
1329
|
+
return true;
|
|
1330
|
+
}
|
|
1328
1331
|
}, {
|
|
1329
1332
|
key: "getSaveResult",
|
|
1330
1333
|
value: function getSaveResult() {
|
|
@@ -1416,7 +1419,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1416
1419
|
var __protectedProperties = object.constructor["__protectedProperties"];
|
|
1417
1420
|
//protected keys can only be changed by the creator of this object
|
|
1418
1421
|
//make sure you set the is_current_user function correctly
|
|
1419
|
-
if (!object.isNew && !(0, _object.array_isEmpty)(__protectedProperties) && !
|
|
1422
|
+
if (!object.isNew && !(0, _object.array_isEmpty)(__protectedProperties) && !_global.gfunc.run_action_sync("is_current_user", object.get("_creator"))) {
|
|
1420
1423
|
key_list = key_list.filter(function (s) {
|
|
1421
1424
|
return !__protectedProperties.includes(s);
|
|
1422
1425
|
});
|
|
@@ -1424,12 +1427,12 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1424
1427
|
}
|
|
1425
1428
|
return key_list;
|
|
1426
1429
|
}
|
|
1427
|
-
/**
|
|
1428
|
-
* check if a key can be changed on an object
|
|
1429
|
-
* @param object the object we are checking
|
|
1430
|
-
* @param key key of the object
|
|
1431
|
-
* @param useExtraProps should we check extra props?
|
|
1432
|
-
* @returns
|
|
1430
|
+
/**
|
|
1431
|
+
* check if a key can be changed on an object
|
|
1432
|
+
* @param object the object we are checking
|
|
1433
|
+
* @param key key of the object
|
|
1434
|
+
* @param useExtraProps should we check extra props?
|
|
1435
|
+
* @returns
|
|
1433
1436
|
*/
|
|
1434
1437
|
}, {
|
|
1435
1438
|
key: "canChangeKey",
|
|
@@ -1444,7 +1447,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1444
1447
|
var __protectedProperties = (0, _object.object_getStatic)(referenceObject, "__protectedProperties");
|
|
1445
1448
|
if ((0, _object.object_isEmpty)(__protectedProperties)) return false;
|
|
1446
1449
|
var referenceUser = (0, _object.object_isClass)(referenceObject) ? (0, _object.object_get)(changesObject, "__user", "_creator") : (0, _object.object_get)(referenceObject, "__user", "_creator");
|
|
1447
|
-
if (
|
|
1450
|
+
if (SimpleObject.getID(referenceUser) == SimpleObject.getID(updaterUser)) {
|
|
1448
1451
|
return false;
|
|
1449
1452
|
}
|
|
1450
1453
|
for (var key in changesObject) {
|
|
@@ -1459,7 +1462,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1459
1462
|
value: function setReadonly(objs) {
|
|
1460
1463
|
var readonlyval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1461
1464
|
var clearChanges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1462
|
-
var checkObjs
|
|
1465
|
+
var checkObjs;
|
|
1463
1466
|
if (!objs) objs = [];
|
|
1464
1467
|
if (!Array.isArray(objs)) checkObjs = [objs];else checkObjs = objs;
|
|
1465
1468
|
for (var index = 0; index < checkObjs.length; index++) {
|
|
@@ -1480,7 +1483,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1480
1483
|
key: "setThrowErrors",
|
|
1481
1484
|
value: function setThrowErrors(objs) {
|
|
1482
1485
|
var throwErr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1483
|
-
var checkObjs
|
|
1486
|
+
var checkObjs;
|
|
1484
1487
|
if (!objs) objs = [];
|
|
1485
1488
|
if (!Array.isArray(objs)) checkObjs = [objs];else checkObjs = objs;
|
|
1486
1489
|
for (var index = 0; index < checkObjs.length; index++) {
|
|
@@ -1579,10 +1582,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1579
1582
|
/* -------------------------------------------------------------------------- */
|
|
1580
1583
|
/* Save Results */
|
|
1581
1584
|
/* -------------------------------------------------------------------------- */
|
|
1582
|
-
/**
|
|
1583
|
-
* Checks if the given object is a valid and truthy save result
|
|
1584
|
-
* @param result_object
|
|
1585
|
-
* @returns
|
|
1585
|
+
/**
|
|
1586
|
+
* Checks if the given object is a valid and truthy save result
|
|
1587
|
+
* @param result_object
|
|
1588
|
+
* @returns
|
|
1586
1589
|
*/
|
|
1587
1590
|
}, {
|
|
1588
1591
|
key: "isResultValid",
|
|
@@ -1617,19 +1620,18 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1617
1620
|
}) == null;
|
|
1618
1621
|
}
|
|
1619
1622
|
/* ----------------------------- check products/variations ----------------------------- */
|
|
1620
|
-
var
|
|
1621
|
-
|
|
1622
|
-
var vk = _varKeys[_i];
|
|
1623
|
+
for (var _i = 0, _arr = ["products", "variations"]; _i < _arr.length; _i++) {
|
|
1624
|
+
var vk = _arr[_i];
|
|
1623
1625
|
if (!(vk in result_object) || (0, _object.array_isEmpty)(result_object[vk])) continue;
|
|
1624
|
-
/**
|
|
1625
|
-
* if one product is not valid the result is not valid
|
|
1626
|
-
* but if all products are valid we still need to check the object itself
|
|
1626
|
+
/**
|
|
1627
|
+
* if one product is not valid the result is not valid
|
|
1628
|
+
* but if all products are valid we still need to check the object itself
|
|
1627
1629
|
*/
|
|
1628
1630
|
if (!this.isResultValid(result_object[vk], depth + 1)) return false;
|
|
1629
1631
|
}
|
|
1630
1632
|
if (result_object.order) {
|
|
1631
|
-
/**
|
|
1632
|
-
* if we get a order-products pair, checking the order is enough
|
|
1633
|
+
/**
|
|
1634
|
+
* if we get a order-products pair, checking the order is enough
|
|
1633
1635
|
*/
|
|
1634
1636
|
return this.isResultValid(result_object.order, depth + 1);
|
|
1635
1637
|
}
|
|
@@ -1647,34 +1649,33 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1647
1649
|
}, {
|
|
1648
1650
|
key: "setTemp",
|
|
1649
1651
|
value: (function () {
|
|
1650
|
-
var _setTemp = _asyncToGenerator(/*#__PURE__*/
|
|
1652
|
+
var _setTemp = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(obj, key, value) {
|
|
1651
1653
|
var sendChanges,
|
|
1652
1654
|
_args16 = arguments;
|
|
1653
|
-
return
|
|
1654
|
-
while (1) switch (_context16.
|
|
1655
|
+
return _regenerator().w(function (_context16) {
|
|
1656
|
+
while (1) switch (_context16.n) {
|
|
1655
1657
|
case 0:
|
|
1656
1658
|
sendChanges = _args16.length > 3 && _args16[3] !== undefined ? _args16[3] : false;
|
|
1657
1659
|
if (!(_typeof(obj) !== "object" || !obj || Array.isArray(obj))) {
|
|
1658
|
-
_context16.
|
|
1660
|
+
_context16.n = 1;
|
|
1659
1661
|
break;
|
|
1660
1662
|
}
|
|
1661
|
-
return _context16.
|
|
1662
|
-
case
|
|
1663
|
+
return _context16.a(2);
|
|
1664
|
+
case 1:
|
|
1663
1665
|
if (!(obj instanceof SimpleObject)) {
|
|
1664
|
-
_context16.
|
|
1666
|
+
_context16.n = 3;
|
|
1665
1667
|
break;
|
|
1666
1668
|
}
|
|
1667
|
-
_context16.
|
|
1669
|
+
_context16.n = 2;
|
|
1668
1670
|
return obj.setTemp(key, value, sendChanges);
|
|
1669
|
-
case
|
|
1670
|
-
return _context16.
|
|
1671
|
-
case
|
|
1671
|
+
case 2:
|
|
1672
|
+
return _context16.a(2, _context16.v);
|
|
1673
|
+
case 3:
|
|
1672
1674
|
//
|
|
1673
1675
|
if (obj.__temp == null) obj.__temp = {};
|
|
1674
1676
|
(0, _object.object_set)(obj.__temp, key, value);
|
|
1675
|
-
case
|
|
1676
|
-
|
|
1677
|
-
return _context16.stop();
|
|
1677
|
+
case 4:
|
|
1678
|
+
return _context16.a(2);
|
|
1678
1679
|
}
|
|
1679
1680
|
}, _callee16);
|
|
1680
1681
|
}));
|
|
@@ -1692,33 +1693,32 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1692
1693
|
}, {
|
|
1693
1694
|
key: "delete_cache",
|
|
1694
1695
|
value: function () {
|
|
1695
|
-
var _delete_cache = _asyncToGenerator(/*#__PURE__*/
|
|
1696
|
+
var _delete_cache = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(context) {
|
|
1696
1697
|
var cacheKey;
|
|
1697
|
-
return
|
|
1698
|
-
while (1) switch (_context17.
|
|
1698
|
+
return _regenerator().w(function (_context17) {
|
|
1699
|
+
while (1) switch (_context17.n) {
|
|
1699
1700
|
case 0:
|
|
1700
1701
|
if (this.__db_name) {
|
|
1701
|
-
_context17.
|
|
1702
|
+
_context17.n = 1;
|
|
1702
1703
|
break;
|
|
1703
1704
|
}
|
|
1704
|
-
return _context17.
|
|
1705
|
-
case
|
|
1705
|
+
return _context17.a(2);
|
|
1706
|
+
case 1:
|
|
1706
1707
|
if (context) {
|
|
1707
|
-
_context17.
|
|
1708
|
+
_context17.n = 3;
|
|
1708
1709
|
break;
|
|
1709
1710
|
}
|
|
1710
|
-
_context17.
|
|
1711
|
+
_context17.n = 2;
|
|
1711
1712
|
return _global.gcache.delete_session_cache(this.__db_name);
|
|
1712
|
-
case
|
|
1713
|
-
_context17.
|
|
1713
|
+
case 2:
|
|
1714
|
+
_context17.n = 4;
|
|
1714
1715
|
break;
|
|
1715
|
-
case
|
|
1716
|
+
case 3:
|
|
1716
1717
|
cacheKey = "".concat(this.__db_name, "-").concat(context);
|
|
1717
|
-
_context17.
|
|
1718
|
+
_context17.n = 4;
|
|
1718
1719
|
return _global.gcache.delete_session_cache(cacheKey);
|
|
1719
|
-
case
|
|
1720
|
-
|
|
1721
|
-
return _context17.stop();
|
|
1720
|
+
case 4:
|
|
1721
|
+
return _context17.a(2);
|
|
1722
1722
|
}
|
|
1723
1723
|
}, _callee17, this);
|
|
1724
1724
|
}));
|
|
@@ -1743,50 +1743,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1743
1743
|
}
|
|
1744
1744
|
}]);
|
|
1745
1745
|
}(_MapableObject2.MapableObject);
|
|
1746
|
-
function _getSubProperty(key, subkey) {
|
|
1747
|
-
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1748
|
-
var subobj = this.get(key, original);
|
|
1749
|
-
if (subobj == null || _typeof(subobj) !== "object") return undefined;
|
|
1750
|
-
return subobj[subkey];
|
|
1751
|
-
}
|
|
1752
|
-
function _setSubProperty(key, subkey, value) {
|
|
1753
|
-
var subobj = this.get(key);
|
|
1754
|
-
//@ts-ignore
|
|
1755
|
-
if (subobj == null || _typeof(subobj) !== "object") subobj = {};else subobj = _objectSpread({}, subobj); //make a clone so we dont update the original
|
|
1756
|
-
subobj[subkey] = value;
|
|
1757
|
-
_assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, key, subobj);
|
|
1758
|
-
}
|
|
1759
|
-
/**
|
|
1760
|
-
* update a property on this object by updating the `__delta`
|
|
1761
|
-
* or update the object property directly depending on `__use_delta` setting
|
|
1762
|
-
*
|
|
1763
|
-
* @param key
|
|
1764
|
-
* @param value
|
|
1765
|
-
*/
|
|
1766
|
-
function _setProperty(key, value) {
|
|
1767
|
-
var checkIsChanged = false;
|
|
1768
|
-
if (this.__use_delta) {
|
|
1769
|
-
if (this[key] === value) {
|
|
1770
|
-
/**
|
|
1771
|
-
* we set something back to its original value
|
|
1772
|
-
* no need to save it as delta
|
|
1773
|
-
*/
|
|
1774
|
-
delete this.__delta[key];
|
|
1775
|
-
////checkIsChanged = true; //check if we should set __has_delta to false
|
|
1776
|
-
} else {
|
|
1777
|
-
this.__delta[key] = value; //always update delta to keep track of changes
|
|
1778
|
-
}
|
|
1779
|
-
} else {
|
|
1780
|
-
this[key] = value; //on noDelta mode update the object itself
|
|
1781
|
-
this.__delta[key] = value; //always update delta to keep track of changes
|
|
1782
|
-
}
|
|
1783
|
-
return true;
|
|
1784
|
-
}
|
|
1785
|
-
function _setSaveResultObject(toObj) {
|
|
1786
|
-
if (toObj == null) toObj = null; //null or undefined
|
|
1787
|
-
this.__saveResultObject = toObj;
|
|
1788
|
-
return true;
|
|
1789
|
-
}
|
|
1790
1746
|
_defineProperty(SimpleObject, "__db_name", "");
|
|
1791
1747
|
_defineProperty(SimpleObject, "__object_name", "");
|
|
1792
1748
|
//these properties should not be changed and are usually set by server
|