@azrico/webobject 1.5.58 → 1.5.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/src/WebObjects/ParentWebObject.d.ts +24 -0
- package/dist/src/WebObjects/ParentWebObject.js +121 -0
- package/dist/src/WebObjects/WebObject.d.ts +153 -0
- package/dist/src/WebObjects/WebObject.js +1624 -0
- package/dist/src/WebObjects/WebObjectHelper.d.ts +9 -0
- package/dist/src/WebObjects/WebObjectHelper.js +38 -0
- package/dist/src/WebObjects/WebObjectHelper.test.d.ts +1 -0
- package/dist/src/WebObjects/WebObjectHelper.test.js +67 -0
- package/dist/src/WebObjects/WebObjectManager.d.ts +68 -0
- package/dist/src/WebObjects/WebObjectManager.js +889 -0
- package/dist/src/WebObjects/WebObjectPathHelper.d.ts +36 -0
- package/dist/src/WebObjects/WebObjectPathHelper.js +155 -0
- package/dist/src/WebObjects/WebObjectPathHelper.test.d.ts +1 -0
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +122 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +115 -0
- package/dist/src/structs/DummyObject.d.ts +5 -0
- package/dist/src/structs/DummyObject.js +32 -0
- package/dist/src/structs/MapableObject.d.ts +43 -0
- package/dist/src/structs/MapableObject.js +123 -0
- package/dist/src/structs/MetaObject.d.ts +15 -0
- package/dist/src/structs/MetaObject.js +121 -0
- package/dist/src/structs/ObjectArray.d.ts +10 -0
- package/dist/src/structs/ObjectArray.js +68 -0
- package/dist/src/structs/ObjectManager.d.ts +135 -0
- package/dist/src/structs/ObjectManager.js +790 -0
- package/dist/src/structs/ObjectWithTemp.d.ts +11 -0
- package/dist/src/structs/ObjectWithTemp.js +66 -0
- package/dist/src/structs/SimpleObject.d.ts +305 -0
- package/dist/src/structs/SimpleObject.js +1751 -0
- package/package.json +1 -1
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.ObjectManager = void 0;
|
|
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); }
|
|
34
|
+
/**
|
|
35
|
+
* This class manages the events of an Simple Object
|
|
36
|
+
*/
|
|
37
|
+
var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
|
|
38
|
+
function ObjectManager(defaultObject) {
|
|
39
|
+
var _this;
|
|
40
|
+
_classCallCheck(this, ObjectManager);
|
|
41
|
+
_this = _callSuper(this, ObjectManager);
|
|
42
|
+
_defineProperty(_this, "__eventList", {});
|
|
43
|
+
_defineProperty(_this, "__eventPrefix", void 0);
|
|
44
|
+
_defineProperty(_this, "__stopEvents", void 0);
|
|
45
|
+
_defineProperty(_this, "__last_object_data", {});
|
|
46
|
+
_defineProperty(_this, "__currentObject", void 0);
|
|
47
|
+
_defineProperty(_this, "__options", void 0);
|
|
48
|
+
//can the current object be set to null safely?
|
|
49
|
+
_defineProperty(_this, "__object_nullable", false);
|
|
50
|
+
_this.setObject(defaultObject);
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
_inherits(ObjectManager, _RawObject);
|
|
54
|
+
return _createClass(ObjectManager, [{
|
|
55
|
+
key: "notifyChanged",
|
|
56
|
+
value: function () {
|
|
57
|
+
var _notifyChanged = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(type, key, value, subvalue) {
|
|
58
|
+
var obj, typestr;
|
|
59
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
60
|
+
while (1) switch (_context.prev = _context.next) {
|
|
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
|
+
/* -------------------------------------------------------------------------- */
|
|
87
|
+
/**
|
|
88
|
+
* Get the object this manager is managing
|
|
89
|
+
* @returns the object
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "obj",
|
|
93
|
+
get: function get() {
|
|
94
|
+
var _this$__currentObject;
|
|
95
|
+
return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the object this manager is managing
|
|
99
|
+
* @returns the object
|
|
100
|
+
*/
|
|
101
|
+
}, {
|
|
102
|
+
key: "getObject",
|
|
103
|
+
value: function getObject() {
|
|
104
|
+
var _this$__currentObject2;
|
|
105
|
+
return (_this$__currentObject2 = this.__currentObject) !== null && _this$__currentObject2 !== void 0 ? _this$__currentObject2 : undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Set the object this manager is managing
|
|
109
|
+
* @param toObj
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
}, {
|
|
113
|
+
key: "setObject",
|
|
114
|
+
value: function setObject(toObj) {
|
|
115
|
+
var _this2 = this;
|
|
116
|
+
this.__currentObject = toObj;
|
|
117
|
+
if (this.obj) {
|
|
118
|
+
this.obj.get_managerClass = function () {
|
|
119
|
+
return _this2;
|
|
120
|
+
};
|
|
121
|
+
// this.obj.set_managerClass(this);
|
|
122
|
+
}
|
|
123
|
+
if (toObj == null && !this.__object_nullable) {
|
|
124
|
+
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
/* -------------------------------------------------------------------------- */
|
|
129
|
+
/* Child functions */
|
|
130
|
+
/* -------------------------------------------------------------------------- */
|
|
131
|
+
}, {
|
|
132
|
+
key: "d",
|
|
133
|
+
get: function get() {
|
|
134
|
+
var _this$obj;
|
|
135
|
+
return ((_this$obj = this.obj) === null || _this$obj === void 0 ? void 0 : _this$obj.d) || {};
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "isChanged",
|
|
139
|
+
get: function get() {
|
|
140
|
+
return this.obj != null && this.obj.isChanged;
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "isDeleted",
|
|
144
|
+
get: function get() {
|
|
145
|
+
return this.obj == null || this.obj.isDeleted;
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "isArchived",
|
|
149
|
+
get: function get() {
|
|
150
|
+
return this.obj == null || this.obj.isArchived;
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "isLocked",
|
|
154
|
+
get: function get() {
|
|
155
|
+
return this.obj == null || this.obj.isLocked;
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "canModify",
|
|
159
|
+
get: function get() {
|
|
160
|
+
var _this$obj2;
|
|
161
|
+
return !((_this$obj2 = this.obj) !== null && _this$obj2 !== void 0 && _this$obj2.canModify);
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "isNew",
|
|
165
|
+
get: function get() {
|
|
166
|
+
return this.obj == null || this.obj.isNew;
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "isSaved",
|
|
170
|
+
get: function get() {
|
|
171
|
+
var _this$obj3;
|
|
172
|
+
return ((_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.isSaved) || false;
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "getSaveResult",
|
|
176
|
+
value: function getSaveResult() {
|
|
177
|
+
var _this$obj4;
|
|
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
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* set value
|
|
211
|
+
* @param key
|
|
212
|
+
* @param value
|
|
213
|
+
* @return true if changed , false otherwise
|
|
214
|
+
*/
|
|
215
|
+
}, {
|
|
216
|
+
key: "set",
|
|
217
|
+
value: (function () {
|
|
218
|
+
var _set = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
219
|
+
var thisobj;
|
|
220
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
221
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
222
|
+
case 0:
|
|
223
|
+
thisobj = this.obj;
|
|
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
|
+
}()
|
|
253
|
+
/**
|
|
254
|
+
* set key of subObject
|
|
255
|
+
* @param key
|
|
256
|
+
* @param value
|
|
257
|
+
* @param subvalue
|
|
258
|
+
* @return true if changed , false otherwise
|
|
259
|
+
*/
|
|
260
|
+
)
|
|
261
|
+
}, {
|
|
262
|
+
key: "setSubValue",
|
|
263
|
+
value: (function () {
|
|
264
|
+
var _setSubValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
|
|
265
|
+
var _yield$this$obj$setSu, _this$obj8;
|
|
266
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
267
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
268
|
+
case 0:
|
|
269
|
+
_context3.next = 2;
|
|
270
|
+
return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.setSubValue(key, objKey, subvalue);
|
|
271
|
+
case 2:
|
|
272
|
+
_context3.t1 = _yield$this$obj$setSu = _context3.sent;
|
|
273
|
+
_context3.t0 = _context3.t1 !== null;
|
|
274
|
+
if (!_context3.t0) {
|
|
275
|
+
_context3.next = 6;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
_context3.t0 = _yield$this$obj$setSu !== void 0;
|
|
279
|
+
case 6:
|
|
280
|
+
if (!_context3.t0) {
|
|
281
|
+
_context3.next = 10;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
_context3.t2 = _yield$this$obj$setSu;
|
|
285
|
+
_context3.next = 11;
|
|
286
|
+
break;
|
|
287
|
+
case 10:
|
|
288
|
+
_context3.t2 = false;
|
|
289
|
+
case 11:
|
|
290
|
+
return _context3.abrupt("return", _context3.t2);
|
|
291
|
+
case 12:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context3.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee3, this);
|
|
296
|
+
}));
|
|
297
|
+
function setSubValue(_x7, _x8, _x9) {
|
|
298
|
+
return _setSubValue.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return setSubValue;
|
|
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
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* only useful for getter functions that dont rely on states
|
|
488
|
+
* @param name
|
|
489
|
+
* @param runEvent
|
|
490
|
+
* @param onlyOn
|
|
491
|
+
* @returns
|
|
492
|
+
*/
|
|
493
|
+
}, {
|
|
494
|
+
key: "event_use_getter",
|
|
495
|
+
value: function event_use_getter(name, runEvent) {
|
|
496
|
+
var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
497
|
+
return _event.EventManager.use_getter(this, name, runEvent, onlyOn);
|
|
498
|
+
}
|
|
499
|
+
}, {
|
|
500
|
+
key: "event_remove",
|
|
501
|
+
value: function event_remove(name, uname) {
|
|
502
|
+
return _event.EventManager.remove(this, name, uname);
|
|
503
|
+
}
|
|
504
|
+
}, {
|
|
505
|
+
key: "event_add",
|
|
506
|
+
value: function () {
|
|
507
|
+
var _event_add = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(name, uname, runEvent) {
|
|
508
|
+
var onlyOn,
|
|
509
|
+
runOnce,
|
|
510
|
+
_args8 = arguments;
|
|
511
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
512
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
513
|
+
case 0:
|
|
514
|
+
onlyOn = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : null;
|
|
515
|
+
runOnce = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : false;
|
|
516
|
+
_context8.next = 4;
|
|
517
|
+
return _event.EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
518
|
+
case 4:
|
|
519
|
+
case "end":
|
|
520
|
+
return _context8.stop();
|
|
521
|
+
}
|
|
522
|
+
}, _callee8, this);
|
|
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
|
+
/* -------------------------------------------------------------------------- */
|
|
562
|
+
/**
|
|
563
|
+
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
564
|
+
* @param key
|
|
565
|
+
* @param value
|
|
566
|
+
* @returns
|
|
567
|
+
*/
|
|
568
|
+
function () {
|
|
569
|
+
var _toggleOption = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key, value) {
|
|
570
|
+
var oldval;
|
|
571
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
572
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
573
|
+
case 0:
|
|
574
|
+
oldval = this.getOption(key);
|
|
575
|
+
if (!(0, _object.object_equals_loose)(oldval, value)) {
|
|
576
|
+
_context9.next = 6;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
_context9.next = 4;
|
|
580
|
+
return this.setOption(key, null);
|
|
581
|
+
case 4:
|
|
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
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* updates `__options` and runs the `event_run`
|
|
607
|
+
* @param key
|
|
608
|
+
* @param value
|
|
609
|
+
* @returns true if changed, false otherwise
|
|
610
|
+
*/
|
|
611
|
+
}, {
|
|
612
|
+
key: "setOption",
|
|
613
|
+
value: (function () {
|
|
614
|
+
var _setOption = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
|
|
615
|
+
var isChanged;
|
|
616
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
617
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
618
|
+
case 0:
|
|
619
|
+
if (this.__options == null) this.__options = {};
|
|
620
|
+
key = key.toLowerCase();
|
|
621
|
+
isChanged = this.__options[key] !== value;
|
|
622
|
+
if (value == null) {
|
|
623
|
+
delete this.__options[key];
|
|
624
|
+
} else {
|
|
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
|
+
}()
|
|
642
|
+
/**
|
|
643
|
+
* use an option and detect its changes in real time. similar to recat state
|
|
644
|
+
* @param key name of the option
|
|
645
|
+
* @returns value of the option
|
|
646
|
+
*/
|
|
647
|
+
)
|
|
648
|
+
}, {
|
|
649
|
+
key: "useOption",
|
|
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
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Sets an option then does an action,
|
|
658
|
+
* after the action is run, updates the option again
|
|
659
|
+
* @param key
|
|
660
|
+
* @param value
|
|
661
|
+
* @param nextvalue
|
|
662
|
+
* @param action
|
|
663
|
+
*/
|
|
664
|
+
}, {
|
|
665
|
+
key: "holdOption",
|
|
666
|
+
value: (function () {
|
|
667
|
+
var _holdOption = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(key, value, nextvalue, action) {
|
|
668
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
669
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
670
|
+
case 0:
|
|
671
|
+
_context11.prev = 0;
|
|
672
|
+
this.setOption(key, value);
|
|
673
|
+
if (!(typeof action === "function")) {
|
|
674
|
+
_context11.next = 5;
|
|
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; ----------------------------- */
|
|
715
|
+
/**
|
|
716
|
+
* @returns isChanged
|
|
717
|
+
*/
|
|
718
|
+
}, {
|
|
719
|
+
key: "useIsChanged",
|
|
720
|
+
value: function useIsChanged() {
|
|
721
|
+
return this.useOption("ischanged");
|
|
722
|
+
}
|
|
723
|
+
}, {
|
|
724
|
+
key: "checkIsChanged",
|
|
725
|
+
value: function () {
|
|
726
|
+
var _checkIsChanged = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
727
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
728
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
729
|
+
case 0:
|
|
730
|
+
_context12.next = 2;
|
|
731
|
+
return this.setOption("ischanged", this.isChanged);
|
|
732
|
+
case 2:
|
|
733
|
+
case "end":
|
|
734
|
+
return _context12.stop();
|
|
735
|
+
}
|
|
736
|
+
}, _callee12, this);
|
|
737
|
+
}));
|
|
738
|
+
function checkIsChanged() {
|
|
739
|
+
return _checkIsChanged.apply(this, arguments);
|
|
740
|
+
}
|
|
741
|
+
return checkIsChanged;
|
|
742
|
+
}()
|
|
743
|
+
}, {
|
|
744
|
+
key: "getObjectType",
|
|
745
|
+
value: /* -------------------------------------------------------------------------- */
|
|
746
|
+
/* get __object_type */
|
|
747
|
+
/* -------------------------------------------------------------------------- */
|
|
748
|
+
function getObjectType() {
|
|
749
|
+
return this.constructor["getObjectType"]();
|
|
750
|
+
}
|
|
751
|
+
}], [{
|
|
752
|
+
key: "events_clear",
|
|
753
|
+
value: function events_clear(obj) {
|
|
754
|
+
_event.EventManager.removeAll(obj);
|
|
755
|
+
}
|
|
756
|
+
}, {
|
|
757
|
+
key: "addError",
|
|
758
|
+
value: function addError(o, title, message) {
|
|
759
|
+
var sendToRegister = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
|
|
760
|
+
if (o && o.obj) {
|
|
761
|
+
return _SimpleObject["default"].addError(o.obj, title, message, sendToRegister);
|
|
762
|
+
}
|
|
763
|
+
var errStr = (0, _string.combine_if_not_blank)(title, " : ", message);
|
|
764
|
+
console.error("[REGISTER-ERROR]", errStr);
|
|
765
|
+
_global.gfunc.run_action("add_error", {
|
|
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;
|