@azrico/webobject 1.4.127 → 1.4.129
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 +20 -51
- package/dist/src/WebObjects/WebObject.js +452 -1032
- package/dist/src/WebObjects/WebObjectManager.js +194 -509
- package/dist/src/index.js +9 -104
- package/dist/src/structs/DummyObject.js +8 -35
- package/dist/src/structs/MapableObject.js +76 -126
- package/dist/src/structs/MetaObject.js +35 -113
- package/dist/src/structs/ObjectArray.js +43 -71
- package/dist/src/structs/ObjectManager.d.ts +2 -2
- package/dist/src/structs/ObjectManager.js +252 -648
- package/dist/src/structs/ObjectWithTemp.js +25 -65
- package/dist/src/structs/SimpleObject.d.ts +5 -6
- package/dist/src/structs/SimpleObject.js +890 -1396
- package/package.json +4 -4
|
@@ -1,599 +1,244 @@
|
|
|
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(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
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 new 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 new 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 new 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(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
17
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
-
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
22
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
23
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
24
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
26
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
32
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
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 { object_equals_loose } from "@azrico/object";
|
|
6
|
+
import RawObject from "./MapableObject";
|
|
33
7
|
/**
|
|
34
8
|
* This class manages the events of an Simple Object
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
_createClass(ObjectManager, [{
|
|
57
|
-
key: "notifyChanged",
|
|
58
|
-
value: function notifyChanged(_x, _x2, _x3, _x4) {
|
|
59
|
-
return (_notifyChanged = _notifyChanged || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(type, key, value, subvalue) {
|
|
60
|
-
var obj, typestr;
|
|
61
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
-
while (1) switch (_context.prev = _context.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
obj = this.getObject();
|
|
65
|
-
if (obj) {
|
|
66
|
-
_context.next = 3;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
return _context.abrupt("return", false);
|
|
70
|
-
case 3:
|
|
71
|
-
if (value === undefined && type != "meta") value = obj.getValue(key);
|
|
72
|
-
typestr = (type ? "$".concat(type, "$") : "") + String(key);
|
|
73
|
-
_context.next = 7;
|
|
74
|
-
return this.event_run("on_change", typestr, value);
|
|
75
|
-
case 7:
|
|
76
|
-
return _context.abrupt("return", _context.sent);
|
|
77
|
-
case 8:
|
|
78
|
-
case "end":
|
|
79
|
-
return _context.stop();
|
|
80
|
-
}
|
|
81
|
-
}, _callee, this);
|
|
82
|
-
}))).apply(this, arguments);
|
|
83
|
-
}
|
|
84
|
-
/* -------------------------------------------------------------------------- */
|
|
9
|
+
*/
|
|
10
|
+
export class ObjectManager extends RawObject {
|
|
11
|
+
__eventList;
|
|
12
|
+
__eventPrefix;
|
|
13
|
+
__stopEvents;
|
|
14
|
+
static __object_type;
|
|
15
|
+
__currentObject;
|
|
16
|
+
__options;
|
|
17
|
+
//can the current object be set to null safely?
|
|
18
|
+
__object_nullable = false;
|
|
19
|
+
async notifyChanged(type, key, value, subvalue) {
|
|
20
|
+
const obj = this.getObject();
|
|
21
|
+
if (!obj)
|
|
22
|
+
return false;
|
|
23
|
+
if (value === undefined && type != "meta")
|
|
24
|
+
value = obj.getValue(key);
|
|
25
|
+
const typestr = (type ? `$${type}$` : "") + String(key);
|
|
26
|
+
return await this.event_run("on_change", typestr, value);
|
|
27
|
+
}
|
|
28
|
+
/* -------------------------------------------------------------------------- */
|
|
85
29
|
/**
|
|
86
30
|
* Get the object this manager is managing
|
|
87
31
|
* @returns the object
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var _this$__currentObject;
|
|
93
|
-
return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
|
|
94
|
-
}
|
|
32
|
+
*/
|
|
33
|
+
get obj() {
|
|
34
|
+
return this.__currentObject ?? undefined;
|
|
35
|
+
}
|
|
95
36
|
/**
|
|
96
37
|
* Get the object this manager is managing
|
|
97
38
|
* @returns the object
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var _this$__currentObject2;
|
|
103
|
-
return (_this$__currentObject2 = this.__currentObject) !== null && _this$__currentObject2 !== void 0 ? _this$__currentObject2 : undefined;
|
|
104
|
-
}
|
|
39
|
+
*/
|
|
40
|
+
getObject() {
|
|
41
|
+
return this.__currentObject ?? undefined;
|
|
42
|
+
}
|
|
105
43
|
/**
|
|
106
44
|
* Set the object this manager is managing
|
|
107
45
|
* @param toObj
|
|
108
46
|
* @returns
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/* -------------------------------------------------------------------------- */
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
get
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
value: function getSaveResult() {
|
|
172
|
-
var _this$obj5;
|
|
173
|
-
return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.getSaveResult()) || null;
|
|
174
|
-
}
|
|
175
|
-
}, {
|
|
176
|
-
key: "getSaveResultType",
|
|
177
|
-
value: function getSaveResultType() {
|
|
178
|
-
var _this$obj6;
|
|
179
|
-
return ((_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.getSaveResultType()) || null;
|
|
180
|
-
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "setSaveResult",
|
|
183
|
-
value: function setSaveResult(toObj, type) {
|
|
184
|
-
var _this$obj7;
|
|
185
|
-
return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.setSaveResult(toObj, type);
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
key: "apply_changes",
|
|
189
|
-
value: function apply_changes() {
|
|
190
|
-
var _this$obj8;
|
|
191
|
-
return ((_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.apply_changes()) || false;
|
|
192
|
-
}
|
|
193
|
-
}, {
|
|
194
|
-
key: "getValue",
|
|
195
|
-
value: function getValue(key) {
|
|
196
|
-
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
197
|
-
var thisobj = this.obj;
|
|
198
|
-
if (thisobj == null || typeof thisobj.getValue != "function") {
|
|
199
|
-
if (!this.__object_nullable) console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
return thisobj.getValue(key, original);
|
|
203
|
-
}
|
|
204
|
-
}, {
|
|
205
|
-
key: "setValue",
|
|
206
|
-
value:
|
|
47
|
+
*/
|
|
48
|
+
setObject(toObj) {
|
|
49
|
+
this.__currentObject = toObj;
|
|
50
|
+
if (this.__currentObject) {
|
|
51
|
+
this.__currentObject.set_managerClass(this);
|
|
52
|
+
}
|
|
53
|
+
if (toObj == null && !this.__object_nullable) {
|
|
54
|
+
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
/* -------------------------------------------------------------------------- */
|
|
59
|
+
/* Child functions */
|
|
60
|
+
/* -------------------------------------------------------------------------- */
|
|
61
|
+
get d() {
|
|
62
|
+
return this.obj?.d || {};
|
|
63
|
+
}
|
|
64
|
+
get isChanged() {
|
|
65
|
+
return this.obj != null && this.obj.isChanged;
|
|
66
|
+
}
|
|
67
|
+
get isDeleted() {
|
|
68
|
+
return this.obj == null || this.obj.isDeleted;
|
|
69
|
+
}
|
|
70
|
+
get isArchived() {
|
|
71
|
+
return this.obj == null || this.obj.isArchived;
|
|
72
|
+
}
|
|
73
|
+
get canModify() {
|
|
74
|
+
return !this.obj?.canModify;
|
|
75
|
+
}
|
|
76
|
+
get isNew() {
|
|
77
|
+
return this.obj == null || this.obj.isNew;
|
|
78
|
+
}
|
|
79
|
+
get isSaved() {
|
|
80
|
+
return this.obj?.isSaved || false;
|
|
81
|
+
}
|
|
82
|
+
get __cache_name() {
|
|
83
|
+
return (this.obj?.__cache_name ||
|
|
84
|
+
this.constructor["__object_type"]?.__cache_name ||
|
|
85
|
+
"");
|
|
86
|
+
}
|
|
87
|
+
getSaveResult() {
|
|
88
|
+
return this.obj?.getSaveResult() || null;
|
|
89
|
+
}
|
|
90
|
+
getSaveResultType() {
|
|
91
|
+
return this.obj?.getSaveResultType() || null;
|
|
92
|
+
}
|
|
93
|
+
setSaveResult(toObj, type) {
|
|
94
|
+
return this.obj?.setSaveResult(toObj, type);
|
|
95
|
+
}
|
|
96
|
+
apply_changes() {
|
|
97
|
+
return this.obj?.apply_changes() || false;
|
|
98
|
+
}
|
|
99
|
+
getValue(key, original = false) {
|
|
100
|
+
const thisobj = this.obj;
|
|
101
|
+
if (thisobj == null || typeof thisobj.getValue != "function") {
|
|
102
|
+
if (!this.__object_nullable)
|
|
103
|
+
console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return thisobj.getValue(key, original);
|
|
107
|
+
}
|
|
108
|
+
get = this.getValue;
|
|
207
109
|
/**
|
|
208
110
|
* set value
|
|
209
111
|
* @param key
|
|
210
112
|
* @param value
|
|
211
113
|
* @return true if changed , false otherwise
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
if (!this.__object_nullable) console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
|
|
225
|
-
return _context2.abrupt("return", false);
|
|
226
|
-
case 4:
|
|
227
|
-
_context2.next = 6;
|
|
228
|
-
return thisobj.setValue(key, value);
|
|
229
|
-
case 6:
|
|
230
|
-
_context2.t0 = _context2.sent;
|
|
231
|
-
if (_context2.t0) {
|
|
232
|
-
_context2.next = 9;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
_context2.t0 = false;
|
|
236
|
-
case 9:
|
|
237
|
-
return _context2.abrupt("return", _context2.t0);
|
|
238
|
-
case 10:
|
|
239
|
-
case "end":
|
|
240
|
-
return _context2.stop();
|
|
241
|
-
}
|
|
242
|
-
}, _callee2, this);
|
|
243
|
-
}))).apply(this, arguments);
|
|
244
|
-
}
|
|
114
|
+
*/
|
|
115
|
+
async setValue(key, value) {
|
|
116
|
+
const thisobj = this.obj;
|
|
117
|
+
if (thisobj == null || typeof thisobj.setValue != "function") {
|
|
118
|
+
if (!this.__object_nullable)
|
|
119
|
+
console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return (await thisobj.setValue(key, value)) || false;
|
|
123
|
+
}
|
|
245
124
|
/**
|
|
246
125
|
* set key of subObject
|
|
247
126
|
* @param key
|
|
248
127
|
* @param value
|
|
249
128
|
* @param subvalue
|
|
250
129
|
* @return true if changed , false otherwise
|
|
251
|
-
*/
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
var _yield$this$obj$pushV, _this$obj10;
|
|
294
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
295
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
296
|
-
case 0:
|
|
297
|
-
_context4.next = 2;
|
|
298
|
-
return (_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.pushValue(key, value);
|
|
299
|
-
case 2:
|
|
300
|
-
_context4.t1 = _yield$this$obj$pushV = _context4.sent;
|
|
301
|
-
_context4.t0 = _context4.t1 !== null;
|
|
302
|
-
if (!_context4.t0) {
|
|
303
|
-
_context4.next = 6;
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
_context4.t0 = _yield$this$obj$pushV !== void 0;
|
|
307
|
-
case 6:
|
|
308
|
-
if (!_context4.t0) {
|
|
309
|
-
_context4.next = 10;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
_context4.t2 = _yield$this$obj$pushV;
|
|
313
|
-
_context4.next = 11;
|
|
314
|
-
break;
|
|
315
|
-
case 10:
|
|
316
|
-
_context4.t2 = false;
|
|
317
|
-
case 11:
|
|
318
|
-
return _context4.abrupt("return", _context4.t2);
|
|
319
|
-
case 12:
|
|
320
|
-
case "end":
|
|
321
|
-
return _context4.stop();
|
|
322
|
-
}
|
|
323
|
-
}, _callee4, this);
|
|
324
|
-
}))).apply(this, arguments);
|
|
325
|
-
} //set temp value of object
|
|
326
|
-
}, {
|
|
327
|
-
key: "setTemp",
|
|
328
|
-
value: function setTemp(_x12, _x13) {
|
|
329
|
-
return (_setTemp = _setTemp || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
|
|
330
|
-
var sendChanges,
|
|
331
|
-
_args5 = arguments;
|
|
332
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
333
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
334
|
-
case 0:
|
|
335
|
-
sendChanges = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : false;
|
|
336
|
-
_context5.next = 3;
|
|
337
|
-
return this.setObjectTemp(key, value, sendChanges);
|
|
338
|
-
case 3:
|
|
339
|
-
_context5.next = 5;
|
|
340
|
-
return _get(_getPrototypeOf(ObjectManager.prototype), "setTemp", this).call(this, key, value);
|
|
341
|
-
case 5:
|
|
342
|
-
return _context5.abrupt("return", _context5.sent);
|
|
343
|
-
case 6:
|
|
344
|
-
case "end":
|
|
345
|
-
return _context5.stop();
|
|
346
|
-
}
|
|
347
|
-
}, _callee5, this);
|
|
348
|
-
}))).apply(this, arguments);
|
|
349
|
-
} //set temp value of object
|
|
350
|
-
}, {
|
|
351
|
-
key: "setObjectTemp",
|
|
352
|
-
value: function setObjectTemp(_x14, _x15) {
|
|
353
|
-
return (_setObjectTemp = _setObjectTemp || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key, value) {
|
|
354
|
-
var _yield$this$obj$setTe, _this$obj11;
|
|
355
|
-
var sendChanges,
|
|
356
|
-
_args6 = arguments;
|
|
357
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
358
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
359
|
-
case 0:
|
|
360
|
-
sendChanges = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : false;
|
|
361
|
-
_context6.next = 3;
|
|
362
|
-
return (_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.setTemp(key, value, sendChanges);
|
|
363
|
-
case 3:
|
|
364
|
-
_context6.t1 = _yield$this$obj$setTe = _context6.sent;
|
|
365
|
-
_context6.t0 = _context6.t1 !== null;
|
|
366
|
-
if (!_context6.t0) {
|
|
367
|
-
_context6.next = 7;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
_context6.t0 = _yield$this$obj$setTe !== void 0;
|
|
371
|
-
case 7:
|
|
372
|
-
if (!_context6.t0) {
|
|
373
|
-
_context6.next = 11;
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
_context6.t2 = _yield$this$obj$setTe;
|
|
377
|
-
_context6.next = 12;
|
|
378
|
-
break;
|
|
379
|
-
case 11:
|
|
380
|
-
_context6.t2 = false;
|
|
381
|
-
case 12:
|
|
382
|
-
return _context6.abrupt("return", _context6.t2);
|
|
383
|
-
case 13:
|
|
384
|
-
case "end":
|
|
385
|
-
return _context6.stop();
|
|
386
|
-
}
|
|
387
|
-
}, _callee6, this);
|
|
388
|
-
}))).apply(this, arguments);
|
|
389
|
-
} //get temp value of object
|
|
390
|
-
}, {
|
|
391
|
-
key: "getObjectTemp",
|
|
392
|
-
value: function getObjectTemp(key) {
|
|
393
|
-
var _this$obj$getTemp, _this$obj12;
|
|
394
|
-
return (_this$obj$getTemp = (_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.getTemp(key)) !== null && _this$obj$getTemp !== void 0 ? _this$obj$getTemp : undefined;
|
|
395
|
-
}
|
|
396
|
-
/* -------------------------------------------------------------------------- */
|
|
397
|
-
}, {
|
|
398
|
-
key: "getIndexOrID",
|
|
399
|
-
value: function getIndexOrID() {
|
|
400
|
-
var _this$obj13;
|
|
401
|
-
return ((_this$obj13 = this.obj) === null || _this$obj13 === void 0 ? void 0 : _this$obj13.getIndexOrID()) || -1;
|
|
402
|
-
}
|
|
403
|
-
}, {
|
|
404
|
-
key: "getIndex",
|
|
405
|
-
value: function getIndex() {
|
|
406
|
-
var _this$obj14;
|
|
407
|
-
return ((_this$obj14 = this.obj) === null || _this$obj14 === void 0 ? void 0 : _this$obj14.getIndex()) || -1;
|
|
408
|
-
}
|
|
409
|
-
}, {
|
|
410
|
-
key: "getID",
|
|
411
|
-
value: function getID() {
|
|
412
|
-
var _this$obj15;
|
|
413
|
-
return ((_this$obj15 = this.obj) === null || _this$obj15 === void 0 ? void 0 : _this$obj15.getID()) || "";
|
|
414
|
-
}
|
|
415
|
-
/* -------------------------------------------------------------------------- */
|
|
416
|
-
/* Events */
|
|
417
|
-
/* -------------------------------------------------------------------------- */
|
|
418
|
-
}, {
|
|
419
|
-
key: "event_run",
|
|
420
|
-
value: function event_run(_x16) {
|
|
421
|
-
return (_event_run = _event_run || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
|
|
422
|
-
var _len2,
|
|
423
|
-
params,
|
|
424
|
-
_key2,
|
|
425
|
-
_args7 = arguments;
|
|
426
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
427
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
428
|
-
case 0:
|
|
429
|
-
if (!(this.__stopEvents === true)) {
|
|
430
|
-
_context7.next = 2;
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
return _context7.abrupt("return");
|
|
434
|
-
case 2:
|
|
435
|
-
for (_len2 = _args7.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
436
|
-
params[_key2 - 1] = _args7[_key2];
|
|
437
|
-
}
|
|
438
|
-
_context7.next = 5;
|
|
439
|
-
return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
|
|
440
|
-
case 5:
|
|
441
|
-
return _context7.abrupt("return", _context7.sent);
|
|
442
|
-
case 6:
|
|
443
|
-
case "end":
|
|
444
|
-
return _context7.stop();
|
|
445
|
-
}
|
|
446
|
-
}, _callee7, this);
|
|
447
|
-
}))).apply(this, arguments);
|
|
448
|
-
}
|
|
449
|
-
}, {
|
|
450
|
-
key: "event_use",
|
|
451
|
-
value: function event_use(name, runEvent) {
|
|
452
|
-
var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
453
|
-
var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
454
|
-
return _event.EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
455
|
-
}
|
|
130
|
+
*/
|
|
131
|
+
async setSubValue(key, objKey, subvalue) {
|
|
132
|
+
return ((await this.obj?.setSubValue(key, objKey, subvalue)) ?? false);
|
|
133
|
+
}
|
|
134
|
+
//Push value on array
|
|
135
|
+
async pushValue(key, value) {
|
|
136
|
+
return (await this.obj?.pushValue(key, value)) ?? false;
|
|
137
|
+
}
|
|
138
|
+
//set temp value of object
|
|
139
|
+
async setTemp(key, value, sendChanges = false) {
|
|
140
|
+
await this.setObjectTemp(key, value, sendChanges);
|
|
141
|
+
return await super.setTemp(key, value);
|
|
142
|
+
}
|
|
143
|
+
//set temp value of object
|
|
144
|
+
async setObjectTemp(key, value, sendChanges = false) {
|
|
145
|
+
return (await this.obj?.setTemp(key, value, sendChanges)) ?? false;
|
|
146
|
+
}
|
|
147
|
+
//get temp value of object
|
|
148
|
+
getObjectTemp(key) {
|
|
149
|
+
return this.obj?.getTemp(key) ?? undefined;
|
|
150
|
+
}
|
|
151
|
+
/* -------------------------------------------------------------------------- */
|
|
152
|
+
getIndexOrID() {
|
|
153
|
+
return this.obj?.getIndexOrID() || -1;
|
|
154
|
+
}
|
|
155
|
+
getIndex() {
|
|
156
|
+
return this.obj?.getIndex() || -1;
|
|
157
|
+
}
|
|
158
|
+
getID() {
|
|
159
|
+
return this.obj?.getID() || "";
|
|
160
|
+
}
|
|
161
|
+
/* -------------------------------------------------------------------------- */
|
|
162
|
+
/* Events */
|
|
163
|
+
/* -------------------------------------------------------------------------- */
|
|
164
|
+
async event_run(eventName, ...params) {
|
|
165
|
+
if (this.__stopEvents === true)
|
|
166
|
+
return;
|
|
167
|
+
return await EventManager.run(this, eventName, ...params);
|
|
168
|
+
}
|
|
169
|
+
event_use(name, runEvent, onlyOn = null, runOnce = false) {
|
|
170
|
+
return EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
171
|
+
}
|
|
456
172
|
/**
|
|
457
173
|
* only useful for getter functions that dont rely on states
|
|
458
174
|
* @param name
|
|
459
175
|
* @param runEvent
|
|
460
176
|
* @param onlyOn
|
|
461
177
|
* @returns
|
|
462
|
-
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}))).apply(this, arguments);
|
|
494
|
-
}
|
|
495
|
-
}, {
|
|
496
|
-
key: "events_start",
|
|
497
|
-
value: function events_start() {
|
|
498
|
-
delete this.__stopEvents;
|
|
499
|
-
}
|
|
500
|
-
}, {
|
|
501
|
-
key: "events_stop",
|
|
502
|
-
value: function events_stop() {
|
|
503
|
-
this.__stopEvents = true;
|
|
504
|
-
}
|
|
505
|
-
}, {
|
|
506
|
-
key: "events_clear",
|
|
507
|
-
value: function events_clear() {
|
|
508
|
-
ObjectManager.events_clear(this);
|
|
509
|
-
}
|
|
510
|
-
}, {
|
|
511
|
-
key: "clear_changes",
|
|
512
|
-
value: function clear_changes() {
|
|
513
|
-
var _this$obj16;
|
|
514
|
-
return (_this$obj16 = this.obj) === null || _this$obj16 === void 0 ? void 0 : _this$obj16.clear_changes();
|
|
515
|
-
}
|
|
516
|
-
}, {
|
|
517
|
-
key: "clear_cache",
|
|
518
|
-
value: function clear_cache() {
|
|
519
|
-
var _this$obj17;
|
|
520
|
-
return (_this$obj17 = this.obj) === null || _this$obj17 === void 0 ? void 0 : _this$obj17.clear_cache();
|
|
521
|
-
}
|
|
522
|
-
}, {
|
|
523
|
-
key: "toggleOption",
|
|
524
|
-
value:
|
|
525
|
-
/* -------------------------------------------------------------------------- */
|
|
526
|
-
/* Options */
|
|
527
|
-
/* -------------------------------------------------------------------------- */
|
|
178
|
+
*/
|
|
179
|
+
event_use_getter(name, runEvent, onlyOn = null) {
|
|
180
|
+
return EventManager.use_getter(this, name, runEvent, onlyOn);
|
|
181
|
+
}
|
|
182
|
+
event_remove(name, uname) {
|
|
183
|
+
return EventManager.remove(this, name, uname);
|
|
184
|
+
}
|
|
185
|
+
async event_add(name, uname, runEvent, onlyOn = null, runOnce = false) {
|
|
186
|
+
await EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
187
|
+
}
|
|
188
|
+
events_start() {
|
|
189
|
+
delete this.__stopEvents;
|
|
190
|
+
}
|
|
191
|
+
events_stop() {
|
|
192
|
+
this.__stopEvents = true;
|
|
193
|
+
}
|
|
194
|
+
events_clear() {
|
|
195
|
+
ObjectManager.events_clear(this);
|
|
196
|
+
}
|
|
197
|
+
clear_changes() {
|
|
198
|
+
return this.obj?.clear_changes();
|
|
199
|
+
}
|
|
200
|
+
clear_cache() {
|
|
201
|
+
return this.obj?.clear_cache();
|
|
202
|
+
}
|
|
203
|
+
static events_clear(obj) {
|
|
204
|
+
EventManager.removeAll(obj);
|
|
205
|
+
}
|
|
206
|
+
/* -------------------------------------------------------------------------- */
|
|
207
|
+
/* Options */
|
|
208
|
+
/* -------------------------------------------------------------------------- */
|
|
528
209
|
/**
|
|
529
210
|
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
530
211
|
* @param key
|
|
531
212
|
* @param value
|
|
532
213
|
* @returns
|
|
533
|
-
*/
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
case 8:
|
|
554
|
-
case "end":
|
|
555
|
-
return _context9.stop();
|
|
556
|
-
}
|
|
557
|
-
}, _callee9, this);
|
|
558
|
-
}))).apply(this, arguments);
|
|
559
|
-
}
|
|
560
|
-
}, {
|
|
561
|
-
key: "setOption",
|
|
562
|
-
value: function setOption(_x22, _x23) {
|
|
563
|
-
return (_setOption = _setOption || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
|
|
564
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
565
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
566
|
-
case 0:
|
|
567
|
-
if (this.__options == null) this.__options = {};
|
|
568
|
-
if (value == null) {
|
|
569
|
-
delete this.__options[key];
|
|
570
|
-
} else {
|
|
571
|
-
this.__options[key] = value;
|
|
572
|
-
}
|
|
573
|
-
_context10.next = 4;
|
|
574
|
-
return this.event_run("on_option_change", key, value);
|
|
575
|
-
case 4:
|
|
576
|
-
return _context10.abrupt("return", _context10.sent);
|
|
577
|
-
case 5:
|
|
578
|
-
case "end":
|
|
579
|
-
return _context10.stop();
|
|
580
|
-
}
|
|
581
|
-
}, _callee10, this);
|
|
582
|
-
}))).apply(this, arguments);
|
|
583
|
-
}
|
|
214
|
+
*/
|
|
215
|
+
async toggleOption(key, value) {
|
|
216
|
+
var oldval = this.getOption(key);
|
|
217
|
+
if (object_equals_loose(oldval, value)) {
|
|
218
|
+
await this.setOption(key, null);
|
|
219
|
+
}
|
|
220
|
+
else
|
|
221
|
+
await this.setOption(key, value);
|
|
222
|
+
}
|
|
223
|
+
async setOption(key, value) {
|
|
224
|
+
if (this.__options == null)
|
|
225
|
+
this.__options = {};
|
|
226
|
+
if (value == null) {
|
|
227
|
+
delete this.__options[key];
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this.__options[key] = value;
|
|
231
|
+
}
|
|
232
|
+
return await this.event_run("on_option_change", key, value);
|
|
233
|
+
}
|
|
584
234
|
/**
|
|
585
235
|
* use an option and detect its changes in real time. similar to recat state
|
|
586
236
|
* @param key name of the option
|
|
587
237
|
* @returns value of the option
|
|
588
|
-
*/
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
var _this2 = this;
|
|
593
|
-
return this.event_use_getter("on_option_change", function () {
|
|
594
|
-
return _this2.getOption(key);
|
|
595
|
-
}, [key]);
|
|
596
|
-
}
|
|
238
|
+
*/
|
|
239
|
+
useOption(key) {
|
|
240
|
+
return this.event_use_getter("on_option_change", () => this.getOption(key), [key]);
|
|
241
|
+
}
|
|
597
242
|
/**
|
|
598
243
|
* Sets an option then does an action,
|
|
599
244
|
* after the action is run, updates the option again
|
|
@@ -601,93 +246,52 @@ var ObjectManager = /*#__PURE__*/function (_RawObject, _notifyChanged, _setValue
|
|
|
601
246
|
* @param value
|
|
602
247
|
* @param nextvalue
|
|
603
248
|
* @param action
|
|
604
|
-
*/
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
value: function clearErrors() {
|
|
654
|
-
return ObjectManager.clearErrors(this);
|
|
655
|
-
}
|
|
656
|
-
}], [{
|
|
657
|
-
key: "events_clear",
|
|
658
|
-
value: function events_clear(obj) {
|
|
659
|
-
_event.EventManager.removeAll(obj);
|
|
660
|
-
}
|
|
661
|
-
}, {
|
|
662
|
-
key: "addError",
|
|
663
|
-
value: function addError(o, title, message) {
|
|
664
|
-
var sendToRegister = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
|
|
665
|
-
if (o && o.obj) {
|
|
666
|
-
return _SimpleObject["default"].addError(o.obj, title, message, sendToRegister);
|
|
667
|
-
}
|
|
668
|
-
var errStr = (0, _string.combine_if_not_blank)(title, " : ", message);
|
|
669
|
-
console.error("[REGISTER-ERROR]", errStr);
|
|
670
|
-
_global.gfunc.run_action("add_error", {
|
|
671
|
-
title: title,
|
|
672
|
-
message: message,
|
|
673
|
-
type: "error"
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
}, {
|
|
677
|
-
key: "getErrors",
|
|
678
|
-
value: function getErrors(o) {
|
|
679
|
-
var obj = o.obj;
|
|
680
|
-
return obj != null ? _SimpleObject["default"].getErrors(o.obj) : [];
|
|
681
|
-
}
|
|
682
|
-
}, {
|
|
683
|
-
key: "clearErrors",
|
|
684
|
-
value: function clearErrors(o) {
|
|
685
|
-
return _SimpleObject["default"].clearErrors(o.obj);
|
|
686
|
-
}
|
|
687
|
-
}]);
|
|
688
|
-
return ObjectManager;
|
|
689
|
-
}(_MapableObject["default"]);
|
|
690
|
-
exports.ObjectManager = ObjectManager;
|
|
691
|
-
_defineProperty(ObjectManager, "__object_type", void 0);
|
|
692
|
-
var _default = ObjectManager;
|
|
693
|
-
exports["default"] = _default;
|
|
249
|
+
*/
|
|
250
|
+
async holdOption(key, value, nextvalue, action) {
|
|
251
|
+
try {
|
|
252
|
+
this.setOption(key, value);
|
|
253
|
+
if (typeof action === "function")
|
|
254
|
+
await action();
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
this.setOption(key, nextvalue);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
getOption(key) {
|
|
261
|
+
if (this.__options == null)
|
|
262
|
+
return undefined;
|
|
263
|
+
return this.__options[key];
|
|
264
|
+
}
|
|
265
|
+
/* -------------------------------------------------------------------------- */
|
|
266
|
+
/* Errors */
|
|
267
|
+
/* -------------------------------------------------------------------------- */
|
|
268
|
+
addError(title, message, sendToRegister = "auto") {
|
|
269
|
+
return ObjectManager.addError(this, title, message, sendToRegister);
|
|
270
|
+
}
|
|
271
|
+
getErrors() {
|
|
272
|
+
return ObjectManager.getErrors(this);
|
|
273
|
+
}
|
|
274
|
+
clearErrors() {
|
|
275
|
+
return ObjectManager.clearErrors(this);
|
|
276
|
+
}
|
|
277
|
+
static addError(o, title, message, sendToRegister = "auto") {
|
|
278
|
+
if (o && o.obj) {
|
|
279
|
+
return SimpleObject.addError(o.obj, title, message, sendToRegister);
|
|
280
|
+
}
|
|
281
|
+
const errStr = combine_if_not_blank(title, " : ", message);
|
|
282
|
+
console.error("[REGISTER-ERROR]", errStr);
|
|
283
|
+
gfunc.run_action("add_error", {
|
|
284
|
+
title: title,
|
|
285
|
+
message: message,
|
|
286
|
+
type: "error",
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
static getErrors(o) {
|
|
290
|
+
const obj = o.obj;
|
|
291
|
+
return obj != null ? SimpleObject.getErrors(o.obj) : [];
|
|
292
|
+
}
|
|
293
|
+
static clearErrors(o) {
|
|
294
|
+
return SimpleObject.clearErrors(o.obj);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
export default ObjectManager;
|