@azrico/webobject 1.2.16 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -18
- package/dist/src/WebObjects/ParentWebObject.js +13 -94
- package/dist/src/WebObjects/WebObject.js +220 -740
- package/dist/src/WebObjects/WebObjectManager.js +74 -351
- package/dist/src/index.js +8 -109
- package/dist/src/structs/DummyObject.js +8 -54
- package/dist/src/structs/MapableObject.js +72 -141
- package/dist/src/structs/MetaObject.js +35 -171
- package/dist/src/structs/ObjectArray.js +43 -84
- package/dist/src/structs/ObjectManager.d.ts +1 -0
- package/dist/src/structs/ObjectManager.js +202 -652
- package/dist/src/structs/SimpleObject.d.ts +2 -0
- package/dist/src/structs/SimpleObject.js +580 -989
- package/package.json +1 -1
|
@@ -1,570 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.ObjectManager = void 0;
|
|
9
|
-
|
|
10
|
-
var _event = require("@azrico/event");
|
|
11
|
-
|
|
12
|
-
var _SimpleObject = _interopRequireDefault(require("./SimpleObject"));
|
|
13
|
-
|
|
14
|
-
var _string = require("@azrico/string");
|
|
15
|
-
|
|
16
|
-
var _global = require("@azrico/global");
|
|
17
|
-
|
|
18
|
-
var _object = require("@azrico/object");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
|
-
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
23
|
-
|
|
24
|
-
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); } }
|
|
25
|
-
|
|
26
|
-
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); }); }; }
|
|
27
|
-
|
|
28
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
-
|
|
30
|
-
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, descriptor.key, descriptor); } }
|
|
31
|
-
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
|
-
|
|
34
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
-
|
|
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";
|
|
36
6
|
/**
|
|
37
7
|
* This class manages the events of an Simple Object
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
value: function () {
|
|
59
|
-
var _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) {
|
|
63
|
-
switch (_context.prev = _context.next) {
|
|
64
|
-
case 0:
|
|
65
|
-
obj = this.getObject();
|
|
66
|
-
|
|
67
|
-
if (obj) {
|
|
68
|
-
_context.next = 3;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return _context.abrupt("return", false);
|
|
73
|
-
|
|
74
|
-
case 3:
|
|
75
|
-
if (value === undefined && type != "meta") value = obj.getValue(key);
|
|
76
|
-
typestr = (type ? "$".concat(type, "$") : "") + String(key);
|
|
77
|
-
_context.next = 7;
|
|
78
|
-
return this.event_run("on_change", typestr, value);
|
|
79
|
-
|
|
80
|
-
case 7:
|
|
81
|
-
return _context.abrupt("return", _context.sent);
|
|
82
|
-
|
|
83
|
-
case 8:
|
|
84
|
-
case "end":
|
|
85
|
-
return _context.stop();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, _callee, this);
|
|
89
|
-
}));
|
|
90
|
-
|
|
91
|
-
function notifyChanged(_x, _x2, _x3, _x4) {
|
|
92
|
-
return _notifyChanged.apply(this, arguments);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return notifyChanged;
|
|
96
|
-
}()
|
|
97
|
-
/* -------------------------------------------------------------------------- */
|
|
98
|
-
|
|
99
|
-
}, {
|
|
100
|
-
key: "obj",
|
|
101
|
-
get: function get() {
|
|
102
|
-
return this.getObject();
|
|
103
|
-
}
|
|
8
|
+
*/
|
|
9
|
+
export class ObjectManager {
|
|
10
|
+
__eventList;
|
|
11
|
+
__eventPrefix;
|
|
12
|
+
__sendEvents = true;
|
|
13
|
+
__currentObject;
|
|
14
|
+
__options;
|
|
15
|
+
async notifyChanged(type, key, value, subvalue) {
|
|
16
|
+
const obj = this.getObject();
|
|
17
|
+
if (!obj)
|
|
18
|
+
return false;
|
|
19
|
+
if (value === undefined && type != "meta")
|
|
20
|
+
value = obj.getValue(key);
|
|
21
|
+
const typestr = (type ? `$${type}$` : "") + String(key);
|
|
22
|
+
return await this.event_run("on_change", typestr, value);
|
|
23
|
+
}
|
|
24
|
+
/* -------------------------------------------------------------------------- */
|
|
25
|
+
get obj() {
|
|
26
|
+
return this.getObject();
|
|
27
|
+
}
|
|
104
28
|
/**
|
|
105
29
|
* Get the object this manager is managing
|
|
106
30
|
* @returns the object
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
value: function getObject() {
|
|
112
|
-
var _this$__currentObject;
|
|
113
|
-
|
|
114
|
-
return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
|
|
115
|
-
}
|
|
31
|
+
*/
|
|
32
|
+
getObject() {
|
|
33
|
+
return this.__currentObject ?? undefined;
|
|
34
|
+
}
|
|
116
35
|
/**
|
|
117
36
|
* Set the object this manager is managing
|
|
118
37
|
* @param toObj
|
|
119
38
|
* @returns
|
|
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
|
-
|
|
145
|
-
get
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
get
|
|
170
|
-
return this.obj == null || this.obj.isNew;
|
|
171
|
-
}
|
|
172
|
-
}, {
|
|
173
|
-
key: "isSaved",
|
|
174
|
-
get: function get() {
|
|
175
|
-
var _this$obj3;
|
|
176
|
-
|
|
177
|
-
return ((_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.isSaved) || false;
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
key: "__cache_name",
|
|
181
|
-
get: function get() {
|
|
182
|
-
return this.constructor["__cache_name"];
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "getSaveResult",
|
|
186
|
-
value: function getSaveResult() {
|
|
187
|
-
var _this$getObject;
|
|
188
|
-
|
|
189
|
-
return ((_this$getObject = this.getObject()) === null || _this$getObject === void 0 ? void 0 : _this$getObject.getSaveResult()) || undefined;
|
|
190
|
-
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "getSaveResultType",
|
|
193
|
-
value: function getSaveResultType() {
|
|
194
|
-
var _this$getObject2;
|
|
195
|
-
|
|
196
|
-
return ((_this$getObject2 = this.getObject()) === null || _this$getObject2 === void 0 ? void 0 : _this$getObject2.getSaveResultType()) || null;
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "setSaveResult",
|
|
200
|
-
value: function setSaveResult(toObj, type) {
|
|
201
|
-
return this.setSaveResult(toObj, type);
|
|
202
|
-
}
|
|
203
|
-
}, {
|
|
204
|
-
key: "apply_changes",
|
|
205
|
-
value: function apply_changes() {
|
|
206
|
-
var _this$obj4;
|
|
207
|
-
|
|
208
|
-
return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.apply_changes();
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
key: "getValue",
|
|
212
|
-
value: function getValue(key) {
|
|
213
|
-
var _this$obj5;
|
|
214
|
-
|
|
215
|
-
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
216
|
-
return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.getValue(key, original);
|
|
217
|
-
}
|
|
218
|
-
}, {
|
|
219
|
-
key: "setValue",
|
|
220
|
-
value:
|
|
39
|
+
*/
|
|
40
|
+
setObject(toObj) {
|
|
41
|
+
this.__currentObject = toObj;
|
|
42
|
+
if (this.__currentObject) {
|
|
43
|
+
this.__currentObject.get_managerClass = (() => {
|
|
44
|
+
return this;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/* -------------------------------------------------------------------------- */
|
|
50
|
+
/* Child functions */
|
|
51
|
+
/* -------------------------------------------------------------------------- */
|
|
52
|
+
get isChanged() {
|
|
53
|
+
return this.obj != null && this.obj.isChanged;
|
|
54
|
+
}
|
|
55
|
+
get isDeleted() {
|
|
56
|
+
return this.obj == null || this.obj.isDeleted;
|
|
57
|
+
}
|
|
58
|
+
get d() {
|
|
59
|
+
return this.obj?.d;
|
|
60
|
+
}
|
|
61
|
+
get canModify() {
|
|
62
|
+
return !this.obj?.canModify;
|
|
63
|
+
}
|
|
64
|
+
get isNew() {
|
|
65
|
+
return this.obj == null || this.obj.isNew;
|
|
66
|
+
}
|
|
67
|
+
get isSaved() {
|
|
68
|
+
return this.obj?.isSaved || false;
|
|
69
|
+
}
|
|
70
|
+
get __cache_name() {
|
|
71
|
+
return this.constructor["__cache_name"];
|
|
72
|
+
}
|
|
73
|
+
getSaveResult() {
|
|
74
|
+
return this.getObject()?.getSaveResult() || undefined;
|
|
75
|
+
}
|
|
76
|
+
getSaveResultType() {
|
|
77
|
+
return this.getObject()?.getSaveResultType() || null;
|
|
78
|
+
}
|
|
79
|
+
setSaveResult(toObj, type) {
|
|
80
|
+
return this.setSaveResult(toObj, type);
|
|
81
|
+
}
|
|
82
|
+
apply_changes() {
|
|
83
|
+
return this.obj?.apply_changes();
|
|
84
|
+
}
|
|
85
|
+
getValue(key, original = false) {
|
|
86
|
+
return this.obj?.getValue(key, original);
|
|
87
|
+
}
|
|
88
|
+
get = this.getValue;
|
|
221
89
|
/**
|
|
222
90
|
* set value
|
|
223
91
|
* @param key
|
|
224
92
|
* @param value
|
|
225
93
|
* @return true if changed , false otherwise
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
232
|
-
while (1) {
|
|
233
|
-
switch (_context2.prev = _context2.next) {
|
|
234
|
-
case 0:
|
|
235
|
-
_context2.next = 2;
|
|
236
|
-
return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setValue(key, value);
|
|
237
|
-
|
|
238
|
-
case 2:
|
|
239
|
-
_context2.t0 = _context2.sent;
|
|
240
|
-
|
|
241
|
-
if (_context2.t0) {
|
|
242
|
-
_context2.next = 5;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
_context2.t0 = false;
|
|
247
|
-
|
|
248
|
-
case 5:
|
|
249
|
-
return _context2.abrupt("return", _context2.t0);
|
|
250
|
-
|
|
251
|
-
case 6:
|
|
252
|
-
case "end":
|
|
253
|
-
return _context2.stop();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}, _callee2, this);
|
|
257
|
-
}));
|
|
258
|
-
|
|
259
|
-
function setValue(_x5, _x6) {
|
|
260
|
-
return _setValue.apply(this, arguments);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return setValue;
|
|
264
|
-
}()
|
|
94
|
+
*/
|
|
95
|
+
async setValue(key, value) {
|
|
96
|
+
return (await this.obj?.setValue(key, value)) || false;
|
|
97
|
+
}
|
|
265
98
|
/**
|
|
266
99
|
* set key of subObject
|
|
267
100
|
* @param key
|
|
268
101
|
* @param value
|
|
269
102
|
* @param subvalue
|
|
270
103
|
* @return true if changed , false otherwise
|
|
271
|
-
*/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
value
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
while (1) {
|
|
322
|
-
switch (_context4.prev = _context4.next) {
|
|
323
|
-
case 0:
|
|
324
|
-
_context4.next = 2;
|
|
325
|
-
return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.pushValue(key, value);
|
|
326
|
-
|
|
327
|
-
case 2:
|
|
328
|
-
_context4.t0 = _context4.sent;
|
|
329
|
-
|
|
330
|
-
if (_context4.t0) {
|
|
331
|
-
_context4.next = 5;
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
_context4.t0 = false;
|
|
336
|
-
|
|
337
|
-
case 5:
|
|
338
|
-
return _context4.abrupt("return", _context4.t0);
|
|
339
|
-
|
|
340
|
-
case 6:
|
|
341
|
-
case "end":
|
|
342
|
-
return _context4.stop();
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}, _callee4, this);
|
|
346
|
-
}));
|
|
347
|
-
|
|
348
|
-
function pushValue(_x10, _x11) {
|
|
349
|
-
return _pushValue.apply(this, arguments);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return pushValue;
|
|
353
|
-
}()
|
|
354
|
-
/* -------------------------------------------------------------------------- */
|
|
355
|
-
|
|
356
|
-
}, {
|
|
357
|
-
key: "getIndexOrID",
|
|
358
|
-
value: function getIndexOrID() {
|
|
359
|
-
var _this$obj9;
|
|
360
|
-
|
|
361
|
-
return ((_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.getIndexOrID()) || -1;
|
|
362
|
-
}
|
|
363
|
-
}, {
|
|
364
|
-
key: "getIndex",
|
|
365
|
-
value: function getIndex() {
|
|
366
|
-
var _this$obj10;
|
|
367
|
-
|
|
368
|
-
return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getIndex()) || -1;
|
|
369
|
-
}
|
|
370
|
-
}, {
|
|
371
|
-
key: "getID",
|
|
372
|
-
value: function getID() {
|
|
373
|
-
var _this$obj11;
|
|
374
|
-
|
|
375
|
-
return ((_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getID()) || "";
|
|
376
|
-
}
|
|
377
|
-
/* -------------------------------------------------------------------------- */
|
|
378
|
-
|
|
379
|
-
/* Getters */
|
|
380
|
-
|
|
381
|
-
/* -------------------------------------------------------------------------- */
|
|
382
|
-
|
|
383
|
-
/* -------------------------------------------------------------------------- */
|
|
384
|
-
|
|
385
|
-
/* Events */
|
|
386
|
-
|
|
387
|
-
/* -------------------------------------------------------------------------- */
|
|
388
|
-
|
|
389
|
-
}, {
|
|
390
|
-
key: "event_run",
|
|
391
|
-
value: function () {
|
|
392
|
-
var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventName) {
|
|
393
|
-
var _len,
|
|
394
|
-
params,
|
|
395
|
-
_key,
|
|
396
|
-
_args5 = arguments;
|
|
397
|
-
|
|
398
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
399
|
-
while (1) {
|
|
400
|
-
switch (_context5.prev = _context5.next) {
|
|
401
|
-
case 0:
|
|
402
|
-
if (this.__sendEvents) {
|
|
403
|
-
_context5.next = 2;
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return _context5.abrupt("return");
|
|
408
|
-
|
|
409
|
-
case 2:
|
|
410
|
-
for (_len = _args5.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
411
|
-
params[_key - 1] = _args5[_key];
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
_context5.next = 5;
|
|
415
|
-
return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
|
|
416
|
-
|
|
417
|
-
case 5:
|
|
418
|
-
case "end":
|
|
419
|
-
return _context5.stop();
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}, _callee5, this);
|
|
423
|
-
}));
|
|
424
|
-
|
|
425
|
-
function event_run(_x12) {
|
|
426
|
-
return _event_run.apply(this, arguments);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
return event_run;
|
|
430
|
-
}()
|
|
431
|
-
}, {
|
|
432
|
-
key: "event_use",
|
|
433
|
-
value: function event_use(name, runEvent) {
|
|
434
|
-
var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
435
|
-
var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
436
|
-
return _event.EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
437
|
-
}
|
|
438
|
-
}, {
|
|
439
|
-
key: "event_add",
|
|
440
|
-
value: function () {
|
|
441
|
-
var _event_add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(name, uname, runEvent) {
|
|
442
|
-
var onlyOn,
|
|
443
|
-
runOnce,
|
|
444
|
-
_args6 = arguments;
|
|
445
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
446
|
-
while (1) {
|
|
447
|
-
switch (_context6.prev = _context6.next) {
|
|
448
|
-
case 0:
|
|
449
|
-
onlyOn = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : null;
|
|
450
|
-
runOnce = _args6.length > 4 && _args6[4] !== undefined ? _args6[4] : false;
|
|
451
|
-
_context6.next = 4;
|
|
452
|
-
return _event.EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
453
|
-
|
|
454
|
-
case 4:
|
|
455
|
-
case "end":
|
|
456
|
-
return _context6.stop();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}, _callee6, this);
|
|
460
|
-
}));
|
|
461
|
-
|
|
462
|
-
function event_add(_x13, _x14, _x15) {
|
|
463
|
-
return _event_add.apply(this, arguments);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return event_add;
|
|
467
|
-
}()
|
|
468
|
-
}, {
|
|
469
|
-
key: "events_stop",
|
|
470
|
-
value: function events_stop() {
|
|
471
|
-
this.__sendEvents = false;
|
|
472
|
-
}
|
|
473
|
-
}, {
|
|
474
|
-
key: "events_clear",
|
|
475
|
-
value: function events_clear() {
|
|
476
|
-
ObjectManager.events_clear(this);
|
|
477
|
-
}
|
|
478
|
-
}, {
|
|
479
|
-
key: "toggleOption",
|
|
480
|
-
value:
|
|
481
|
-
/* -------------------------------------------------------------------------- */
|
|
482
|
-
|
|
483
|
-
/* Options */
|
|
484
|
-
|
|
485
|
-
/* -------------------------------------------------------------------------- */
|
|
486
|
-
|
|
104
|
+
*/
|
|
105
|
+
async setSubValue(key, objKey, subvalue) {
|
|
106
|
+
return ((await this.obj?.setSubValue(key, objKey, subvalue)) || false);
|
|
107
|
+
}
|
|
108
|
+
//Push value on array
|
|
109
|
+
async pushValue(key, value) {
|
|
110
|
+
return (await this.obj?.pushValue(key, value)) || false;
|
|
111
|
+
}
|
|
112
|
+
/* -------------------------------------------------------------------------- */
|
|
113
|
+
getIndexOrID() {
|
|
114
|
+
return this.obj?.getIndexOrID() || -1;
|
|
115
|
+
}
|
|
116
|
+
getIndex() {
|
|
117
|
+
return this.obj?.getIndex() || -1;
|
|
118
|
+
}
|
|
119
|
+
getID() {
|
|
120
|
+
return this.obj?.getID() || "";
|
|
121
|
+
}
|
|
122
|
+
/* -------------------------------------------------------------------------- */
|
|
123
|
+
/* Getters */
|
|
124
|
+
/* -------------------------------------------------------------------------- */
|
|
125
|
+
/* -------------------------------------------------------------------------- */
|
|
126
|
+
/* Events */
|
|
127
|
+
/* -------------------------------------------------------------------------- */
|
|
128
|
+
async event_run(eventName, ...params) {
|
|
129
|
+
if (!this.__sendEvents)
|
|
130
|
+
return;
|
|
131
|
+
await EventManager.run(this, eventName, ...params);
|
|
132
|
+
}
|
|
133
|
+
event_use(name, runEvent, onlyOn = null, runOnce = false) {
|
|
134
|
+
return EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
135
|
+
}
|
|
136
|
+
event_remove(name, uname) {
|
|
137
|
+
return EventManager.remove(this, name, uname);
|
|
138
|
+
}
|
|
139
|
+
async event_add(name, uname, runEvent, onlyOn = null, runOnce = false) {
|
|
140
|
+
await EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
141
|
+
}
|
|
142
|
+
events_stop() {
|
|
143
|
+
this.__sendEvents = false;
|
|
144
|
+
}
|
|
145
|
+
events_clear() {
|
|
146
|
+
ObjectManager.events_clear(this);
|
|
147
|
+
}
|
|
148
|
+
static events_clear(obj) {
|
|
149
|
+
EventManager.removeAll(obj);
|
|
150
|
+
}
|
|
151
|
+
/* -------------------------------------------------------------------------- */
|
|
152
|
+
/* Options */
|
|
153
|
+
/* -------------------------------------------------------------------------- */
|
|
487
154
|
/**
|
|
488
155
|
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
489
156
|
* @param key
|
|
490
157
|
* @param value
|
|
491
158
|
* @returns
|
|
492
|
-
*/
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
break;
|
|
513
|
-
|
|
514
|
-
case 6:
|
|
515
|
-
_context7.next = 8;
|
|
516
|
-
return this.setOption(key, value);
|
|
517
|
-
|
|
518
|
-
case 8:
|
|
519
|
-
case "end":
|
|
520
|
-
return _context7.stop();
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}, _callee7, this);
|
|
524
|
-
}));
|
|
525
|
-
|
|
526
|
-
function toggleOption(_x16, _x17) {
|
|
527
|
-
return _toggleOption.apply(this, arguments);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return toggleOption;
|
|
531
|
-
}()
|
|
532
|
-
}, {
|
|
533
|
-
key: "setOption",
|
|
534
|
-
value: function () {
|
|
535
|
-
var _setOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(key, value) {
|
|
536
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
537
|
-
while (1) {
|
|
538
|
-
switch (_context8.prev = _context8.next) {
|
|
539
|
-
case 0:
|
|
540
|
-
if (this.__options == null) this.__options = {};
|
|
541
|
-
|
|
542
|
-
if (value == null) {
|
|
543
|
-
delete this.__options[key];
|
|
544
|
-
} else {
|
|
545
|
-
this.__options[key] = value;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
_context8.next = 4;
|
|
549
|
-
return this.event_run("on_option_change", key, value);
|
|
550
|
-
|
|
551
|
-
case 4:
|
|
552
|
-
return _context8.abrupt("return", _context8.sent);
|
|
553
|
-
|
|
554
|
-
case 5:
|
|
555
|
-
case "end":
|
|
556
|
-
return _context8.stop();
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}, _callee8, this);
|
|
560
|
-
}));
|
|
561
|
-
|
|
562
|
-
function setOption(_x18, _x19) {
|
|
563
|
-
return _setOption.apply(this, arguments);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return setOption;
|
|
567
|
-
}()
|
|
159
|
+
*/
|
|
160
|
+
async toggleOption(key, value) {
|
|
161
|
+
var oldval = this.getOption(key);
|
|
162
|
+
if (object_equals_loose(oldval, value)) {
|
|
163
|
+
await this.setOption(key, null);
|
|
164
|
+
}
|
|
165
|
+
else
|
|
166
|
+
await this.setOption(key, value);
|
|
167
|
+
}
|
|
168
|
+
async setOption(key, value) {
|
|
169
|
+
if (this.__options == null)
|
|
170
|
+
this.__options = {};
|
|
171
|
+
if (value == null) {
|
|
172
|
+
delete this.__options[key];
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.__options[key] = value;
|
|
176
|
+
}
|
|
177
|
+
return await this.event_run("on_option_change", key, value);
|
|
178
|
+
}
|
|
568
179
|
/**
|
|
569
180
|
* Sets an option then does an action,
|
|
570
181
|
* after the action is run, updates the option again
|
|
@@ -572,113 +183,52 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
572
183
|
* @param value
|
|
573
184
|
* @param nextvalue
|
|
574
185
|
* @param action
|
|
575
|
-
*/
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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
|
-
key: "addError",
|
|
629
|
-
value: function addError(title, message) {
|
|
630
|
-
var sendToRegister = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "auto";
|
|
631
|
-
return ObjectManager.addError(this, title, message, sendToRegister);
|
|
632
|
-
}
|
|
633
|
-
}, {
|
|
634
|
-
key: "getErrors",
|
|
635
|
-
value: function getErrors() {
|
|
636
|
-
return ObjectManager.getErrors(this);
|
|
637
|
-
}
|
|
638
|
-
}, {
|
|
639
|
-
key: "clearErrors",
|
|
640
|
-
value: function clearErrors() {
|
|
641
|
-
return ObjectManager.clearErrors(this);
|
|
642
|
-
}
|
|
643
|
-
}], [{
|
|
644
|
-
key: "events_clear",
|
|
645
|
-
value: function events_clear(obj) {
|
|
646
|
-
_event.EventManager.removeAll(obj);
|
|
647
|
-
}
|
|
648
|
-
}, {
|
|
649
|
-
key: "addError",
|
|
650
|
-
value: function addError(o, title, message) {
|
|
651
|
-
var sendToRegister = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
|
|
652
|
-
|
|
653
|
-
if (o && o.obj) {
|
|
654
|
-
return _SimpleObject["default"].addError(o.obj, title, message, sendToRegister);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
var errStr = (0, _string.combine_if_not_blank)(title, " : ", message);
|
|
658
|
-
console.error("[REGISTER-ERROR]", errStr);
|
|
659
|
-
|
|
660
|
-
_global.gfunc.run_action("add_error", {
|
|
661
|
-
title: title,
|
|
662
|
-
message: message,
|
|
663
|
-
type: "error"
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
}, {
|
|
667
|
-
key: "getErrors",
|
|
668
|
-
value: function getErrors(o) {
|
|
669
|
-
var obj = o.obj;
|
|
670
|
-
return obj != null ? _SimpleObject["default"].getErrors(o.obj) : [];
|
|
671
|
-
}
|
|
672
|
-
}, {
|
|
673
|
-
key: "clearErrors",
|
|
674
|
-
value: function clearErrors(o) {
|
|
675
|
-
return _SimpleObject["default"].clearErrors(o.obj);
|
|
676
|
-
}
|
|
677
|
-
}]);
|
|
678
|
-
|
|
679
|
-
return ObjectManager;
|
|
680
|
-
}();
|
|
681
|
-
|
|
682
|
-
exports.ObjectManager = ObjectManager;
|
|
683
|
-
var _default = ObjectManager;
|
|
684
|
-
exports["default"] = _default;
|
|
186
|
+
*/
|
|
187
|
+
async holdOption(key, value, nextvalue, action) {
|
|
188
|
+
try {
|
|
189
|
+
this.setOption(key, value);
|
|
190
|
+
if (typeof action === "function")
|
|
191
|
+
await action();
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
this.setOption(key, nextvalue);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
getOption(key) {
|
|
198
|
+
if (this.__options == null)
|
|
199
|
+
return undefined;
|
|
200
|
+
return this.__options[key];
|
|
201
|
+
}
|
|
202
|
+
/* -------------------------------------------------------------------------- */
|
|
203
|
+
/* Errors */
|
|
204
|
+
/* -------------------------------------------------------------------------- */
|
|
205
|
+
addError(title, message, sendToRegister = "auto") {
|
|
206
|
+
return ObjectManager.addError(this, title, message, sendToRegister);
|
|
207
|
+
}
|
|
208
|
+
getErrors() {
|
|
209
|
+
return ObjectManager.getErrors(this);
|
|
210
|
+
}
|
|
211
|
+
clearErrors() {
|
|
212
|
+
return ObjectManager.clearErrors(this);
|
|
213
|
+
}
|
|
214
|
+
static addError(o, title, message, sendToRegister = "auto") {
|
|
215
|
+
if (o && o.obj) {
|
|
216
|
+
return SimpleObject.addError(o.obj, title, message, sendToRegister);
|
|
217
|
+
}
|
|
218
|
+
const errStr = combine_if_not_blank(title, " : ", message);
|
|
219
|
+
console.error("[REGISTER-ERROR]", errStr);
|
|
220
|
+
gfunc.run_action("add_error", {
|
|
221
|
+
title: title,
|
|
222
|
+
message: message,
|
|
223
|
+
type: "error",
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
static getErrors(o) {
|
|
227
|
+
const obj = o.obj;
|
|
228
|
+
return obj != null ? SimpleObject.getErrors(o.obj) : [];
|
|
229
|
+
}
|
|
230
|
+
static clearErrors(o) {
|
|
231
|
+
return SimpleObject.clearErrors(o.obj);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
export default ObjectManager;
|