@azrico/webobject 1.5.13 → 1.5.15

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