@azrico/webobject 1.5.15 → 1.5.17

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,210 @@
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(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); }
5
31
  /**
6
32
  * 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
- /* -------------------------------------------------------------------------- */
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
+ /* -------------------------------------------------------------------------- */
98
208
  /**
99
209
  * Update meta value of this object , meta data is stored in meta_data variable
100
210
  * @param key
@@ -102,184 +212,677 @@ export class WebObjectManager extends ObjectManager {
102
212
  * @param createIfNotExists should we create a new meta if key does not exist
103
213
  * @param sendChange
104
214
  * @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 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
- /* -------------------------------------------------------------------------- */
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: "New",
311
+ value: function () {
312
+ var _New = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
313
+ var cls;
314
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
315
+ while (1) switch (_context8.prev = _context8.next) {
316
+ case 0:
317
+ cls = this.getObjectType();
318
+ this.setObject(new cls());
319
+ _context8.next = 4;
320
+ return this.onNew();
321
+ case 4:
322
+ case "end":
323
+ return _context8.stop();
324
+ }
325
+ }, _callee8, this);
326
+ }));
327
+ function New() {
328
+ return _New.apply(this, arguments);
329
+ }
330
+ return New;
331
+ }()
332
+ }, {
333
+ key: "Delete",
334
+ value: function () {
335
+ var _Delete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
336
+ var _this$obj5;
337
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
338
+ while (1) switch (_context9.prev = _context9.next) {
339
+ case 0:
340
+ _context9.next = 2;
341
+ return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.Delete();
342
+ case 2:
343
+ _context9.t0 = _context9.sent;
344
+ if (_context9.t0) {
345
+ _context9.next = 5;
346
+ break;
347
+ }
348
+ _context9.t0 = false;
349
+ case 5:
350
+ return _context9.abrupt("return", _context9.t0);
351
+ case 6:
352
+ case "end":
353
+ return _context9.stop();
354
+ }
355
+ }, _callee9, this);
356
+ }));
357
+ function Delete() {
358
+ return _Delete.apply(this, arguments);
359
+ }
360
+ return Delete;
361
+ }()
362
+ }, {
363
+ key: "Lock",
364
+ value: function () {
365
+ var _Lock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
366
+ var _this$obj6;
367
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
368
+ while (1) switch (_context10.prev = _context10.next) {
369
+ case 0:
370
+ _context10.next = 2;
371
+ return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.Lock();
372
+ case 2:
373
+ _context10.t0 = _context10.sent;
374
+ if (_context10.t0) {
375
+ _context10.next = 5;
376
+ break;
377
+ }
378
+ _context10.t0 = false;
379
+ case 5:
380
+ return _context10.abrupt("return", _context10.t0);
381
+ case 6:
382
+ case "end":
383
+ return _context10.stop();
384
+ }
385
+ }, _callee10, this);
386
+ }));
387
+ function Lock() {
388
+ return _Lock.apply(this, arguments);
389
+ }
390
+ return Lock;
391
+ }()
392
+ }, {
393
+ key: "UnLock",
394
+ value: function () {
395
+ var _UnLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
396
+ var _this$obj7;
397
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
398
+ while (1) switch (_context11.prev = _context11.next) {
399
+ case 0:
400
+ _context11.next = 2;
401
+ return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.UnLock();
402
+ case 2:
403
+ _context11.t0 = _context11.sent;
404
+ if (_context11.t0) {
405
+ _context11.next = 5;
406
+ break;
407
+ }
408
+ _context11.t0 = false;
409
+ case 5:
410
+ return _context11.abrupt("return", _context11.t0);
411
+ case 6:
412
+ case "end":
413
+ return _context11.stop();
414
+ }
415
+ }, _callee11, this);
416
+ }));
417
+ function UnLock() {
418
+ return _UnLock.apply(this, arguments);
419
+ }
420
+ return UnLock;
421
+ }()
422
+ }, {
423
+ key: "Archive",
424
+ value: function () {
425
+ var _Archive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
426
+ var _this$obj8;
427
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
428
+ while (1) switch (_context12.prev = _context12.next) {
429
+ case 0:
430
+ _context12.next = 2;
431
+ return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.Archive();
432
+ case 2:
433
+ _context12.t0 = _context12.sent;
434
+ if (_context12.t0) {
435
+ _context12.next = 5;
436
+ break;
437
+ }
438
+ _context12.t0 = false;
439
+ case 5:
440
+ return _context12.abrupt("return", _context12.t0);
441
+ case 6:
442
+ case "end":
443
+ return _context12.stop();
444
+ }
445
+ }, _callee12, this);
446
+ }));
447
+ function Archive() {
448
+ return _Archive.apply(this, arguments);
449
+ }
450
+ return Archive;
451
+ }()
452
+ }, {
453
+ key: "UnArchive",
454
+ value: function () {
455
+ var _UnArchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
456
+ var _this$obj9;
457
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
458
+ while (1) switch (_context13.prev = _context13.next) {
459
+ case 0:
460
+ _context13.next = 2;
461
+ return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.UnArchive();
462
+ case 2:
463
+ _context13.t0 = _context13.sent;
464
+ if (_context13.t0) {
465
+ _context13.next = 5;
466
+ break;
467
+ }
468
+ _context13.t0 = false;
469
+ case 5:
470
+ return _context13.abrupt("return", _context13.t0);
471
+ case 6:
472
+ case "end":
473
+ return _context13.stop();
474
+ }
475
+ }, _callee13, this);
476
+ }));
477
+ function UnArchive() {
478
+ return _UnArchive.apply(this, arguments);
479
+ }
480
+ return UnArchive;
481
+ }() /* -------------------------------------------------------------------------- */
482
+ }, {
483
+ key: "Load",
484
+ value: (function () {
485
+ var _Load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(id) {
486
+ var classType, result_product;
487
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
488
+ while (1) switch (_context14.prev = _context14.next) {
489
+ case 0:
490
+ if (id) {
491
+ _context14.next = 2;
492
+ break;
493
+ }
494
+ return _context14.abrupt("return");
495
+ case 2:
496
+ _context14.prev = 2;
497
+ this.event_run("on_process_start", true);
498
+ classType = this.getObjectType();
499
+ if (!classType) {
500
+ console.error("[webobjectmanager]", "getObjectType failed to get the object_type.", "did you set the __object_type correctly ?");
501
+ }
502
+ _context14.next = 8;
503
+ return classType.get_single(id, false);
504
+ case 8:
505
+ result_product = _context14.sent;
506
+ if (!(result_product && _typeof(result_product) === "object" && _index.WebObject.getID(result_product))) {
507
+ _context14.next = 15;
508
+ break;
509
+ }
510
+ this.setObject(result_product);
511
+ _context14.next = 13;
512
+ return result_product.onLoad();
513
+ case 13:
514
+ _context14.next = 17;
515
+ break;
516
+ case 15:
517
+ console.error("badobject:", id, result_product);
518
+ _index.WebObject.addError(this.obj, "Invalid ".concat(this.__object_name), "The loaded ".concat(this.__object_name, " from website is invalid"), true);
519
+ case 17:
520
+ _context14.prev = 17;
521
+ this.event_run("on_process_end", true);
522
+ return _context14.finish(17);
523
+ case 20:
524
+ return _context14.abrupt("return", this.getObject());
525
+ case 21:
526
+ case "end":
527
+ return _context14.stop();
528
+ }
529
+ }, _callee14, this, [[2,, 17, 20]]);
530
+ }));
531
+ function Load(_x7) {
532
+ return _Load.apply(this, arguments);
533
+ }
534
+ return Load;
535
+ }()
536
+ /* -------------------------------------------------------------------------- */
537
+ /* Child Functions */
538
+ /* -------------------------------------------------------------------------- */
539
+ )
540
+ }, {
541
+ key: "__web_path",
542
+ get: function get() {
543
+ return this.__getObjectData(["__web_path", "__db_name"]);
544
+ }
545
+ }, {
546
+ key: "__db_name",
547
+ get: function get() {
548
+ return this.__getObjectData(["__db_name", "__web_path"]);
549
+ }
550
+ }, {
551
+ key: "__object_name",
552
+ get: function get() {
553
+ return this.__getObjectData(["__object_name", "__db_name"]);
554
+ }
555
+ }, {
556
+ key: "get_webpath",
557
+ value: function get_webpath() {
558
+ return this.__getObjectData(["__web_path", "__db_name"]);
559
+ }
560
+ }, {
561
+ key: "__getObjectData",
562
+ value: function __getObjectData(checkKeys) {
563
+ var objtype = this.getObjectType();
564
+ for (var index = 0; index < checkKeys.length; index++) {
565
+ var _this$obj10;
566
+ var k = checkKeys[index];
567
+ 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]);
568
+ if (v) return v;
569
+ }
570
+ return "";
571
+ }
572
+ /* -------------------------------------------------------------------------- */
573
+ /* Default Events */
574
+ /* -------------------------------------------------------------------------- */
190
575
  /**
191
576
  * Use this when you delete Object
192
577
  * @param p
193
578
  * @returns
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
- }
579
+ */
580
+ }, {
581
+ key: "onDelete",
582
+ value: (function () {
583
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
584
+ var srt;
585
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
586
+ while (1) switch (_context15.prev = _context15.next) {
587
+ case 0:
588
+ srt = this.getSaveResultType();
589
+ _context15.next = 3;
590
+ return this.event_run("on_delete", srt);
591
+ case 3:
592
+ _context15.next = 5;
593
+ return this.event_run("on_after_delete", srt);
594
+ case 5:
595
+ return _context15.abrupt("return", true);
596
+ case 6:
597
+ case "end":
598
+ return _context15.stop();
599
+ }
600
+ }, _callee15, this);
601
+ }));
602
+ function onDelete() {
603
+ return _onDelete.apply(this, arguments);
604
+ }
605
+ return onDelete;
606
+ }())
607
+ }, {
608
+ key: "onArchive",
609
+ value: function () {
610
+ var _onArchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
611
+ var srt;
612
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
613
+ while (1) switch (_context16.prev = _context16.next) {
614
+ case 0:
615
+ srt = this.getSaveResultType();
616
+ _context16.next = 3;
617
+ return this.event_run("on_archive", srt);
618
+ case 3:
619
+ _context16.next = 5;
620
+ return this.event_run("on_after_archive", srt);
621
+ case 5:
622
+ return _context16.abrupt("return", true);
623
+ case 6:
624
+ case "end":
625
+ return _context16.stop();
626
+ }
627
+ }, _callee16, this);
628
+ }));
629
+ function onArchive() {
630
+ return _onArchive.apply(this, arguments);
631
+ }
632
+ return onArchive;
633
+ }()
634
+ }, {
635
+ key: "onUnArchive",
636
+ value: function () {
637
+ var _onUnArchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
638
+ var srt;
639
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
640
+ while (1) switch (_context17.prev = _context17.next) {
641
+ case 0:
642
+ srt = this.getSaveResultType();
643
+ _context17.next = 3;
644
+ return this.event_run("on_unarchive", srt);
645
+ case 3:
646
+ _context17.next = 5;
647
+ return this.event_run("on_after_unarchive", srt);
648
+ case 5:
649
+ return _context17.abrupt("return", true);
650
+ case 6:
651
+ case "end":
652
+ return _context17.stop();
653
+ }
654
+ }, _callee17, this);
655
+ }));
656
+ function onUnArchive() {
657
+ return _onUnArchive.apply(this, arguments);
658
+ }
659
+ return onUnArchive;
660
+ }()
661
+ }, {
662
+ key: "onLock",
663
+ value: function () {
664
+ var _onLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
665
+ var srt;
666
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
667
+ while (1) switch (_context18.prev = _context18.next) {
668
+ case 0:
669
+ srt = this.getSaveResultType();
670
+ _context18.next = 3;
671
+ return this.event_run("on_lock", srt);
672
+ case 3:
673
+ _context18.next = 5;
674
+ return this.event_run("on_after_lock", srt);
675
+ case 5:
676
+ return _context18.abrupt("return", true);
677
+ case 6:
678
+ case "end":
679
+ return _context18.stop();
680
+ }
681
+ }, _callee18, this);
682
+ }));
683
+ function onLock() {
684
+ return _onLock.apply(this, arguments);
685
+ }
686
+ return onLock;
687
+ }()
688
+ }, {
689
+ key: "onUnLock",
690
+ value: function () {
691
+ var _onUnLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
692
+ var srt;
693
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
694
+ while (1) switch (_context19.prev = _context19.next) {
695
+ case 0:
696
+ srt = this.getSaveResultType();
697
+ _context19.next = 3;
698
+ return this.event_run("on_unlock", srt);
699
+ case 3:
700
+ _context19.next = 5;
701
+ return this.event_run("on_after_unlock", srt);
702
+ case 5:
703
+ return _context19.abrupt("return", true);
704
+ case 6:
705
+ case "end":
706
+ return _context19.stop();
707
+ }
708
+ }, _callee19, this);
709
+ }));
710
+ function onUnLock() {
711
+ return _onUnLock.apply(this, arguments);
712
+ }
713
+ return onUnLock;
714
+ }()
225
715
  /**
226
716
  * Use this when you load new Object
227
717
  * @param p
228
718
  * @returns
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
- }
719
+ */
720
+ }, {
721
+ key: "onNew",
722
+ value: (function () {
723
+ var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
724
+ var _this$obj11;
725
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
726
+ while (1) switch (_context20.prev = _context20.next) {
727
+ case 0:
728
+ if (this.canModify) {
729
+ (_this$obj11 = this.obj) === null || _this$obj11 === void 0 || _this$obj11.setOriginal();
730
+ }
731
+ _context20.next = 3;
732
+ return this.event_run("on_new");
733
+ case 3:
734
+ _context20.next = 5;
735
+ return this.event_run("on_change", true);
736
+ case 5:
737
+ _context20.next = 7;
738
+ return this.event_run("on_after_new");
739
+ case 7:
740
+ _context20.next = 9;
741
+ return this.checkIsChanged();
742
+ case 9:
743
+ _context20.next = 11;
744
+ return Promise.resolve(true);
745
+ case 11:
746
+ return _context20.abrupt("return", _context20.sent);
747
+ case 12:
748
+ case "end":
749
+ return _context20.stop();
750
+ }
751
+ }, _callee20, this);
752
+ }));
753
+ function onNew() {
754
+ return _onNew.apply(this, arguments);
755
+ }
756
+ return onNew;
757
+ }()
240
758
  /**
241
759
  * Use this when you load data to the object
242
760
  * @param p
243
761
  * @returns
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
- }
762
+ */
763
+ )
764
+ }, {
765
+ key: "onLoad",
766
+ value: (function () {
767
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
768
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
769
+ while (1) switch (_context21.prev = _context21.next) {
770
+ case 0:
771
+ if (this.canModify && this.obj) {
772
+ this.obj.isDeleted = false;
773
+ this.obj.setOriginal();
774
+ }
775
+ _context21.next = 3;
776
+ return this.event_run("on_load");
777
+ case 3:
778
+ _context21.next = 5;
779
+ return this.event_run("on_change", true);
780
+ case 5:
781
+ _context21.next = 7;
782
+ return this.event_run("on_after_load");
783
+ case 7:
784
+ _context21.next = 9;
785
+ return this.event_run("on_load_finished");
786
+ case 9:
787
+ _context21.next = 11;
788
+ return this.checkIsChanged();
789
+ case 11:
790
+ return _context21.abrupt("return", true);
791
+ case 12:
792
+ case "end":
793
+ return _context21.stop();
794
+ }
795
+ }, _callee21, this);
796
+ }));
797
+ function onLoad() {
798
+ return _onLoad.apply(this, arguments);
799
+ }
800
+ return onLoad;
801
+ }()
257
802
  /**
258
803
  * Use this after succesful save to Database
259
804
  * @param p
260
805
  * @returns
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;
806
+ */
807
+ )
808
+ }, {
809
+ key: "onSave",
810
+ value: (function () {
811
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
812
+ var srt;
813
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
814
+ while (1) switch (_context22.prev = _context22.next) {
815
+ case 0:
816
+ srt = this.getSaveResultType();
817
+ _context22.next = 3;
818
+ return this.event_run("on_save", srt);
819
+ case 3:
820
+ _context22.next = 5;
821
+ return this.event_run("on_change", true);
822
+ case 5:
823
+ _context22.next = 7;
824
+ return this.checkIsChanged();
825
+ case 7:
826
+ _context22.next = 9;
827
+ return Promise.resolve(true);
828
+ case 9:
829
+ return _context22.abrupt("return", _context22.sent);
830
+ case 10:
831
+ case "end":
832
+ return _context22.stop();
833
+ }
834
+ }, _callee22, this);
835
+ }));
836
+ function onSave() {
837
+ return _onSave.apply(this, arguments);
838
+ }
839
+ return onSave;
840
+ }())
841
+ }, {
842
+ key: "onAfterSave",
843
+ value: function () {
844
+ var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
845
+ var srt;
846
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
847
+ while (1) switch (_context23.prev = _context23.next) {
848
+ case 0:
849
+ srt = this.getSaveResultType();
850
+ _context23.next = 3;
851
+ return this.event_run("on_after_save", srt);
852
+ case 3:
853
+ _context23.next = 5;
854
+ return this.event_run("on_save_finished", srt);
855
+ case 5:
856
+ _context23.next = 7;
857
+ return Promise.resolve(true);
858
+ case 7:
859
+ return _context23.abrupt("return", _context23.sent);
860
+ case 8:
861
+ case "end":
862
+ return _context23.stop();
863
+ }
864
+ }, _callee23, this);
865
+ }));
866
+ function onAfterSave() {
867
+ return _onAfterSave.apply(this, arguments);
868
+ }
869
+ return onAfterSave;
870
+ }()
871
+ /* -------------------------------------------------------------------------- */
872
+ /* get __object_type */
873
+ /* -------------------------------------------------------------------------- */
874
+ }, {
875
+ key: "getObjectType",
876
+ value: function getObjectType() {
877
+ return this.constructor["getObjectType"]();
878
+ }
879
+ }], [{
880
+ key: "getObjectType",
881
+ value: function getObjectType() {
882
+ return (0, _object.fn_eval)(this.__object_type);
883
+ }
884
+ }]);
885
+ }(_ObjectManager2["default"]);
886
+ _defineProperty(WebObjectManager, "__object_type", void 0);
887
+ _defineProperty(WebObjectManager, "__save_message", true);
888
+ var _default = exports["default"] = WebObjectManager;