@azrico/webobject 1.5.59 → 1.5.62
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/README.md +9 -9
- package/dist/index.js +1 -16
- package/dist/src/WebObjects/ParentWebObject.js +71 -115
- package/dist/src/WebObjects/WebObject.js +584 -1554
- package/dist/src/WebObjects/WebObjectHelper.js +15 -35
- package/dist/src/WebObjects/WebObjectHelper.test.js +45 -67
- package/dist/src/WebObjects/WebObjectManager.js +265 -864
- package/dist/src/WebObjects/WebObjectPathHelper.js +71 -142
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +31 -122
- package/dist/src/index.js +10 -115
- package/dist/src/structs/DummyObject.js +8 -32
- package/dist/src/structs/MapableObject.js +75 -121
- package/dist/src/structs/MetaObject.js +35 -121
- package/dist/src/structs/ObjectArray.js +43 -68
- package/dist/src/structs/ObjectManager.d.ts +11 -6
- package/dist/src/structs/ObjectManager.js +285 -739
- package/dist/src/structs/ObjectWithTemp.d.ts +5 -0
- package/dist/src/structs/ObjectWithTemp.js +33 -64
- package/dist/src/structs/SimpleObject.js +1052 -1660
- package/package.json +1 -1
- package/dist/src/structs/SimpleObject.d.ts +0 -305
|
@@ -1,658 +1,269 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var _event = require("@azrico/event");
|
|
8
|
-
var _SimpleObject = _interopRequireDefault(require("./SimpleObject"));
|
|
9
|
-
var _string = require("@azrico/string");
|
|
10
|
-
var _global = require("@azrico/global");
|
|
11
|
-
var _object = require("@azrico/object");
|
|
12
|
-
var _MapableObject = _interopRequireDefault(require("./MapableObject"));
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
|
-
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); }
|
|
15
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
16
|
-
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); }
|
|
17
|
-
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); }); }; }
|
|
18
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
19
|
-
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); } }
|
|
20
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
21
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
22
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
23
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
24
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
|
-
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
26
|
-
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
|
|
27
|
-
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
28
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
29
|
-
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); }
|
|
30
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
31
|
-
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; }
|
|
32
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
33
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
|
+
import { EventManager } from "@azrico/event";
|
|
2
|
+
import SimpleObject from "./SimpleObject";
|
|
3
|
+
import { combine_if_not_blank } from "@azrico/string";
|
|
4
|
+
import { gfunc } from "@azrico/global";
|
|
5
|
+
import { fn_eval, object_equals_loose, } from "@azrico/object";
|
|
6
|
+
import RawObject from "./MapableObject";
|
|
34
7
|
/**
|
|
35
8
|
* This class manages the events of an Simple Object
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
case 0:
|
|
62
|
-
obj = this.getObject();
|
|
63
|
-
if (obj) {
|
|
64
|
-
_context.next = 3;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
return _context.abrupt("return", false);
|
|
68
|
-
case 3:
|
|
69
|
-
if (value === undefined && type != "meta") value = obj.get(key);
|
|
70
|
-
typestr = (type ? "$".concat(type, "$") : "") + String(key);
|
|
71
|
-
_context.next = 7;
|
|
72
|
-
return this.event_run("on_change", typestr, value);
|
|
73
|
-
case 7:
|
|
74
|
-
return _context.abrupt("return", _context.sent);
|
|
75
|
-
case 8:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}, _callee, this);
|
|
80
|
-
}));
|
|
81
|
-
function notifyChanged(_x, _x2, _x3, _x4) {
|
|
82
|
-
return _notifyChanged.apply(this, arguments);
|
|
83
|
-
}
|
|
84
|
-
return notifyChanged;
|
|
85
|
-
}()
|
|
86
|
-
/* -------------------------------------------------------------------------- */
|
|
9
|
+
*/
|
|
10
|
+
export class ObjectManager extends RawObject {
|
|
11
|
+
__eventList = {};
|
|
12
|
+
__eventPrefix;
|
|
13
|
+
__stopEvents;
|
|
14
|
+
static __object_type;
|
|
15
|
+
__last_object_data = {};
|
|
16
|
+
__currentObject;
|
|
17
|
+
__options;
|
|
18
|
+
//can the current object be set to null safely?
|
|
19
|
+
__object_nullable = false;
|
|
20
|
+
constructor(defaultObject) {
|
|
21
|
+
super();
|
|
22
|
+
this.setObject(defaultObject);
|
|
23
|
+
}
|
|
24
|
+
async notifyChanged(type, key, value, subvalue) {
|
|
25
|
+
const obj = this.getObject();
|
|
26
|
+
if (!obj)
|
|
27
|
+
return false;
|
|
28
|
+
if (value === undefined && type != "meta")
|
|
29
|
+
value = obj.get(key);
|
|
30
|
+
const typestr = (type ? `$${type}$` : "") + String(key);
|
|
31
|
+
return await this.event_run("on_change", typestr, value);
|
|
32
|
+
}
|
|
33
|
+
/* -------------------------------------------------------------------------- */
|
|
87
34
|
/**
|
|
88
35
|
* Get the object this manager is managing
|
|
89
36
|
* @returns the object
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var _this$__currentObject;
|
|
95
|
-
return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
|
|
96
|
-
}
|
|
37
|
+
*/
|
|
38
|
+
get obj() {
|
|
39
|
+
return this.__currentObject ?? undefined;
|
|
40
|
+
}
|
|
97
41
|
/**
|
|
98
42
|
* Get the object this manager is managing
|
|
99
43
|
* @returns the object
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var _this$__currentObject2;
|
|
105
|
-
return (_this$__currentObject2 = this.__currentObject) !== null && _this$__currentObject2 !== void 0 ? _this$__currentObject2 : undefined;
|
|
106
|
-
}
|
|
44
|
+
*/
|
|
45
|
+
getObject() {
|
|
46
|
+
return this.__currentObject ?? undefined;
|
|
47
|
+
}
|
|
107
48
|
/**
|
|
108
49
|
* Set the object this manager is managing
|
|
109
50
|
* @param toObj
|
|
110
51
|
* @returns
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
get
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
key
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return ((_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.getSaveResult()) || null;
|
|
179
|
-
}
|
|
180
|
-
}, {
|
|
181
|
-
key: "getSaveResultType",
|
|
182
|
-
value: function getSaveResultType() {
|
|
183
|
-
var _this$obj5;
|
|
184
|
-
return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.getSaveResultType()) || null;
|
|
185
|
-
}
|
|
186
|
-
}, {
|
|
187
|
-
key: "setSaveResult",
|
|
188
|
-
value: function setSaveResult(toObj, type) {
|
|
189
|
-
var _this$obj6;
|
|
190
|
-
return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setSaveResult(toObj, type);
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "apply_changes",
|
|
194
|
-
value: function apply_changes() {
|
|
195
|
-
var _this$obj7;
|
|
196
|
-
return ((_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.apply_changes()) || false;
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "get",
|
|
200
|
-
value: function get(key) {
|
|
201
|
-
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
202
|
-
var thisobj = this.obj;
|
|
203
|
-
if (thisobj == null || typeof thisobj.get != "function") {
|
|
204
|
-
if (!this.__object_nullable) console.error("cant use get when object is not defined. maybe you have to use New() ?");
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
return thisobj.get(key, original);
|
|
208
|
-
}
|
|
52
|
+
*/
|
|
53
|
+
setObject(toObj) {
|
|
54
|
+
this.__currentObject = toObj;
|
|
55
|
+
if (this.obj) {
|
|
56
|
+
this.obj.get_managerClass = () => this;
|
|
57
|
+
// this.obj.set_managerClass(this);
|
|
58
|
+
}
|
|
59
|
+
if (toObj == null && !this.__object_nullable) {
|
|
60
|
+
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/* -------------------------------------------------------------------------- */
|
|
65
|
+
/* Child functions */
|
|
66
|
+
/* -------------------------------------------------------------------------- */
|
|
67
|
+
get d() {
|
|
68
|
+
return this.obj?.d || {};
|
|
69
|
+
}
|
|
70
|
+
get isChanged() {
|
|
71
|
+
return this.obj != null && this.obj.isChanged;
|
|
72
|
+
}
|
|
73
|
+
get isDeleted() {
|
|
74
|
+
return this.obj == null || this.obj.isDeleted;
|
|
75
|
+
}
|
|
76
|
+
get isArchived() {
|
|
77
|
+
return this.obj == null || this.obj.isArchived;
|
|
78
|
+
}
|
|
79
|
+
get isLocked() {
|
|
80
|
+
return this.obj == null || this.obj.isLocked;
|
|
81
|
+
}
|
|
82
|
+
get canModify() {
|
|
83
|
+
return !this.obj?.canModify;
|
|
84
|
+
}
|
|
85
|
+
get isNew() {
|
|
86
|
+
return this.obj == null || this.obj.isNew;
|
|
87
|
+
}
|
|
88
|
+
get isSaved() {
|
|
89
|
+
return this.obj?.isSaved || false;
|
|
90
|
+
}
|
|
91
|
+
getSaveResult() {
|
|
92
|
+
return this.obj?.getSaveResult() || null;
|
|
93
|
+
}
|
|
94
|
+
getSaveResultType() {
|
|
95
|
+
return this.obj?.getSaveResultType() || null;
|
|
96
|
+
}
|
|
97
|
+
setSaveResult(toObj, type) {
|
|
98
|
+
return this.obj?.setSaveResult(toObj, type);
|
|
99
|
+
}
|
|
100
|
+
apply_changes() {
|
|
101
|
+
return this.obj?.apply_changes() || false;
|
|
102
|
+
}
|
|
103
|
+
get(key, original = false) {
|
|
104
|
+
const thisobj = this.obj;
|
|
105
|
+
if (thisobj == null || typeof thisobj.get != "function") {
|
|
106
|
+
if (!this.__object_nullable)
|
|
107
|
+
console.error("cant use get when object is not defined. maybe you have to use New() ?");
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return thisobj.get(key, original);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* use a property from the object, this will return latest value of the property
|
|
114
|
+
* uses `EventManager` to detect changes
|
|
115
|
+
*/
|
|
116
|
+
use(key) {
|
|
117
|
+
return EventManager.useProperty(this, key);
|
|
118
|
+
}
|
|
209
119
|
/**
|
|
210
120
|
* set value
|
|
211
121
|
* @param key
|
|
212
122
|
* @param value
|
|
213
123
|
* @return true if changed , false otherwise
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (!(thisobj == null || typeof thisobj.set != "function")) {
|
|
225
|
-
_context2.next = 4;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
if (!this.__object_nullable) console.error("cant use set when object is not defined. maybe you have to use New() ?");
|
|
229
|
-
return _context2.abrupt("return", false);
|
|
230
|
-
case 4:
|
|
231
|
-
_context2.next = 6;
|
|
232
|
-
return thisobj.set(key, value);
|
|
233
|
-
case 6:
|
|
234
|
-
_context2.t0 = _context2.sent;
|
|
235
|
-
if (_context2.t0) {
|
|
236
|
-
_context2.next = 9;
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
_context2.t0 = false;
|
|
240
|
-
case 9:
|
|
241
|
-
return _context2.abrupt("return", _context2.t0);
|
|
242
|
-
case 10:
|
|
243
|
-
case "end":
|
|
244
|
-
return _context2.stop();
|
|
245
|
-
}
|
|
246
|
-
}, _callee2, this);
|
|
247
|
-
}));
|
|
248
|
-
function set(_x5, _x6) {
|
|
249
|
-
return _set.apply(this, arguments);
|
|
250
|
-
}
|
|
251
|
-
return set;
|
|
252
|
-
}()
|
|
124
|
+
*/
|
|
125
|
+
async set(key, value) {
|
|
126
|
+
const thisobj = this.obj;
|
|
127
|
+
if (thisobj == null || typeof thisobj.set != "function") {
|
|
128
|
+
if (!this.__object_nullable)
|
|
129
|
+
console.error("cant use set when object is not defined. maybe you have to use New() ?");
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return (await thisobj.set(key, value)) || false;
|
|
133
|
+
}
|
|
253
134
|
/**
|
|
254
135
|
* set key of subObject
|
|
255
136
|
* @param key
|
|
256
137
|
* @param value
|
|
257
138
|
* @param subvalue
|
|
258
139
|
* @return true if changed , false otherwise
|
|
259
|
-
*/
|
|
260
|
-
)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
value
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}() //Push value on array
|
|
302
|
-
)
|
|
303
|
-
}, {
|
|
304
|
-
key: "pushValue",
|
|
305
|
-
value: function () {
|
|
306
|
-
var _pushValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
|
|
307
|
-
var _yield$this$obj$pushV, _this$obj9;
|
|
308
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
309
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
310
|
-
case 0:
|
|
311
|
-
_context4.next = 2;
|
|
312
|
-
return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.pushValue(key, value);
|
|
313
|
-
case 2:
|
|
314
|
-
_context4.t1 = _yield$this$obj$pushV = _context4.sent;
|
|
315
|
-
_context4.t0 = _context4.t1 !== null;
|
|
316
|
-
if (!_context4.t0) {
|
|
317
|
-
_context4.next = 6;
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
_context4.t0 = _yield$this$obj$pushV !== void 0;
|
|
321
|
-
case 6:
|
|
322
|
-
if (!_context4.t0) {
|
|
323
|
-
_context4.next = 10;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
_context4.t2 = _yield$this$obj$pushV;
|
|
327
|
-
_context4.next = 11;
|
|
328
|
-
break;
|
|
329
|
-
case 10:
|
|
330
|
-
_context4.t2 = false;
|
|
331
|
-
case 11:
|
|
332
|
-
return _context4.abrupt("return", _context4.t2);
|
|
333
|
-
case 12:
|
|
334
|
-
case "end":
|
|
335
|
-
return _context4.stop();
|
|
336
|
-
}
|
|
337
|
-
}, _callee4, this);
|
|
338
|
-
}));
|
|
339
|
-
function pushValue(_x10, _x11) {
|
|
340
|
-
return _pushValue.apply(this, arguments);
|
|
341
|
-
}
|
|
342
|
-
return pushValue;
|
|
343
|
-
}() //set temp value of object
|
|
344
|
-
}, {
|
|
345
|
-
key: "setTemp",
|
|
346
|
-
value: function () {
|
|
347
|
-
var _setTemp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
|
|
348
|
-
var sendChanges,
|
|
349
|
-
_args5 = arguments;
|
|
350
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
351
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
352
|
-
case 0:
|
|
353
|
-
sendChanges = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : false;
|
|
354
|
-
_context5.next = 3;
|
|
355
|
-
return this.setObjectTemp(key, value, sendChanges);
|
|
356
|
-
case 3:
|
|
357
|
-
_context5.next = 5;
|
|
358
|
-
return _superPropGet(ObjectManager, "setTemp", this, 3)([key, value]);
|
|
359
|
-
case 5:
|
|
360
|
-
return _context5.abrupt("return", _context5.sent);
|
|
361
|
-
case 6:
|
|
362
|
-
case "end":
|
|
363
|
-
return _context5.stop();
|
|
364
|
-
}
|
|
365
|
-
}, _callee5, this);
|
|
366
|
-
}));
|
|
367
|
-
function setTemp(_x12, _x13) {
|
|
368
|
-
return _setTemp.apply(this, arguments);
|
|
369
|
-
}
|
|
370
|
-
return setTemp;
|
|
371
|
-
}() //set temp value of object
|
|
372
|
-
}, {
|
|
373
|
-
key: "setObjectTemp",
|
|
374
|
-
value: function () {
|
|
375
|
-
var _setObjectTemp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key, value) {
|
|
376
|
-
var _yield$this$obj$setTe, _this$obj10;
|
|
377
|
-
var sendChanges,
|
|
378
|
-
_args6 = arguments;
|
|
379
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
380
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
381
|
-
case 0:
|
|
382
|
-
sendChanges = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : false;
|
|
383
|
-
_context6.next = 3;
|
|
384
|
-
return (_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.setTemp(key, value, sendChanges);
|
|
385
|
-
case 3:
|
|
386
|
-
_context6.t1 = _yield$this$obj$setTe = _context6.sent;
|
|
387
|
-
_context6.t0 = _context6.t1 !== null;
|
|
388
|
-
if (!_context6.t0) {
|
|
389
|
-
_context6.next = 7;
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
_context6.t0 = _yield$this$obj$setTe !== void 0;
|
|
393
|
-
case 7:
|
|
394
|
-
if (!_context6.t0) {
|
|
395
|
-
_context6.next = 11;
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
|
-
_context6.t2 = _yield$this$obj$setTe;
|
|
399
|
-
_context6.next = 12;
|
|
400
|
-
break;
|
|
401
|
-
case 11:
|
|
402
|
-
_context6.t2 = false;
|
|
403
|
-
case 12:
|
|
404
|
-
return _context6.abrupt("return", _context6.t2);
|
|
405
|
-
case 13:
|
|
406
|
-
case "end":
|
|
407
|
-
return _context6.stop();
|
|
408
|
-
}
|
|
409
|
-
}, _callee6, this);
|
|
410
|
-
}));
|
|
411
|
-
function setObjectTemp(_x14, _x15) {
|
|
412
|
-
return _setObjectTemp.apply(this, arguments);
|
|
413
|
-
}
|
|
414
|
-
return setObjectTemp;
|
|
415
|
-
}() //get temp value of object
|
|
416
|
-
}, {
|
|
417
|
-
key: "getObjectTemp",
|
|
418
|
-
value: function getObjectTemp(key) {
|
|
419
|
-
var _this$obj$getTemp, _this$obj11;
|
|
420
|
-
return (_this$obj$getTemp = (_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getTemp(key)) !== null && _this$obj$getTemp !== void 0 ? _this$obj$getTemp : undefined;
|
|
421
|
-
}
|
|
422
|
-
/* -------------------------------------------------------------------------- */
|
|
423
|
-
}, {
|
|
424
|
-
key: "getIndexOrID",
|
|
425
|
-
value: function getIndexOrID() {
|
|
426
|
-
var _this$obj12;
|
|
427
|
-
return ((_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.getIndexOrID()) || -1;
|
|
428
|
-
}
|
|
429
|
-
}, {
|
|
430
|
-
key: "getIndex",
|
|
431
|
-
value: function getIndex() {
|
|
432
|
-
var _this$obj13;
|
|
433
|
-
return ((_this$obj13 = this.obj) === null || _this$obj13 === void 0 ? void 0 : _this$obj13.getIndex()) || -1;
|
|
434
|
-
}
|
|
435
|
-
}, {
|
|
436
|
-
key: "getID",
|
|
437
|
-
value: function getID() {
|
|
438
|
-
var _this$obj14;
|
|
439
|
-
return ((_this$obj14 = this.obj) === null || _this$obj14 === void 0 ? void 0 : _this$obj14.getID()) || "";
|
|
440
|
-
}
|
|
441
|
-
/* -------------------------------------------------------------------------- */
|
|
442
|
-
/* Events */
|
|
443
|
-
/* -------------------------------------------------------------------------- */
|
|
444
|
-
}, {
|
|
445
|
-
key: "event_run",
|
|
446
|
-
value: (function () {
|
|
447
|
-
var _event_run = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
|
|
448
|
-
var _len,
|
|
449
|
-
params,
|
|
450
|
-
_key,
|
|
451
|
-
_args7 = arguments;
|
|
452
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
453
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
454
|
-
case 0:
|
|
455
|
-
if (!(this.__stopEvents === true)) {
|
|
456
|
-
_context7.next = 2;
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
return _context7.abrupt("return");
|
|
460
|
-
case 2:
|
|
461
|
-
for (_len = _args7.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
462
|
-
params[_key - 1] = _args7[_key];
|
|
463
|
-
}
|
|
464
|
-
_context7.next = 5;
|
|
465
|
-
return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
|
|
466
|
-
case 5:
|
|
467
|
-
return _context7.abrupt("return", _context7.sent);
|
|
468
|
-
case 6:
|
|
469
|
-
case "end":
|
|
470
|
-
return _context7.stop();
|
|
471
|
-
}
|
|
472
|
-
}, _callee7, this);
|
|
473
|
-
}));
|
|
474
|
-
function event_run(_x16) {
|
|
475
|
-
return _event_run.apply(this, arguments);
|
|
476
|
-
}
|
|
477
|
-
return event_run;
|
|
478
|
-
}())
|
|
479
|
-
}, {
|
|
480
|
-
key: "event_use",
|
|
481
|
-
value: function event_use(name, runEvent) {
|
|
482
|
-
var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
483
|
-
var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
484
|
-
return _event.EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
485
|
-
}
|
|
140
|
+
*/
|
|
141
|
+
async setSubValue(key, objKey, subvalue) {
|
|
142
|
+
return ((await this.obj?.setSubValue(key, objKey, subvalue)) ?? false);
|
|
143
|
+
}
|
|
144
|
+
//Push value on array
|
|
145
|
+
async pushValue(key, value) {
|
|
146
|
+
return (await this.obj?.pushValue(key, value)) ?? false;
|
|
147
|
+
}
|
|
148
|
+
//set temp value of object
|
|
149
|
+
async setTemp(key, value, sendChanges = false) {
|
|
150
|
+
await this.setObjectTemp(key, value, sendChanges);
|
|
151
|
+
return await super.setTemp(key, value);
|
|
152
|
+
}
|
|
153
|
+
//set temp value of object
|
|
154
|
+
async setObjectTemp(key, value, sendChanges = false) {
|
|
155
|
+
return (await this.obj?.setTemp(key, value, sendChanges)) ?? false;
|
|
156
|
+
}
|
|
157
|
+
//get temp value of object
|
|
158
|
+
getObjectTemp(key) {
|
|
159
|
+
return this.obj?.getTemp(key) ?? undefined;
|
|
160
|
+
}
|
|
161
|
+
/* -------------------------------------------------------------------------- */
|
|
162
|
+
getIndexOrID() {
|
|
163
|
+
return this.obj?.getIndexOrID() || -1;
|
|
164
|
+
}
|
|
165
|
+
getIndex() {
|
|
166
|
+
return this.obj?.getIndex() || -1;
|
|
167
|
+
}
|
|
168
|
+
getID() {
|
|
169
|
+
return this.obj?.getID() || "";
|
|
170
|
+
}
|
|
171
|
+
/* -------------------------------------------------------------------------- */
|
|
172
|
+
/* Events */
|
|
173
|
+
/* -------------------------------------------------------------------------- */
|
|
174
|
+
async event_run(eventName, ...params) {
|
|
175
|
+
if (this.__stopEvents === true)
|
|
176
|
+
return;
|
|
177
|
+
return await EventManager.run(this, eventName, ...params);
|
|
178
|
+
}
|
|
179
|
+
event_use(name, runEvent, onlyOn = null, runOnce = false) {
|
|
180
|
+
return EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
181
|
+
}
|
|
486
182
|
/**
|
|
487
183
|
* only useful for getter functions that dont rely on states
|
|
488
184
|
* @param name
|
|
489
185
|
* @param runEvent
|
|
490
186
|
* @param onlyOn
|
|
491
187
|
* @returns
|
|
492
|
-
*/
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}));
|
|
524
|
-
function event_add(_x17, _x18, _x19) {
|
|
525
|
-
return _event_add.apply(this, arguments);
|
|
526
|
-
}
|
|
527
|
-
return event_add;
|
|
528
|
-
}()
|
|
529
|
-
}, {
|
|
530
|
-
key: "events_start",
|
|
531
|
-
value: function events_start() {
|
|
532
|
-
delete this.__stopEvents;
|
|
533
|
-
}
|
|
534
|
-
}, {
|
|
535
|
-
key: "events_stop",
|
|
536
|
-
value: function events_stop() {
|
|
537
|
-
this.__stopEvents = true;
|
|
538
|
-
}
|
|
539
|
-
}, {
|
|
540
|
-
key: "events_clear",
|
|
541
|
-
value: function events_clear() {
|
|
542
|
-
ObjectManager.events_clear(this);
|
|
543
|
-
}
|
|
544
|
-
}, {
|
|
545
|
-
key: "clear_changes",
|
|
546
|
-
value: function clear_changes() {
|
|
547
|
-
var _this$obj15;
|
|
548
|
-
return (_this$obj15 = this.obj) === null || _this$obj15 === void 0 ? void 0 : _this$obj15.clear_changes();
|
|
549
|
-
}
|
|
550
|
-
}, {
|
|
551
|
-
key: "clear_cache",
|
|
552
|
-
value: function clear_cache() {
|
|
553
|
-
var _this$obj16;
|
|
554
|
-
return (_this$obj16 = this.obj) === null || _this$obj16 === void 0 ? void 0 : _this$obj16.clear_cache();
|
|
555
|
-
}
|
|
556
|
-
}, {
|
|
557
|
-
key: "toggleOption",
|
|
558
|
-
value: (
|
|
559
|
-
/* -------------------------------------------------------------------------- */
|
|
560
|
-
/* Options */
|
|
561
|
-
/* -------------------------------------------------------------------------- */
|
|
188
|
+
*/
|
|
189
|
+
event_use_getter(name, runEvent, onlyOn = null) {
|
|
190
|
+
return EventManager.use_getter(this, name, runEvent, onlyOn);
|
|
191
|
+
}
|
|
192
|
+
event_remove(name, uname) {
|
|
193
|
+
return EventManager.remove(this, name, uname);
|
|
194
|
+
}
|
|
195
|
+
async event_add(name, uname, runEvent, onlyOn = null, runOnce = false) {
|
|
196
|
+
await EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
197
|
+
}
|
|
198
|
+
events_start() {
|
|
199
|
+
delete this.__stopEvents;
|
|
200
|
+
}
|
|
201
|
+
events_stop() {
|
|
202
|
+
this.__stopEvents = true;
|
|
203
|
+
}
|
|
204
|
+
events_clear() {
|
|
205
|
+
ObjectManager.events_clear(this);
|
|
206
|
+
}
|
|
207
|
+
clear_changes() {
|
|
208
|
+
return this.obj?.clear_changes() ?? false;
|
|
209
|
+
}
|
|
210
|
+
clear_cache() {
|
|
211
|
+
return this.obj?.clear_cache() ?? false;
|
|
212
|
+
}
|
|
213
|
+
static events_clear(obj) {
|
|
214
|
+
EventManager.removeAll(obj);
|
|
215
|
+
}
|
|
216
|
+
/* -------------------------------------------------------------------------- */
|
|
217
|
+
/* Options */
|
|
218
|
+
/* -------------------------------------------------------------------------- */
|
|
562
219
|
/**
|
|
563
220
|
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
564
221
|
* @param key
|
|
565
222
|
* @param value
|
|
566
223
|
* @returns
|
|
567
|
-
*/
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
_context9.next = 8;
|
|
583
|
-
break;
|
|
584
|
-
case 6:
|
|
585
|
-
_context9.next = 8;
|
|
586
|
-
return this.setOption(key, value);
|
|
587
|
-
case 8:
|
|
588
|
-
case "end":
|
|
589
|
-
return _context9.stop();
|
|
590
|
-
}
|
|
591
|
-
}, _callee9, this);
|
|
592
|
-
}));
|
|
593
|
-
function toggleOption(_x20, _x21) {
|
|
594
|
-
return _toggleOption.apply(this, arguments);
|
|
595
|
-
}
|
|
596
|
-
return toggleOption;
|
|
597
|
-
}())
|
|
598
|
-
}, {
|
|
599
|
-
key: "getOption",
|
|
600
|
-
value: function getOption(key) {
|
|
601
|
-
if (this.__options == null) return undefined;
|
|
602
|
-
key = key.toLowerCase();
|
|
603
|
-
return this.__options[key];
|
|
604
|
-
}
|
|
224
|
+
*/
|
|
225
|
+
async toggleOption(key, value) {
|
|
226
|
+
var oldval = this.getOption(key);
|
|
227
|
+
if (object_equals_loose(oldval, value)) {
|
|
228
|
+
await this.setOption(key, null);
|
|
229
|
+
}
|
|
230
|
+
else
|
|
231
|
+
await this.setOption(key, value);
|
|
232
|
+
}
|
|
233
|
+
getOption(key) {
|
|
234
|
+
if (this.__options == null)
|
|
235
|
+
return undefined;
|
|
236
|
+
key = key.toLowerCase();
|
|
237
|
+
return this.__options[key];
|
|
238
|
+
}
|
|
605
239
|
/**
|
|
606
240
|
* updates `__options` and runs the `event_run`
|
|
607
241
|
* @param key
|
|
608
242
|
* @param value
|
|
609
243
|
* @returns true if changed, false otherwise
|
|
610
|
-
*/
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
this.__options[key] = value;
|
|
626
|
-
}
|
|
627
|
-
_context10.next = 6;
|
|
628
|
-
return this.event_run("on_option_change", key, value);
|
|
629
|
-
case 6:
|
|
630
|
-
return _context10.abrupt("return", isChanged);
|
|
631
|
-
case 7:
|
|
632
|
-
case "end":
|
|
633
|
-
return _context10.stop();
|
|
634
|
-
}
|
|
635
|
-
}, _callee10, this);
|
|
636
|
-
}));
|
|
637
|
-
function setOption(_x22, _x23) {
|
|
638
|
-
return _setOption.apply(this, arguments);
|
|
639
|
-
}
|
|
640
|
-
return setOption;
|
|
641
|
-
}()
|
|
244
|
+
*/
|
|
245
|
+
async setOption(key, value) {
|
|
246
|
+
if (this.__options == null)
|
|
247
|
+
this.__options = {};
|
|
248
|
+
key = key.toLowerCase();
|
|
249
|
+
const isChanged = this.__options[key] !== value;
|
|
250
|
+
if (value == null) {
|
|
251
|
+
delete this.__options[key];
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
this.__options[key] = value;
|
|
255
|
+
}
|
|
256
|
+
await this.event_run("on_option_change", key, value);
|
|
257
|
+
return isChanged;
|
|
258
|
+
}
|
|
642
259
|
/**
|
|
643
|
-
* use an option and detect its changes in real time. similar to
|
|
260
|
+
* use an option and detect its changes in real time. similar to React state
|
|
644
261
|
* @param key name of the option
|
|
645
262
|
* @returns value of the option
|
|
646
|
-
*/
|
|
647
|
-
)
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
value: function useOption(key) {
|
|
651
|
-
var _this3 = this;
|
|
652
|
-
return this.event_use_getter("on_option_change", function () {
|
|
653
|
-
return _this3.getOption(key);
|
|
654
|
-
}, [key]);
|
|
655
|
-
}
|
|
263
|
+
*/
|
|
264
|
+
useOption(key) {
|
|
265
|
+
return this.event_use_getter("on_option_change", () => this.getOption(key), [key]);
|
|
266
|
+
}
|
|
656
267
|
/**
|
|
657
268
|
* Sets an option then does an action,
|
|
658
269
|
* after the action is run, updates the option again
|
|
@@ -660,131 +271,66 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
|
|
|
660
271
|
* @param value
|
|
661
272
|
* @param nextvalue
|
|
662
273
|
* @param action
|
|
663
|
-
*/
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
break;
|
|
676
|
-
}
|
|
677
|
-
_context11.next = 5;
|
|
678
|
-
return action();
|
|
679
|
-
case 5:
|
|
680
|
-
_context11.prev = 5;
|
|
681
|
-
this.setOption(key, nextvalue);
|
|
682
|
-
return _context11.finish(5);
|
|
683
|
-
case 8:
|
|
684
|
-
case "end":
|
|
685
|
-
return _context11.stop();
|
|
686
|
-
}
|
|
687
|
-
}, _callee11, this, [[0,, 5, 8]]);
|
|
688
|
-
}));
|
|
689
|
-
function holdOption(_x24, _x25, _x26, _x27) {
|
|
690
|
-
return _holdOption.apply(this, arguments);
|
|
691
|
-
}
|
|
692
|
-
return holdOption;
|
|
693
|
-
}()
|
|
694
|
-
/* -------------------------------------------------------------------------- */
|
|
695
|
-
/* Errors */
|
|
696
|
-
/* -------------------------------------------------------------------------- */
|
|
697
|
-
)
|
|
698
|
-
}, {
|
|
699
|
-
key: "addError",
|
|
700
|
-
value: function addError(title, message) {
|
|
701
|
-
var sendToRegister = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "auto";
|
|
702
|
-
return ObjectManager.addError(this, title, message, sendToRegister);
|
|
703
|
-
}
|
|
704
|
-
}, {
|
|
705
|
-
key: "getErrors",
|
|
706
|
-
value: function getErrors() {
|
|
707
|
-
return ObjectManager.getErrors(this);
|
|
708
|
-
}
|
|
709
|
-
}, {
|
|
710
|
-
key: "clearErrors",
|
|
711
|
-
value: function clearErrors() {
|
|
712
|
-
return ObjectManager.clearErrors(this);
|
|
713
|
-
}
|
|
714
|
-
/* ------------------------------ useIsChanged; ----------------------------- */
|
|
274
|
+
*/
|
|
275
|
+
async holdOption(key, value, nextvalue, action) {
|
|
276
|
+
try {
|
|
277
|
+
this.setOption(key, value);
|
|
278
|
+
if (typeof action === "function")
|
|
279
|
+
await action();
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
this.setOption(key, nextvalue);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/* ------------------------------ useIsChanged; ----------------------------- */
|
|
715
286
|
/**
|
|
716
287
|
* @returns isChanged
|
|
717
|
-
*/
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
title: title,
|
|
767
|
-
message: message,
|
|
768
|
-
type: "error"
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
}, {
|
|
772
|
-
key: "getErrors",
|
|
773
|
-
value: function getErrors(o) {
|
|
774
|
-
var obj = o.obj;
|
|
775
|
-
return obj != null ? _SimpleObject["default"].getErrors(o.obj) : [];
|
|
776
|
-
}
|
|
777
|
-
}, {
|
|
778
|
-
key: "clearErrors",
|
|
779
|
-
value: function clearErrors(o) {
|
|
780
|
-
return _SimpleObject["default"].clearErrors(o.obj);
|
|
781
|
-
}
|
|
782
|
-
}, {
|
|
783
|
-
key: "getObjectType",
|
|
784
|
-
value: function getObjectType() {
|
|
785
|
-
return (0, _object.fn_eval)(this.__object_type);
|
|
786
|
-
}
|
|
787
|
-
}]);
|
|
788
|
-
}(_MapableObject["default"]);
|
|
789
|
-
_defineProperty(ObjectManager, "__object_type", void 0);
|
|
790
|
-
var _default = exports["default"] = ObjectManager;
|
|
288
|
+
*/
|
|
289
|
+
useIsChanged() {
|
|
290
|
+
return this.useOption("ischanged");
|
|
291
|
+
}
|
|
292
|
+
async checkIsChanged() {
|
|
293
|
+
await this.setOption("ischanged", this.isChanged);
|
|
294
|
+
}
|
|
295
|
+
/* -------------------------------------------------------------------------- */
|
|
296
|
+
/* Errors */
|
|
297
|
+
/* -------------------------------------------------------------------------- */
|
|
298
|
+
addError(title, message, sendToRegister = "auto") {
|
|
299
|
+
return ObjectManager.addError(this, title, message, sendToRegister);
|
|
300
|
+
}
|
|
301
|
+
getErrors() {
|
|
302
|
+
return ObjectManager.getErrors(this);
|
|
303
|
+
}
|
|
304
|
+
clearErrors() {
|
|
305
|
+
return ObjectManager.clearErrors(this);
|
|
306
|
+
}
|
|
307
|
+
static addError(o, title, message, sendToRegister = "auto") {
|
|
308
|
+
if (o && o.obj) {
|
|
309
|
+
return SimpleObject.addError(o.obj, title, message, sendToRegister);
|
|
310
|
+
}
|
|
311
|
+
const errStr = combine_if_not_blank(title, " : ", message);
|
|
312
|
+
console.error("[REGISTER-ERROR]", errStr);
|
|
313
|
+
gfunc.run_action("add_error", {
|
|
314
|
+
title: title,
|
|
315
|
+
message: message,
|
|
316
|
+
type: "error",
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
static getErrors(o) {
|
|
320
|
+
const obj = o.obj;
|
|
321
|
+
return obj != null ? SimpleObject.getErrors(o.obj) : [];
|
|
322
|
+
}
|
|
323
|
+
static clearErrors(o) {
|
|
324
|
+
return SimpleObject.clearErrors(o.obj);
|
|
325
|
+
}
|
|
326
|
+
/* -------------------------------------------------------------------------- */
|
|
327
|
+
/* get __object_type */
|
|
328
|
+
/* -------------------------------------------------------------------------- */
|
|
329
|
+
getObjectType() {
|
|
330
|
+
return this.constructor["getObjectType"]();
|
|
331
|
+
}
|
|
332
|
+
static getObjectType() {
|
|
333
|
+
return fn_eval(this.__object_type);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
export default ObjectManager;
|