@azrico/webobject 1.5.59 → 1.5.61

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,211 +1,100 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.WebObjectManager = void 0;
7
- var _index = require("../index");
8
- var _ObjectManager2 = _interopRequireDefault(require("../structs/ObjectManager"));
9
- var _global = require("@azrico/global");
10
- var _object = require("@azrico/object");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- 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); }
13
- 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; }
14
- 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); }
15
- 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); }); }; }
16
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
17
- 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); } }
18
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
19
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
20
- 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); }
21
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
22
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
23
- 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; }
24
- 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); }
25
- function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
26
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
27
- 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); }
28
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
29
- 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; }
30
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
31
- 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 { SimpleObject, WebObject } from "../index";
2
+ import ObjectManager from "../structs/ObjectManager";
3
+ import { gfunc } from "@azrico/global";
4
+ import { fn_eval, } from "@azrico/object";
32
5
  /**
33
6
  * This class manages the events of an Simple Object
34
- */
35
- var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
36
- /* -------------------------------------------------------------------------- */
37
- function WebObjectManager(defaultObject) {
38
- var _this;
39
- _classCallCheck(this, WebObjectManager);
40
- _this = _callSuper(this, WebObjectManager, [defaultObject]);
41
- if (_this.constructor["__save_message"]) {
42
- /* ---------------- should we display a message after saving ? -------------- */
43
- _this.event_add("on_save", "on_save-sendmsg", /*#__PURE__*/function () {
44
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(srt) {
45
- return _regeneratorRuntime().wrap(function _callee$(_context) {
46
- while (1) switch (_context.prev = _context.next) {
47
- case 0:
48
- _context.t0 = srt;
49
- _context.next = _context.t0 === "nothing" ? 3 : _context.t0 === "normal" ? 6 : 9;
50
- break;
51
- case 3:
52
- _context.next = 5;
53
- return _global.gfunc.run_action("show_message", {
54
- message: "Nothing to save",
55
- type: "info"
56
- });
57
- case 5:
58
- return _context.abrupt("return", _context.sent);
59
- case 6:
60
- _context.next = 8;
61
- return _global.gfunc.run_action("show_message", {
62
- message: "Saved",
63
- type: "success"
64
- });
65
- case 8:
66
- return _context.abrupt("return", _context.sent);
67
- case 9:
68
- _context.next = 11;
69
- return _global.gfunc.run_action("show_message", {
70
- message: "Not saved",
71
- type: "error"
72
- });
73
- case 11:
74
- return _context.abrupt("return", _context.sent);
75
- case 12:
76
- case "end":
77
- return _context.stop();
78
- }
79
- }, _callee);
80
- }));
81
- return function (_x) {
82
- return _ref.apply(this, arguments);
83
- };
84
- }());
85
- _this.event_add("on_archive", "on_archive-sendmsg", /*#__PURE__*/function () {
86
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(srType) {
87
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
88
- while (1) switch (_context2.prev = _context2.next) {
89
- case 0:
90
- _context2.t0 = srType;
91
- _context2.next = _context2.t0 === "normal" ? 3 : 6;
92
- break;
93
- case 3:
94
- _context2.next = 5;
95
- return _global.gfunc.run_action("show_message", {
96
- message: "Archived",
97
- type: "success"
98
- });
99
- case 5:
100
- return _context2.abrupt("return", _context2.sent);
101
- case 6:
102
- _context2.next = 8;
103
- return _global.gfunc.run_action("show_message", {
104
- message: "Not archived (".concat(srType, ")"),
105
- type: "error"
106
- });
107
- case 8:
108
- return _context2.abrupt("return", _context2.sent);
109
- case 9:
110
- case "end":
111
- return _context2.stop();
112
- }
113
- }, _callee2);
114
- }));
115
- return function (_x2) {
116
- return _ref2.apply(this, arguments);
117
- };
118
- }());
119
- _this.event_add("on_unarchive", "on_unarchive-sendmsg", /*#__PURE__*/function () {
120
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(srType) {
121
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
122
- while (1) switch (_context3.prev = _context3.next) {
123
- case 0:
124
- _context3.t0 = srType;
125
- _context3.next = _context3.t0 === "normal" ? 3 : 6;
126
- break;
127
- case 3:
128
- _context3.next = 5;
129
- return _global.gfunc.run_action("show_message", {
130
- message: "Restored",
131
- type: "success"
132
- });
133
- case 5:
134
- return _context3.abrupt("return", _context3.sent);
135
- case 6:
136
- _context3.next = 8;
137
- return _global.gfunc.run_action("show_message", {
138
- message: "Not restored (".concat(srType, ")"),
139
- type: "error"
140
- });
141
- case 8:
142
- return _context3.abrupt("return", _context3.sent);
143
- case 9:
144
- case "end":
145
- return _context3.stop();
146
- }
147
- }, _callee3);
148
- }));
149
- return function (_x3) {
150
- return _ref3.apply(this, arguments);
151
- };
152
- }());
153
- _this.event_add("on_delete", "on_delete-sendmsg", /*#__PURE__*/function () {
154
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(srType) {
155
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
156
- while (1) switch (_context4.prev = _context4.next) {
157
- case 0:
158
- _context4.t0 = srType;
159
- _context4.next = _context4.t0 === "normal" ? 3 : 6;
160
- break;
161
- case 3:
162
- _context4.next = 5;
163
- return _global.gfunc.run_action("show_message", {
164
- message: "Deleted",
165
- type: "success"
166
- });
167
- case 5:
168
- return _context4.abrupt("return", _context4.sent);
169
- case 6:
170
- _context4.next = 8;
171
- return _global.gfunc.run_action("show_message", {
172
- message: "Not deleted (".concat(srType, ")"),
173
- type: "error"
174
- });
175
- case 8:
176
- return _context4.abrupt("return", _context4.sent);
177
- case 9:
178
- case "end":
179
- return _context4.stop();
180
- }
181
- }, _callee4);
182
- }));
183
- return function (_x4) {
184
- return _ref4.apply(this, arguments);
185
- };
186
- }());
187
- }
188
- return _this;
189
- }
190
- /* -------------------------------------------------------------------------- */
191
- _inherits(WebObjectManager, _ObjectManager);
192
- return _createClass(WebObjectManager, [{
193
- key: "setObject",
194
- value: function setObject(toObj) {
195
- var res = _superPropGet(WebObjectManager, "setObject", this, 3)([toObj]);
196
- if (this.__currentObject && this.__currentObject instanceof _index.SimpleObject) {
197
- var checkKeys = ["__web_path", "__db_name", "__object_name"];
198
- for (var index = 0; index < checkKeys.length; index++) {
199
- var k = checkKeys[index];
200
- if (!this.__last_object_data) this.__last_object_data = {};
201
- if (this.__currentObject[k] != null) this.__last_object_data[k] = this.__currentObject[k];
202
- }
203
- }
204
- return res;
205
- }
206
- /* -------------------------------------------------------------------------- */
207
- /* Meta data */
208
- /* -------------------------------------------------------------------------- */
7
+ */
8
+ export class WebObjectManager extends ObjectManager {
9
+ static __object_type;
10
+ static __save_message = true;
11
+ /* -------------------------------------------------------------------------- */
12
+ constructor(defaultObject) {
13
+ super(defaultObject);
14
+ if (this.constructor["__save_message"]) {
15
+ /* ---------------- should we display a message after saving ? -------------- */
16
+ this.event_add("on_save", "on_save-sendmsg", async (srt) => {
17
+ switch (srt) {
18
+ case "nothing":
19
+ return await gfunc.run_action("show_message", {
20
+ message: "Nothing to save",
21
+ type: "info",
22
+ });
23
+ case "normal":
24
+ return await gfunc.run_action("show_message", {
25
+ message: "Saved",
26
+ type: "success",
27
+ });
28
+ default:
29
+ return await gfunc.run_action("show_message", {
30
+ message: "Not saved",
31
+ type: "error",
32
+ });
33
+ }
34
+ });
35
+ this.event_add("on_archive", "on_archive-sendmsg", async (srType) => {
36
+ switch (srType) {
37
+ case "normal":
38
+ return await gfunc.run_action("show_message", {
39
+ message: "Archived",
40
+ type: "success",
41
+ });
42
+ default:
43
+ return await gfunc.run_action("show_message", {
44
+ message: `Not archived (${srType})`,
45
+ type: "error",
46
+ });
47
+ }
48
+ });
49
+ this.event_add("on_unarchive", "on_unarchive-sendmsg", async (srType) => {
50
+ switch (srType) {
51
+ case "normal":
52
+ return await gfunc.run_action("show_message", {
53
+ message: "Restored",
54
+ type: "success",
55
+ });
56
+ default:
57
+ return await gfunc.run_action("show_message", {
58
+ message: `Not restored (${srType})`,
59
+ type: "error",
60
+ });
61
+ }
62
+ });
63
+ this.event_add("on_delete", "on_delete-sendmsg", async (srType) => {
64
+ switch (srType) {
65
+ case "normal":
66
+ return await gfunc.run_action("show_message", {
67
+ message: "Deleted",
68
+ type: "success",
69
+ });
70
+ default:
71
+ return await gfunc.run_action("show_message", {
72
+ message: `Not deleted (${srType})`,
73
+ type: "error",
74
+ });
75
+ }
76
+ });
77
+ }
78
+ }
79
+ /* -------------------------------------------------------------------------- */
80
+ setObject(toObj) {
81
+ const res = super.setObject(toObj);
82
+ if (this.__currentObject &&
83
+ this.__currentObject instanceof SimpleObject) {
84
+ const checkKeys = ["__web_path", "__db_name", "__object_name"];
85
+ for (let index = 0; index < checkKeys.length; index++) {
86
+ const k = checkKeys[index];
87
+ if (!this.__last_object_data)
88
+ this.__last_object_data = {};
89
+ if (this.__currentObject[k] != null)
90
+ this.__last_object_data[k] = this.__currentObject[k];
91
+ }
92
+ }
93
+ return res;
94
+ }
95
+ /* -------------------------------------------------------------------------- */
96
+ /* Meta data */
97
+ /* -------------------------------------------------------------------------- */
209
98
  /**
210
99
  * Update meta value of this object , meta data is stored in meta_data variable
211
100
  * @param key
@@ -213,677 +102,189 @@ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_Object
213
102
  * @param createIfNotExists should we create a new meta if key does not exist
214
103
  * @param sendChange
215
104
  * @returns
216
- */
217
- }, {
218
- key: "setMetaValue",
219
- value: (function () {
220
- var _setMetaValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
221
- var _this$obj;
222
- var sendChange,
223
- _args5 = arguments;
224
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
225
- while (1) switch (_context5.prev = _context5.next) {
226
- case 0:
227
- sendChange = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : "auto";
228
- _context5.next = 3;
229
- return (_this$obj = this.obj) === null || _this$obj === void 0 ? void 0 : _this$obj.setMetaValue(key, value, sendChange);
230
- case 3:
231
- return _context5.abrupt("return", _context5.sent);
232
- case 4:
233
- case "end":
234
- return _context5.stop();
235
- }
236
- }, _callee5, this);
237
- }));
238
- function setMetaValue(_x5, _x6) {
239
- return _setMetaValue.apply(this, arguments);
240
- }
241
- return setMetaValue;
242
- }())
243
- }, {
244
- key: "getMetaValue",
245
- value: function getMetaValue(key) {
246
- var _this$obj2;
247
- return (_this$obj2 = this.obj) === null || _this$obj2 === void 0 ? void 0 : _this$obj2.getMetaValue(key);
248
- }
249
- /* -------------------------------------------------------------------------- */
250
- }, {
251
- key: "get_deltaObject",
252
- value: (function () {
253
- var _get_deltaObject = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
254
- var _this$obj3;
255
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
256
- while (1) switch (_context6.prev = _context6.next) {
257
- case 0:
258
- _context6.next = 2;
259
- return (_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.get_deltaObject();
260
- case 2:
261
- _context6.t0 = _context6.sent;
262
- if (_context6.t0) {
263
- _context6.next = 5;
264
- break;
265
- }
266
- _context6.t0 = {};
267
- case 5:
268
- return _context6.abrupt("return", _context6.t0);
269
- case 6:
270
- case "end":
271
- return _context6.stop();
272
- }
273
- }, _callee6, this);
274
- }));
275
- function get_deltaObject() {
276
- return _get_deltaObject.apply(this, arguments);
277
- }
278
- return get_deltaObject;
279
- }() /* ------------------------------ save and load ----------------------------- */)
280
- }, {
281
- key: "Save",
282
- value: (function () {
283
- var _Save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
284
- var _this$obj4;
285
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
286
- while (1) switch (_context7.prev = _context7.next) {
287
- case 0:
288
- _context7.next = 2;
289
- return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.Save();
290
- case 2:
291
- _context7.t0 = _context7.sent;
292
- if (_context7.t0) {
293
- _context7.next = 5;
294
- break;
295
- }
296
- _context7.t0 = false;
297
- case 5:
298
- return _context7.abrupt("return", _context7.t0);
299
- case 6:
300
- case "end":
301
- return _context7.stop();
302
- }
303
- }, _callee7, this);
304
- }));
305
- function Save() {
306
- return _Save.apply(this, arguments);
307
- }
308
- return Save;
309
- }())
310
- }, {
311
- key: "New",
312
- value: function () {
313
- var _New = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
314
- var cls;
315
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
316
- while (1) switch (_context8.prev = _context8.next) {
317
- case 0:
318
- cls = this.getObjectType();
319
- this.setObject(new cls());
320
- _context8.next = 4;
321
- return this.onNew();
322
- case 4:
323
- case "end":
324
- return _context8.stop();
325
- }
326
- }, _callee8, this);
327
- }));
328
- function New() {
329
- return _New.apply(this, arguments);
330
- }
331
- return New;
332
- }()
333
- }, {
334
- key: "Delete",
335
- value: function () {
336
- var _Delete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
337
- var _this$obj5;
338
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
339
- while (1) switch (_context9.prev = _context9.next) {
340
- case 0:
341
- _context9.next = 2;
342
- return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.Delete();
343
- case 2:
344
- _context9.t0 = _context9.sent;
345
- if (_context9.t0) {
346
- _context9.next = 5;
347
- break;
348
- }
349
- _context9.t0 = false;
350
- case 5:
351
- return _context9.abrupt("return", _context9.t0);
352
- case 6:
353
- case "end":
354
- return _context9.stop();
355
- }
356
- }, _callee9, this);
357
- }));
358
- function Delete() {
359
- return _Delete.apply(this, arguments);
360
- }
361
- return Delete;
362
- }()
363
- }, {
364
- key: "Lock",
365
- value: function () {
366
- var _Lock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
367
- var _this$obj6;
368
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
369
- while (1) switch (_context10.prev = _context10.next) {
370
- case 0:
371
- _context10.next = 2;
372
- return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.Lock();
373
- case 2:
374
- _context10.t0 = _context10.sent;
375
- if (_context10.t0) {
376
- _context10.next = 5;
377
- break;
378
- }
379
- _context10.t0 = false;
380
- case 5:
381
- return _context10.abrupt("return", _context10.t0);
382
- case 6:
383
- case "end":
384
- return _context10.stop();
385
- }
386
- }, _callee10, this);
387
- }));
388
- function Lock() {
389
- return _Lock.apply(this, arguments);
390
- }
391
- return Lock;
392
- }()
393
- }, {
394
- key: "UnLock",
395
- value: function () {
396
- var _UnLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
397
- var _this$obj7;
398
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
399
- while (1) switch (_context11.prev = _context11.next) {
400
- case 0:
401
- _context11.next = 2;
402
- return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.UnLock();
403
- case 2:
404
- _context11.t0 = _context11.sent;
405
- if (_context11.t0) {
406
- _context11.next = 5;
407
- break;
408
- }
409
- _context11.t0 = false;
410
- case 5:
411
- return _context11.abrupt("return", _context11.t0);
412
- case 6:
413
- case "end":
414
- return _context11.stop();
415
- }
416
- }, _callee11, this);
417
- }));
418
- function UnLock() {
419
- return _UnLock.apply(this, arguments);
420
- }
421
- return UnLock;
422
- }()
423
- }, {
424
- key: "Archive",
425
- value: function () {
426
- var _Archive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
427
- var _this$obj8;
428
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
429
- while (1) switch (_context12.prev = _context12.next) {
430
- case 0:
431
- _context12.next = 2;
432
- return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.Archive();
433
- case 2:
434
- _context12.t0 = _context12.sent;
435
- if (_context12.t0) {
436
- _context12.next = 5;
437
- break;
438
- }
439
- _context12.t0 = false;
440
- case 5:
441
- return _context12.abrupt("return", _context12.t0);
442
- case 6:
443
- case "end":
444
- return _context12.stop();
445
- }
446
- }, _callee12, this);
447
- }));
448
- function Archive() {
449
- return _Archive.apply(this, arguments);
450
- }
451
- return Archive;
452
- }()
453
- }, {
454
- key: "UnArchive",
455
- value: function () {
456
- var _UnArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
457
- var _this$obj9;
458
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
459
- while (1) switch (_context13.prev = _context13.next) {
460
- case 0:
461
- _context13.next = 2;
462
- return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.UnArchive();
463
- case 2:
464
- _context13.t0 = _context13.sent;
465
- if (_context13.t0) {
466
- _context13.next = 5;
467
- break;
468
- }
469
- _context13.t0 = false;
470
- case 5:
471
- return _context13.abrupt("return", _context13.t0);
472
- case 6:
473
- case "end":
474
- return _context13.stop();
475
- }
476
- }, _callee13, this);
477
- }));
478
- function UnArchive() {
479
- return _UnArchive.apply(this, arguments);
480
- }
481
- return UnArchive;
482
- }() /* -------------------------------------------------------------------------- */
483
- }, {
484
- key: "Load",
485
- value: (function () {
486
- var _Load = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(id) {
487
- var classType, result_product;
488
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
489
- while (1) switch (_context14.prev = _context14.next) {
490
- case 0:
491
- if (id) {
492
- _context14.next = 2;
493
- break;
494
- }
495
- return _context14.abrupt("return");
496
- case 2:
497
- _context14.prev = 2;
498
- this.event_run("on_process_start", true);
499
- classType = this.getObjectType();
500
- if (!classType) {
501
- console.error("[webobjectmanager]", "getObjectType failed to get the object_type.", "did you set the __object_type correctly ?");
502
- }
503
- _context14.next = 8;
504
- return classType.get_single(id, false);
505
- case 8:
506
- result_product = _context14.sent;
507
- if (!(result_product && _typeof(result_product) === "object" && _index.WebObject.getID(result_product))) {
508
- _context14.next = 15;
509
- break;
510
- }
511
- this.setObject(result_product);
512
- _context14.next = 13;
513
- return result_product.onLoad();
514
- case 13:
515
- _context14.next = 17;
516
- break;
517
- case 15:
518
- console.error("badobject:", id, result_product);
519
- _index.WebObject.addError(this.obj, "Invalid ".concat(this.__object_name), "The loaded ".concat(this.__object_name, " from website is invalid"), true);
520
- case 17:
521
- _context14.prev = 17;
522
- this.event_run("on_process_end", true);
523
- return _context14.finish(17);
524
- case 20:
525
- return _context14.abrupt("return", this.getObject());
526
- case 21:
527
- case "end":
528
- return _context14.stop();
529
- }
530
- }, _callee14, this, [[2,, 17, 20]]);
531
- }));
532
- function Load(_x7) {
533
- return _Load.apply(this, arguments);
534
- }
535
- return Load;
536
- }()
537
- /* -------------------------------------------------------------------------- */
538
- /* Child Functions */
539
- /* -------------------------------------------------------------------------- */
540
- )
541
- }, {
542
- key: "__web_path",
543
- get: function get() {
544
- return this.__getObjectData(["__web_path", "__db_name"]);
545
- }
546
- }, {
547
- key: "__db_name",
548
- get: function get() {
549
- return this.__getObjectData(["__db_name", "__web_path"]);
550
- }
551
- }, {
552
- key: "__object_name",
553
- get: function get() {
554
- return this.__getObjectData(["__object_name", "__db_name"]);
555
- }
556
- }, {
557
- key: "get_webpath",
558
- value: function get_webpath() {
559
- return this.__getObjectData(["__web_path", "__db_name"]);
560
- }
561
- }, {
562
- key: "__getObjectData",
563
- value: function __getObjectData(checkKeys) {
564
- var objtype = this.getObjectType();
565
- for (var index = 0; index < checkKeys.length; index++) {
566
- var _this$obj10;
567
- var k = checkKeys[index];
568
- var v = ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10[k]) || this.__last_object_data[k] || (objtype === null || objtype === void 0 ? void 0 : objtype[k]);
569
- if (v) return v;
570
- }
571
- return "";
572
- }
573
- /* -------------------------------------------------------------------------- */
574
- /* Default Events */
575
- /* -------------------------------------------------------------------------- */
105
+ */
106
+ async setMetaValue(key, value, sendChange = "auto") {
107
+ return await this.obj?.setMetaValue(key, value, sendChange);
108
+ }
109
+ getMetaValue(key) {
110
+ return this.obj?.getMetaValue(key);
111
+ }
112
+ /* -------------------------------------------------------------------------- */
113
+ async get_deltaObject() {
114
+ return (await this.obj?.get_deltaObject()) || {};
115
+ }
116
+ /* ------------------------------ save and load ----------------------------- */
117
+ async Save() {
118
+ return (await this.obj?.Save()) || false;
119
+ }
120
+ async New() {
121
+ const cls = this.getObjectType();
122
+ this.setObject(new cls());
123
+ await this.onNew();
124
+ }
125
+ async Delete() {
126
+ return (await this.obj?.Delete()) || false;
127
+ }
128
+ async Lock() {
129
+ return (await this.obj?.Lock()) || false;
130
+ }
131
+ async UnLock() {
132
+ return (await this.obj?.UnLock()) || false;
133
+ }
134
+ async Archive() {
135
+ return (await this.obj?.Archive()) || false;
136
+ }
137
+ async UnArchive() {
138
+ return (await this.obj?.UnArchive()) || false;
139
+ }
140
+ /* -------------------------------------------------------------------------- */
141
+ async Load(id, ...p) {
142
+ if (!id)
143
+ return;
144
+ try {
145
+ this.event_run("on_process_start", true);
146
+ const classType = this.getObjectType();
147
+ if (!classType) {
148
+ console.error("[webobjectmanager]", "getObjectType failed to get the object_type.", "did you set the __object_type correctly ?");
149
+ }
150
+ const result_product = await classType.get_single(id, false);
151
+ if (result_product &&
152
+ typeof result_product === "object" &&
153
+ WebObject.getID(result_product)) {
154
+ this.setObject(result_product);
155
+ await result_product.onLoad();
156
+ }
157
+ else {
158
+ console.error("badobject:", id, result_product);
159
+ WebObject.addError(this.obj, `Invalid ${this.__object_name}`, `The loaded ${this.__object_name} from website is invalid`, true);
160
+ }
161
+ }
162
+ finally {
163
+ this.event_run("on_process_end", true);
164
+ }
165
+ return this.getObject();
166
+ }
167
+ /* -------------------------------------------------------------------------- */
168
+ /* Child Functions */
169
+ /* -------------------------------------------------------------------------- */
170
+ get __web_path() {
171
+ return this.__getObjectData(["__web_path", "__db_name"]);
172
+ }
173
+ get __db_name() {
174
+ return this.__getObjectData(["__db_name", "__web_path"]);
175
+ }
176
+ get __object_name() {
177
+ return this.__getObjectData(["__object_name", "__db_name"]);
178
+ }
179
+ get_webpath() {
180
+ return this.__getObjectData(["__web_path", "__db_name"]);
181
+ }
182
+ __getObjectData(checkKeys) {
183
+ const objtype = this.getObjectType();
184
+ for (let index = 0; index < checkKeys.length; index++) {
185
+ const k = checkKeys[index];
186
+ const v = this.obj?.[k] || this.__last_object_data[k] || objtype?.[k];
187
+ if (v)
188
+ return v;
189
+ }
190
+ return "";
191
+ }
192
+ /* -------------------------------------------------------------------------- */
193
+ /* Default Events */
194
+ /* -------------------------------------------------------------------------- */
576
195
  /**
577
196
  * Use this when you delete Object
578
197
  * @param p
579
198
  * @returns
580
- */
581
- }, {
582
- key: "onDelete",
583
- value: (function () {
584
- var _onDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
585
- var srt;
586
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
587
- while (1) switch (_context15.prev = _context15.next) {
588
- case 0:
589
- srt = this.getSaveResultType();
590
- _context15.next = 3;
591
- return this.event_run("on_delete", srt);
592
- case 3:
593
- _context15.next = 5;
594
- return this.event_run("on_after_delete", srt);
595
- case 5:
596
- return _context15.abrupt("return", true);
597
- case 6:
598
- case "end":
599
- return _context15.stop();
600
- }
601
- }, _callee15, this);
602
- }));
603
- function onDelete() {
604
- return _onDelete.apply(this, arguments);
605
- }
606
- return onDelete;
607
- }())
608
- }, {
609
- key: "onArchive",
610
- value: function () {
611
- var _onArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
612
- var srt;
613
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
614
- while (1) switch (_context16.prev = _context16.next) {
615
- case 0:
616
- srt = this.getSaveResultType();
617
- _context16.next = 3;
618
- return this.event_run("on_archive", srt);
619
- case 3:
620
- _context16.next = 5;
621
- return this.event_run("on_after_archive", srt);
622
- case 5:
623
- return _context16.abrupt("return", true);
624
- case 6:
625
- case "end":
626
- return _context16.stop();
627
- }
628
- }, _callee16, this);
629
- }));
630
- function onArchive() {
631
- return _onArchive.apply(this, arguments);
632
- }
633
- return onArchive;
634
- }()
635
- }, {
636
- key: "onUnArchive",
637
- value: function () {
638
- var _onUnArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
639
- var srt;
640
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
641
- while (1) switch (_context17.prev = _context17.next) {
642
- case 0:
643
- srt = this.getSaveResultType();
644
- _context17.next = 3;
645
- return this.event_run("on_unarchive", srt);
646
- case 3:
647
- _context17.next = 5;
648
- return this.event_run("on_after_unarchive", srt);
649
- case 5:
650
- return _context17.abrupt("return", true);
651
- case 6:
652
- case "end":
653
- return _context17.stop();
654
- }
655
- }, _callee17, this);
656
- }));
657
- function onUnArchive() {
658
- return _onUnArchive.apply(this, arguments);
659
- }
660
- return onUnArchive;
661
- }()
662
- }, {
663
- key: "onLock",
664
- value: function () {
665
- var _onLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
666
- var srt;
667
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
668
- while (1) switch (_context18.prev = _context18.next) {
669
- case 0:
670
- srt = this.getSaveResultType();
671
- _context18.next = 3;
672
- return this.event_run("on_lock", srt);
673
- case 3:
674
- _context18.next = 5;
675
- return this.event_run("on_after_lock", srt);
676
- case 5:
677
- return _context18.abrupt("return", true);
678
- case 6:
679
- case "end":
680
- return _context18.stop();
681
- }
682
- }, _callee18, this);
683
- }));
684
- function onLock() {
685
- return _onLock.apply(this, arguments);
686
- }
687
- return onLock;
688
- }()
689
- }, {
690
- key: "onUnLock",
691
- value: function () {
692
- var _onUnLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
693
- var srt;
694
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
695
- while (1) switch (_context19.prev = _context19.next) {
696
- case 0:
697
- srt = this.getSaveResultType();
698
- _context19.next = 3;
699
- return this.event_run("on_unlock", srt);
700
- case 3:
701
- _context19.next = 5;
702
- return this.event_run("on_after_unlock", srt);
703
- case 5:
704
- return _context19.abrupt("return", true);
705
- case 6:
706
- case "end":
707
- return _context19.stop();
708
- }
709
- }, _callee19, this);
710
- }));
711
- function onUnLock() {
712
- return _onUnLock.apply(this, arguments);
713
- }
714
- return onUnLock;
715
- }()
199
+ */
200
+ async onDelete(...p) {
201
+ const srt = this.getSaveResultType();
202
+ await this.event_run("on_delete", srt);
203
+ await this.event_run("on_after_delete", srt);
204
+ return true;
205
+ }
206
+ async onArchive(...p) {
207
+ const srt = this.getSaveResultType();
208
+ await this.event_run("on_archive", srt);
209
+ await this.event_run("on_after_archive", srt);
210
+ return true;
211
+ }
212
+ async onUnArchive(...p) {
213
+ const srt = this.getSaveResultType();
214
+ await this.event_run("on_unarchive", srt);
215
+ await this.event_run("on_after_unarchive", srt);
216
+ return true;
217
+ }
218
+ async onLock(...p) {
219
+ const srt = this.getSaveResultType();
220
+ await this.event_run("on_lock", srt);
221
+ await this.event_run("on_after_lock", srt);
222
+ return true;
223
+ }
224
+ async onUnLock(...p) {
225
+ const srt = this.getSaveResultType();
226
+ await this.event_run("on_unlock", srt);
227
+ await this.event_run("on_after_unlock", srt);
228
+ return true;
229
+ }
716
230
  /**
717
231
  * Use this when you load new Object
718
232
  * @param p
719
233
  * @returns
720
- */
721
- }, {
722
- key: "onNew",
723
- value: (function () {
724
- var _onNew = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
725
- var _this$obj11;
726
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
727
- while (1) switch (_context20.prev = _context20.next) {
728
- case 0:
729
- if (this.canModify) {
730
- (_this$obj11 = this.obj) === null || _this$obj11 === void 0 || _this$obj11.setOriginal();
731
- }
732
- _context20.next = 3;
733
- return this.event_run("on_new");
734
- case 3:
735
- _context20.next = 5;
736
- return this.event_run("on_change", true);
737
- case 5:
738
- _context20.next = 7;
739
- return this.event_run("on_after_new");
740
- case 7:
741
- _context20.next = 9;
742
- return this.checkIsChanged();
743
- case 9:
744
- _context20.next = 11;
745
- return Promise.resolve(true);
746
- case 11:
747
- return _context20.abrupt("return", _context20.sent);
748
- case 12:
749
- case "end":
750
- return _context20.stop();
751
- }
752
- }, _callee20, this);
753
- }));
754
- function onNew() {
755
- return _onNew.apply(this, arguments);
756
- }
757
- return onNew;
758
- }()
234
+ */
235
+ async onNew(...p) {
236
+ if (this.canModify) {
237
+ this.obj?.setOriginal();
238
+ }
239
+ await this.event_run("on_new");
240
+ await this.event_run("on_change", true);
241
+ await this.event_run("on_after_new");
242
+ await this.checkIsChanged();
243
+ return await Promise.resolve(true);
244
+ }
759
245
  /**
760
246
  * Use this when you load data to the object
761
247
  * @param p
762
248
  * @returns
763
- */
764
- )
765
- }, {
766
- key: "onLoad",
767
- value: (function () {
768
- var _onLoad = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
769
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
770
- while (1) switch (_context21.prev = _context21.next) {
771
- case 0:
772
- if (this.canModify && this.obj) {
773
- this.obj.isDeleted = false;
774
- this.obj.setOriginal();
775
- }
776
- _context21.next = 3;
777
- return this.event_run("on_load");
778
- case 3:
779
- _context21.next = 5;
780
- return this.event_run("on_change", true);
781
- case 5:
782
- _context21.next = 7;
783
- return this.event_run("on_after_load");
784
- case 7:
785
- _context21.next = 9;
786
- return this.event_run("on_load_finished");
787
- case 9:
788
- _context21.next = 11;
789
- return this.checkIsChanged();
790
- case 11:
791
- return _context21.abrupt("return", true);
792
- case 12:
793
- case "end":
794
- return _context21.stop();
795
- }
796
- }, _callee21, this);
797
- }));
798
- function onLoad() {
799
- return _onLoad.apply(this, arguments);
800
- }
801
- return onLoad;
802
- }()
249
+ */
250
+ async onLoad(...p) {
251
+ if (this.canModify && this.obj) {
252
+ this.obj.isDeleted = false;
253
+ this.obj.setOriginal();
254
+ }
255
+ await this.event_run("on_load");
256
+ await this.event_run("on_change", true);
257
+ await this.event_run("on_after_load");
258
+ await this.event_run("on_load_finished");
259
+ await this.checkIsChanged();
260
+ return true;
261
+ }
803
262
  /**
804
263
  * Use this after succesful save to Database
805
264
  * @param p
806
265
  * @returns
807
- */
808
- )
809
- }, {
810
- key: "onSave",
811
- value: (function () {
812
- var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
813
- var srt;
814
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
815
- while (1) switch (_context22.prev = _context22.next) {
816
- case 0:
817
- srt = this.getSaveResultType();
818
- _context22.next = 3;
819
- return this.event_run("on_save", srt);
820
- case 3:
821
- _context22.next = 5;
822
- return this.event_run("on_change", true);
823
- case 5:
824
- _context22.next = 7;
825
- return this.checkIsChanged();
826
- case 7:
827
- _context22.next = 9;
828
- return Promise.resolve(true);
829
- case 9:
830
- return _context22.abrupt("return", _context22.sent);
831
- case 10:
832
- case "end":
833
- return _context22.stop();
834
- }
835
- }, _callee22, this);
836
- }));
837
- function onSave() {
838
- return _onSave.apply(this, arguments);
839
- }
840
- return onSave;
841
- }())
842
- }, {
843
- key: "onAfterSave",
844
- value: function () {
845
- var _onAfterSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
846
- var srt;
847
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
848
- while (1) switch (_context23.prev = _context23.next) {
849
- case 0:
850
- srt = this.getSaveResultType();
851
- _context23.next = 3;
852
- return this.event_run("on_after_save", srt);
853
- case 3:
854
- _context23.next = 5;
855
- return this.event_run("on_save_finished", srt);
856
- case 5:
857
- _context23.next = 7;
858
- return Promise.resolve(true);
859
- case 7:
860
- return _context23.abrupt("return", _context23.sent);
861
- case 8:
862
- case "end":
863
- return _context23.stop();
864
- }
865
- }, _callee23, this);
866
- }));
867
- function onAfterSave() {
868
- return _onAfterSave.apply(this, arguments);
869
- }
870
- return onAfterSave;
871
- }()
872
- /* -------------------------------------------------------------------------- */
873
- /* get __object_type */
874
- /* -------------------------------------------------------------------------- */
875
- }, {
876
- key: "getObjectType",
877
- value: function getObjectType() {
878
- return this.constructor["getObjectType"]();
879
- }
880
- }], [{
881
- key: "getObjectType",
882
- value: function getObjectType() {
883
- return (0, _object.fn_eval)(this.__object_type);
884
- }
885
- }]);
886
- }(_ObjectManager2["default"]);
887
- _defineProperty(WebObjectManager, "__object_type", void 0);
888
- _defineProperty(WebObjectManager, "__save_message", true);
889
- var _default = exports["default"] = WebObjectManager;
266
+ */
267
+ async onSave(...p) {
268
+ const srt = this.getSaveResultType();
269
+ await this.event_run("on_save", srt);
270
+ await this.event_run("on_change", true);
271
+ await this.checkIsChanged();
272
+ return await Promise.resolve(true);
273
+ }
274
+ async onAfterSave(...p) {
275
+ const srt = this.getSaveResultType();
276
+ await this.event_run("on_after_save", srt);
277
+ await this.event_run("on_save_finished", srt);
278
+ return await Promise.resolve(true);
279
+ }
280
+ /* -------------------------------------------------------------------------- */
281
+ /* get __object_type */
282
+ /* -------------------------------------------------------------------------- */
283
+ getObjectType() {
284
+ return this.constructor["getObjectType"]();
285
+ }
286
+ static getObjectType() {
287
+ return fn_eval(this.__object_type);
288
+ }
289
+ }
290
+ export default WebObjectManager;