@azrico/webobject 1.5.61 → 1.5.63

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,100 +1,211 @@
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";
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/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { 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 && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
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); }
5
32
  /**
6
33
  * This class manages the events of an Simple Object
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
- /* -------------------------------------------------------------------------- */
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
+ /* -------------------------------------------------------------------------- */
98
209
  /**
99
210
  * Update meta value of this object , meta data is stored in meta_data variable
100
211
  * @param key
@@ -102,189 +213,677 @@ export class WebObjectManager extends ObjectManager {
102
213
  * @param createIfNotExists should we create a new meta if key does not exist
103
214
  * @param sendChange
104
215
  * @returns
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
- /* -------------------------------------------------------------------------- */
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 _callee0() {
367
+ var _this$obj6;
368
+ return _regeneratorRuntime().wrap(function _callee0$(_context0) {
369
+ while (1) switch (_context0.prev = _context0.next) {
370
+ case 0:
371
+ _context0.next = 2;
372
+ return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.Lock();
373
+ case 2:
374
+ _context0.t0 = _context0.sent;
375
+ if (_context0.t0) {
376
+ _context0.next = 5;
377
+ break;
378
+ }
379
+ _context0.t0 = false;
380
+ case 5:
381
+ return _context0.abrupt("return", _context0.t0);
382
+ case 6:
383
+ case "end":
384
+ return _context0.stop();
385
+ }
386
+ }, _callee0, 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 _callee1() {
397
+ var _this$obj7;
398
+ return _regeneratorRuntime().wrap(function _callee1$(_context1) {
399
+ while (1) switch (_context1.prev = _context1.next) {
400
+ case 0:
401
+ _context1.next = 2;
402
+ return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.UnLock();
403
+ case 2:
404
+ _context1.t0 = _context1.sent;
405
+ if (_context1.t0) {
406
+ _context1.next = 5;
407
+ break;
408
+ }
409
+ _context1.t0 = false;
410
+ case 5:
411
+ return _context1.abrupt("return", _context1.t0);
412
+ case 6:
413
+ case "end":
414
+ return _context1.stop();
415
+ }
416
+ }, _callee1, 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 _callee10() {
427
+ var _this$obj8;
428
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
429
+ while (1) switch (_context10.prev = _context10.next) {
430
+ case 0:
431
+ _context10.next = 2;
432
+ return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.Archive();
433
+ case 2:
434
+ _context10.t0 = _context10.sent;
435
+ if (_context10.t0) {
436
+ _context10.next = 5;
437
+ break;
438
+ }
439
+ _context10.t0 = false;
440
+ case 5:
441
+ return _context10.abrupt("return", _context10.t0);
442
+ case 6:
443
+ case "end":
444
+ return _context10.stop();
445
+ }
446
+ }, _callee10, 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 _callee11() {
457
+ var _this$obj9;
458
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
459
+ while (1) switch (_context11.prev = _context11.next) {
460
+ case 0:
461
+ _context11.next = 2;
462
+ return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.UnArchive();
463
+ case 2:
464
+ _context11.t0 = _context11.sent;
465
+ if (_context11.t0) {
466
+ _context11.next = 5;
467
+ break;
468
+ }
469
+ _context11.t0 = false;
470
+ case 5:
471
+ return _context11.abrupt("return", _context11.t0);
472
+ case 6:
473
+ case "end":
474
+ return _context11.stop();
475
+ }
476
+ }, _callee11, 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 _callee12(id) {
487
+ var classType, result_product;
488
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
489
+ while (1) switch (_context12.prev = _context12.next) {
490
+ case 0:
491
+ if (id) {
492
+ _context12.next = 2;
493
+ break;
494
+ }
495
+ return _context12.abrupt("return");
496
+ case 2:
497
+ _context12.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
+ _context12.next = 8;
504
+ return classType.get_single(id, false);
505
+ case 8:
506
+ result_product = _context12.sent;
507
+ if (!(result_product && _typeof(result_product) === "object" && _index.WebObject.getID(result_product))) {
508
+ _context12.next = 15;
509
+ break;
510
+ }
511
+ this.setObject(result_product);
512
+ _context12.next = 13;
513
+ return result_product.onLoad();
514
+ case 13:
515
+ _context12.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
+ _context12.prev = 17;
522
+ this.event_run("on_process_end", true);
523
+ return _context12.finish(17);
524
+ case 20:
525
+ return _context12.abrupt("return", this.getObject());
526
+ case 21:
527
+ case "end":
528
+ return _context12.stop();
529
+ }
530
+ }, _callee12, 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$obj0;
567
+ var k = checkKeys[index];
568
+ var v = ((_this$obj0 = this.obj) === null || _this$obj0 === void 0 ? void 0 : _this$obj0[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
+ /* -------------------------------------------------------------------------- */
195
576
  /**
196
577
  * Use this when you delete Object
197
578
  * @param p
198
579
  * @returns
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
- }
580
+ */
581
+ }, {
582
+ key: "onDelete",
583
+ value: (function () {
584
+ var _onDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
585
+ var srt;
586
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
587
+ while (1) switch (_context13.prev = _context13.next) {
588
+ case 0:
589
+ srt = this.getSaveResultType();
590
+ _context13.next = 3;
591
+ return this.event_run("on_delete", srt);
592
+ case 3:
593
+ _context13.next = 5;
594
+ return this.event_run("on_after_delete", srt);
595
+ case 5:
596
+ return _context13.abrupt("return", true);
597
+ case 6:
598
+ case "end":
599
+ return _context13.stop();
600
+ }
601
+ }, _callee13, 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 _callee14() {
612
+ var srt;
613
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
614
+ while (1) switch (_context14.prev = _context14.next) {
615
+ case 0:
616
+ srt = this.getSaveResultType();
617
+ _context14.next = 3;
618
+ return this.event_run("on_archive", srt);
619
+ case 3:
620
+ _context14.next = 5;
621
+ return this.event_run("on_after_archive", srt);
622
+ case 5:
623
+ return _context14.abrupt("return", true);
624
+ case 6:
625
+ case "end":
626
+ return _context14.stop();
627
+ }
628
+ }, _callee14, 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 _callee15() {
639
+ var srt;
640
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
641
+ while (1) switch (_context15.prev = _context15.next) {
642
+ case 0:
643
+ srt = this.getSaveResultType();
644
+ _context15.next = 3;
645
+ return this.event_run("on_unarchive", srt);
646
+ case 3:
647
+ _context15.next = 5;
648
+ return this.event_run("on_after_unarchive", srt);
649
+ case 5:
650
+ return _context15.abrupt("return", true);
651
+ case 6:
652
+ case "end":
653
+ return _context15.stop();
654
+ }
655
+ }, _callee15, 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 _callee16() {
666
+ var srt;
667
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
668
+ while (1) switch (_context16.prev = _context16.next) {
669
+ case 0:
670
+ srt = this.getSaveResultType();
671
+ _context16.next = 3;
672
+ return this.event_run("on_lock", srt);
673
+ case 3:
674
+ _context16.next = 5;
675
+ return this.event_run("on_after_lock", srt);
676
+ case 5:
677
+ return _context16.abrupt("return", true);
678
+ case 6:
679
+ case "end":
680
+ return _context16.stop();
681
+ }
682
+ }, _callee16, 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 _callee17() {
693
+ var srt;
694
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
695
+ while (1) switch (_context17.prev = _context17.next) {
696
+ case 0:
697
+ srt = this.getSaveResultType();
698
+ _context17.next = 3;
699
+ return this.event_run("on_unlock", srt);
700
+ case 3:
701
+ _context17.next = 5;
702
+ return this.event_run("on_after_unlock", srt);
703
+ case 5:
704
+ return _context17.abrupt("return", true);
705
+ case 6:
706
+ case "end":
707
+ return _context17.stop();
708
+ }
709
+ }, _callee17, this);
710
+ }));
711
+ function onUnLock() {
712
+ return _onUnLock.apply(this, arguments);
713
+ }
714
+ return onUnLock;
715
+ }()
230
716
  /**
231
717
  * Use this when you load new Object
232
718
  * @param p
233
719
  * @returns
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
- }
720
+ */
721
+ }, {
722
+ key: "onNew",
723
+ value: (function () {
724
+ var _onNew = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
725
+ var _this$obj1;
726
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
727
+ while (1) switch (_context18.prev = _context18.next) {
728
+ case 0:
729
+ if (this.canModify) {
730
+ (_this$obj1 = this.obj) === null || _this$obj1 === void 0 || _this$obj1.setOriginal();
731
+ }
732
+ _context18.next = 3;
733
+ return this.event_run("on_new");
734
+ case 3:
735
+ _context18.next = 5;
736
+ return this.event_run("on_change", true);
737
+ case 5:
738
+ _context18.next = 7;
739
+ return this.event_run("on_after_new");
740
+ case 7:
741
+ _context18.next = 9;
742
+ return this.checkIsChanged();
743
+ case 9:
744
+ _context18.next = 11;
745
+ return Promise.resolve(true);
746
+ case 11:
747
+ return _context18.abrupt("return", _context18.sent);
748
+ case 12:
749
+ case "end":
750
+ return _context18.stop();
751
+ }
752
+ }, _callee18, this);
753
+ }));
754
+ function onNew() {
755
+ return _onNew.apply(this, arguments);
756
+ }
757
+ return onNew;
758
+ }()
245
759
  /**
246
760
  * Use this when you load data to the object
247
761
  * @param p
248
762
  * @returns
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
- }
763
+ */
764
+ )
765
+ }, {
766
+ key: "onLoad",
767
+ value: (function () {
768
+ var _onLoad = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
769
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
770
+ while (1) switch (_context19.prev = _context19.next) {
771
+ case 0:
772
+ if (this.canModify && this.obj) {
773
+ this.obj.isDeleted = false;
774
+ this.obj.setOriginal();
775
+ }
776
+ _context19.next = 3;
777
+ return this.event_run("on_load");
778
+ case 3:
779
+ _context19.next = 5;
780
+ return this.event_run("on_change", true);
781
+ case 5:
782
+ _context19.next = 7;
783
+ return this.event_run("on_after_load");
784
+ case 7:
785
+ _context19.next = 9;
786
+ return this.event_run("on_load_finished");
787
+ case 9:
788
+ _context19.next = 11;
789
+ return this.checkIsChanged();
790
+ case 11:
791
+ return _context19.abrupt("return", true);
792
+ case 12:
793
+ case "end":
794
+ return _context19.stop();
795
+ }
796
+ }, _callee19, this);
797
+ }));
798
+ function onLoad() {
799
+ return _onLoad.apply(this, arguments);
800
+ }
801
+ return onLoad;
802
+ }()
262
803
  /**
263
804
  * Use this after succesful save to Database
264
805
  * @param p
265
806
  * @returns
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;
807
+ */
808
+ )
809
+ }, {
810
+ key: "onSave",
811
+ value: (function () {
812
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
813
+ var srt;
814
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
815
+ while (1) switch (_context20.prev = _context20.next) {
816
+ case 0:
817
+ srt = this.getSaveResultType();
818
+ _context20.next = 3;
819
+ return this.event_run("on_save", srt);
820
+ case 3:
821
+ _context20.next = 5;
822
+ return this.event_run("on_change", true);
823
+ case 5:
824
+ _context20.next = 7;
825
+ return this.checkIsChanged();
826
+ case 7:
827
+ _context20.next = 9;
828
+ return Promise.resolve(true);
829
+ case 9:
830
+ return _context20.abrupt("return", _context20.sent);
831
+ case 10:
832
+ case "end":
833
+ return _context20.stop();
834
+ }
835
+ }, _callee20, 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 _callee21() {
846
+ var srt;
847
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
848
+ while (1) switch (_context21.prev = _context21.next) {
849
+ case 0:
850
+ srt = this.getSaveResultType();
851
+ _context21.next = 3;
852
+ return this.event_run("on_after_save", srt);
853
+ case 3:
854
+ _context21.next = 5;
855
+ return this.event_run("on_save_finished", srt);
856
+ case 5:
857
+ _context21.next = 7;
858
+ return Promise.resolve(true);
859
+ case 7:
860
+ return _context21.abrupt("return", _context21.sent);
861
+ case 8:
862
+ case "end":
863
+ return _context21.stop();
864
+ }
865
+ }, _callee21, 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;