@azrico/webobject 1.4.175 → 1.4.177

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