@azrico/webobject 1.5.67 → 1.5.68
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.
- package/dist/index.js +1 -16
- package/dist/src/WebObjects/ParentWebObject.js +71 -115
- package/dist/src/WebObjects/WebObject.js +584 -1554
- package/dist/src/WebObjects/WebObjectHelper.js +15 -35
- package/dist/src/WebObjects/WebObjectHelper.test.js +45 -67
- package/dist/src/WebObjects/WebObjectManager.js +265 -864
- package/dist/src/WebObjects/WebObjectPathHelper.js +71 -142
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +31 -122
- package/dist/src/index.js +10 -115
- package/dist/src/structs/DummyObject.js +8 -32
- package/dist/src/structs/MapableObject.js +75 -121
- package/dist/src/structs/MetaObject.js +35 -121
- package/dist/src/structs/ObjectArray.js +43 -68
- package/dist/src/structs/ObjectManager.js +285 -744
- package/dist/src/structs/ObjectWithTemp.d.ts +3 -2
- package/dist/src/structs/ObjectWithTemp.js +28 -71
- package/dist/src/structs/SimpleObject.js +1044 -1702
- package/package.json +1 -1
|
@@ -1,211 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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); }
|
|
1
|
+
import { SimpleObject, WebObject } from "../index";
|
|
2
|
+
import ObjectManager from "../structs/ObjectManager";
|
|
3
|
+
import { gfunc } from "@azrico/global";
|
|
4
|
+
import { fn_eval, } from "@azrico/object";
|
|
32
5
|
/**
|
|
33
6
|
* This class manages the events of an Simple Object
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
_context3.next = _context3.t0 === "normal" ? 3 : 6;
|
|
126
|
-
break;
|
|
127
|
-
case 3:
|
|
128
|
-
_context3.next = 5;
|
|
129
|
-
return _global.gfunc.run_action("show_message", {
|
|
130
|
-
message: "Restored",
|
|
131
|
-
type: "success"
|
|
132
|
-
});
|
|
133
|
-
case 5:
|
|
134
|
-
return _context3.abrupt("return", _context3.sent);
|
|
135
|
-
case 6:
|
|
136
|
-
_context3.next = 8;
|
|
137
|
-
return _global.gfunc.run_action("show_message", {
|
|
138
|
-
message: "Not restored (".concat(srType, ")"),
|
|
139
|
-
type: "error"
|
|
140
|
-
});
|
|
141
|
-
case 8:
|
|
142
|
-
return _context3.abrupt("return", _context3.sent);
|
|
143
|
-
case 9:
|
|
144
|
-
case "end":
|
|
145
|
-
return _context3.stop();
|
|
146
|
-
}
|
|
147
|
-
}, _callee3);
|
|
148
|
-
}));
|
|
149
|
-
return function (_x3) {
|
|
150
|
-
return _ref3.apply(this, arguments);
|
|
151
|
-
};
|
|
152
|
-
}());
|
|
153
|
-
_this.event_add("on_delete", "on_delete-sendmsg", /*#__PURE__*/function () {
|
|
154
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(srType) {
|
|
155
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
156
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
157
|
-
case 0:
|
|
158
|
-
_context4.t0 = srType;
|
|
159
|
-
_context4.next = _context4.t0 === "normal" ? 3 : 6;
|
|
160
|
-
break;
|
|
161
|
-
case 3:
|
|
162
|
-
_context4.next = 5;
|
|
163
|
-
return _global.gfunc.run_action("show_message", {
|
|
164
|
-
message: "Deleted",
|
|
165
|
-
type: "success"
|
|
166
|
-
});
|
|
167
|
-
case 5:
|
|
168
|
-
return _context4.abrupt("return", _context4.sent);
|
|
169
|
-
case 6:
|
|
170
|
-
_context4.next = 8;
|
|
171
|
-
return _global.gfunc.run_action("show_message", {
|
|
172
|
-
message: "Not deleted (".concat(srType, ")"),
|
|
173
|
-
type: "error"
|
|
174
|
-
});
|
|
175
|
-
case 8:
|
|
176
|
-
return _context4.abrupt("return", _context4.sent);
|
|
177
|
-
case 9:
|
|
178
|
-
case "end":
|
|
179
|
-
return _context4.stop();
|
|
180
|
-
}
|
|
181
|
-
}, _callee4);
|
|
182
|
-
}));
|
|
183
|
-
return function (_x4) {
|
|
184
|
-
return _ref4.apply(this, arguments);
|
|
185
|
-
};
|
|
186
|
-
}());
|
|
187
|
-
}
|
|
188
|
-
return _this;
|
|
189
|
-
}
|
|
190
|
-
/* -------------------------------------------------------------------------- */
|
|
191
|
-
_inherits(WebObjectManager, _ObjectManager);
|
|
192
|
-
return _createClass(WebObjectManager, [{
|
|
193
|
-
key: "setObject",
|
|
194
|
-
value: function setObject(toObj) {
|
|
195
|
-
var res = _superPropGet(WebObjectManager, "setObject", this, 3)([toObj]);
|
|
196
|
-
if (this.__currentObject && this.__currentObject instanceof _index.SimpleObject) {
|
|
197
|
-
var checkKeys = ["__web_path", "__db_name", "__object_name"];
|
|
198
|
-
for (var index = 0; index < checkKeys.length; index++) {
|
|
199
|
-
var k = checkKeys[index];
|
|
200
|
-
if (!this.__last_object_data) this.__last_object_data = {};
|
|
201
|
-
if (this.__currentObject[k] != null) this.__last_object_data[k] = this.__currentObject[k];
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return res;
|
|
205
|
-
}
|
|
206
|
-
/* -------------------------------------------------------------------------- */
|
|
207
|
-
/* Meta data */
|
|
208
|
-
/* -------------------------------------------------------------------------- */
|
|
7
|
+
*/
|
|
8
|
+
export class WebObjectManager extends ObjectManager {
|
|
9
|
+
static __object_type;
|
|
10
|
+
static __save_message = true;
|
|
11
|
+
/* -------------------------------------------------------------------------- */
|
|
12
|
+
constructor(defaultObject) {
|
|
13
|
+
super(defaultObject);
|
|
14
|
+
if (this.constructor["__save_message"]) {
|
|
15
|
+
/* ---------------- should we display a message after saving ? -------------- */
|
|
16
|
+
this.event_add("on_save", "on_save-sendmsg", async (srt) => {
|
|
17
|
+
switch (srt) {
|
|
18
|
+
case "nothing":
|
|
19
|
+
return await gfunc.run_action("show_message", {
|
|
20
|
+
message: "Nothing to save",
|
|
21
|
+
type: "info",
|
|
22
|
+
});
|
|
23
|
+
case "normal":
|
|
24
|
+
return await gfunc.run_action("show_message", {
|
|
25
|
+
message: "Saved",
|
|
26
|
+
type: "success",
|
|
27
|
+
});
|
|
28
|
+
default:
|
|
29
|
+
return await gfunc.run_action("show_message", {
|
|
30
|
+
message: "Not saved",
|
|
31
|
+
type: "error",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
this.event_add("on_archive", "on_archive-sendmsg", async (srType) => {
|
|
36
|
+
switch (srType) {
|
|
37
|
+
case "normal":
|
|
38
|
+
return await gfunc.run_action("show_message", {
|
|
39
|
+
message: "Archived",
|
|
40
|
+
type: "success",
|
|
41
|
+
});
|
|
42
|
+
default:
|
|
43
|
+
return await gfunc.run_action("show_message", {
|
|
44
|
+
message: `Not archived (${srType})`,
|
|
45
|
+
type: "error",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
this.event_add("on_unarchive", "on_unarchive-sendmsg", async (srType) => {
|
|
50
|
+
switch (srType) {
|
|
51
|
+
case "normal":
|
|
52
|
+
return await gfunc.run_action("show_message", {
|
|
53
|
+
message: "Restored",
|
|
54
|
+
type: "success",
|
|
55
|
+
});
|
|
56
|
+
default:
|
|
57
|
+
return await gfunc.run_action("show_message", {
|
|
58
|
+
message: `Not restored (${srType})`,
|
|
59
|
+
type: "error",
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.event_add("on_delete", "on_delete-sendmsg", async (srType) => {
|
|
64
|
+
switch (srType) {
|
|
65
|
+
case "normal":
|
|
66
|
+
return await gfunc.run_action("show_message", {
|
|
67
|
+
message: "Deleted",
|
|
68
|
+
type: "success",
|
|
69
|
+
});
|
|
70
|
+
default:
|
|
71
|
+
return await gfunc.run_action("show_message", {
|
|
72
|
+
message: `Not deleted (${srType})`,
|
|
73
|
+
type: "error",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/* -------------------------------------------------------------------------- */
|
|
80
|
+
setObject(toObj) {
|
|
81
|
+
const res = super.setObject(toObj);
|
|
82
|
+
if (this.__currentObject &&
|
|
83
|
+
this.__currentObject instanceof SimpleObject) {
|
|
84
|
+
const checkKeys = ["__web_path", "__db_name", "__object_name"];
|
|
85
|
+
for (let index = 0; index < checkKeys.length; index++) {
|
|
86
|
+
const k = checkKeys[index];
|
|
87
|
+
if (!this.__last_object_data)
|
|
88
|
+
this.__last_object_data = {};
|
|
89
|
+
if (this.__currentObject[k] != null)
|
|
90
|
+
this.__last_object_data[k] = this.__currentObject[k];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
/* -------------------------------------------------------------------------- */
|
|
96
|
+
/* Meta data */
|
|
97
|
+
/* -------------------------------------------------------------------------- */
|
|
209
98
|
/**
|
|
210
99
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
211
100
|
* @param key
|
|
@@ -213,677 +102,189 @@ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_Object
|
|
|
213
102
|
* @param createIfNotExists should we create a new meta if key does not exist
|
|
214
103
|
* @param sendChange
|
|
215
104
|
* @returns
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
/* -------------------------------------------------------------------------- */
|
|
105
|
+
*/
|
|
106
|
+
async setMetaValue(key, value, sendChange = "auto") {
|
|
107
|
+
return await this.obj?.setMetaValue(key, value, sendChange);
|
|
108
|
+
}
|
|
109
|
+
getMetaValue(key) {
|
|
110
|
+
return this.obj?.getMetaValue(key);
|
|
111
|
+
}
|
|
112
|
+
/* -------------------------------------------------------------------------- */
|
|
113
|
+
async get_deltaObject() {
|
|
114
|
+
return (await this.obj?.get_deltaObject()) || {};
|
|
115
|
+
}
|
|
116
|
+
/* ------------------------------ save and load ----------------------------- */
|
|
117
|
+
async Save() {
|
|
118
|
+
return (await this.obj?.Save()) || false;
|
|
119
|
+
}
|
|
120
|
+
async New() {
|
|
121
|
+
const cls = this.getObjectType();
|
|
122
|
+
this.setObject(new cls());
|
|
123
|
+
await this.onNew();
|
|
124
|
+
}
|
|
125
|
+
async Delete() {
|
|
126
|
+
return (await this.obj?.Delete()) || false;
|
|
127
|
+
}
|
|
128
|
+
async Lock() {
|
|
129
|
+
return (await this.obj?.Lock()) || false;
|
|
130
|
+
}
|
|
131
|
+
async UnLock() {
|
|
132
|
+
return (await this.obj?.UnLock()) || false;
|
|
133
|
+
}
|
|
134
|
+
async Archive() {
|
|
135
|
+
return (await this.obj?.Archive()) || false;
|
|
136
|
+
}
|
|
137
|
+
async UnArchive() {
|
|
138
|
+
return (await this.obj?.UnArchive()) || false;
|
|
139
|
+
}
|
|
140
|
+
/* -------------------------------------------------------------------------- */
|
|
141
|
+
async Load(id, ...p) {
|
|
142
|
+
if (!id)
|
|
143
|
+
return;
|
|
144
|
+
try {
|
|
145
|
+
this.event_run("on_process_start", true);
|
|
146
|
+
const classType = this.getObjectType();
|
|
147
|
+
if (!classType) {
|
|
148
|
+
console.error("[webobjectmanager]", "getObjectType failed to get the object_type.", "did you set the __object_type correctly ?");
|
|
149
|
+
}
|
|
150
|
+
const result_product = await classType.get_single(id, false);
|
|
151
|
+
if (result_product &&
|
|
152
|
+
typeof result_product === "object" &&
|
|
153
|
+
WebObject.getID(result_product)) {
|
|
154
|
+
this.setObject(result_product);
|
|
155
|
+
await result_product.onLoad();
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
console.error("badobject:", id, result_product);
|
|
159
|
+
WebObject.addError(this.obj, `Invalid ${this.__object_name}`, `The loaded ${this.__object_name} from website is invalid`, true);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
this.event_run("on_process_end", true);
|
|
164
|
+
}
|
|
165
|
+
return this.getObject();
|
|
166
|
+
}
|
|
167
|
+
/* -------------------------------------------------------------------------- */
|
|
168
|
+
/* Child Functions */
|
|
169
|
+
/* -------------------------------------------------------------------------- */
|
|
170
|
+
get __web_path() {
|
|
171
|
+
return this.__getObjectData(["__web_path", "__db_name"]);
|
|
172
|
+
}
|
|
173
|
+
get __db_name() {
|
|
174
|
+
return this.__getObjectData(["__db_name", "__web_path"]);
|
|
175
|
+
}
|
|
176
|
+
get __object_name() {
|
|
177
|
+
return this.__getObjectData(["__object_name", "__db_name"]);
|
|
178
|
+
}
|
|
179
|
+
get_webpath() {
|
|
180
|
+
return this.__getObjectData(["__web_path", "__db_name"]);
|
|
181
|
+
}
|
|
182
|
+
__getObjectData(checkKeys) {
|
|
183
|
+
const objtype = this.getObjectType();
|
|
184
|
+
for (let index = 0; index < checkKeys.length; index++) {
|
|
185
|
+
const k = checkKeys[index];
|
|
186
|
+
const v = this.obj?.[k] || this.__last_object_data[k] || objtype?.[k];
|
|
187
|
+
if (v)
|
|
188
|
+
return v;
|
|
189
|
+
}
|
|
190
|
+
return "";
|
|
191
|
+
}
|
|
192
|
+
/* -------------------------------------------------------------------------- */
|
|
193
|
+
/* Default Events */
|
|
194
|
+
/* -------------------------------------------------------------------------- */
|
|
576
195
|
/**
|
|
577
196
|
* Use this when you delete Object
|
|
578
197
|
* @param p
|
|
579
198
|
* @returns
|
|
580
|
-
*/
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
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
|
-
}()
|
|
199
|
+
*/
|
|
200
|
+
async onDelete(...p) {
|
|
201
|
+
const srt = this.getSaveResultType();
|
|
202
|
+
await this.event_run("on_delete", srt);
|
|
203
|
+
await this.event_run("on_after_delete", srt);
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
async onArchive(...p) {
|
|
207
|
+
const srt = this.getSaveResultType();
|
|
208
|
+
await this.event_run("on_archive", srt);
|
|
209
|
+
await this.event_run("on_after_archive", srt);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
async onUnArchive(...p) {
|
|
213
|
+
const srt = this.getSaveResultType();
|
|
214
|
+
await this.event_run("on_unarchive", srt);
|
|
215
|
+
await this.event_run("on_after_unarchive", srt);
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
async onLock(...p) {
|
|
219
|
+
const srt = this.getSaveResultType();
|
|
220
|
+
await this.event_run("on_lock", srt);
|
|
221
|
+
await this.event_run("on_after_lock", srt);
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
async onUnLock(...p) {
|
|
225
|
+
const srt = this.getSaveResultType();
|
|
226
|
+
await this.event_run("on_unlock", srt);
|
|
227
|
+
await this.event_run("on_after_unlock", srt);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
716
230
|
/**
|
|
717
231
|
* Use this when you load new Object
|
|
718
232
|
* @param p
|
|
719
233
|
* @returns
|
|
720
|
-
*/
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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
|
-
}()
|
|
234
|
+
*/
|
|
235
|
+
async onNew(...p) {
|
|
236
|
+
if (this.canModify) {
|
|
237
|
+
this.obj?.setOriginal();
|
|
238
|
+
}
|
|
239
|
+
await this.event_run("on_new");
|
|
240
|
+
await this.event_run("on_change", true);
|
|
241
|
+
await this.event_run("on_after_new");
|
|
242
|
+
await this.checkIsChanged();
|
|
243
|
+
return await Promise.resolve(true);
|
|
244
|
+
}
|
|
759
245
|
/**
|
|
760
246
|
* Use this when you load data to the object
|
|
761
247
|
* @param p
|
|
762
248
|
* @returns
|
|
763
|
-
*/
|
|
764
|
-
)
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
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
|
-
}()
|
|
249
|
+
*/
|
|
250
|
+
async onLoad(...p) {
|
|
251
|
+
if (this.canModify && this.obj) {
|
|
252
|
+
this.obj.isDeleted = false;
|
|
253
|
+
this.obj.setOriginal();
|
|
254
|
+
}
|
|
255
|
+
await this.event_run("on_load");
|
|
256
|
+
await this.event_run("on_change", true);
|
|
257
|
+
await this.event_run("on_after_load");
|
|
258
|
+
await this.event_run("on_load_finished");
|
|
259
|
+
await this.checkIsChanged();
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
803
262
|
/**
|
|
804
263
|
* Use this after succesful save to Database
|
|
805
264
|
* @param p
|
|
806
265
|
* @returns
|
|
807
|
-
*/
|
|
808
|
-
)
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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;
|
|
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;
|