@azrico/webobject 1.4.127 → 1.4.129
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/README.md +9 -9
- package/dist/index.js +1 -16
- package/dist/src/WebObjects/ParentWebObject.js +20 -51
- package/dist/src/WebObjects/WebObject.js +452 -1032
- package/dist/src/WebObjects/WebObjectManager.js +194 -509
- package/dist/src/index.js +9 -104
- package/dist/src/structs/DummyObject.js +8 -35
- package/dist/src/structs/MapableObject.js +76 -126
- package/dist/src/structs/MetaObject.js +35 -113
- package/dist/src/structs/ObjectArray.js +43 -71
- package/dist/src/structs/ObjectManager.d.ts +2 -2
- package/dist/src/structs/ObjectManager.js +252 -648
- package/dist/src/structs/ObjectWithTemp.js +25 -65
- package/dist/src/structs/SimpleObject.d.ts +5 -6
- package/dist/src/structs/SimpleObject.js +890 -1396
- package/package.json +4 -4
|
@@ -1,197 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
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); }
|
|
12
|
-
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 new 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 new 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 new 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; }
|
|
13
|
-
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); } }
|
|
14
|
-
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); }); }; }
|
|
15
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
-
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); } }
|
|
17
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
-
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); }
|
|
19
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
20
|
-
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); }
|
|
21
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
23
|
-
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); }
|
|
24
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
-
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; }
|
|
28
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
29
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
1
|
+
import { SimpleObject } from "../index";
|
|
2
|
+
import ObjectManager from "../structs/ObjectManager";
|
|
3
|
+
import { gfunc } from "@azrico/global";
|
|
30
4
|
/**
|
|
31
5
|
* This class manages the events of an Simple Object
|
|
32
|
-
*/
|
|
33
|
-
|
|
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
|
-
case 0:
|
|
121
|
-
_context3.t0 = srType;
|
|
122
|
-
_context3.next = _context3.t0 === "normal" ? 3 : 6;
|
|
123
|
-
break;
|
|
124
|
-
case 3:
|
|
125
|
-
_context3.next = 5;
|
|
126
|
-
return _global.gfunc.run_action("show_message", {
|
|
127
|
-
message: "Restored",
|
|
128
|
-
type: "success"
|
|
129
|
-
});
|
|
130
|
-
case 5:
|
|
131
|
-
return _context3.abrupt("return", _context3.sent);
|
|
132
|
-
case 6:
|
|
133
|
-
_context3.next = 8;
|
|
134
|
-
return _global.gfunc.run_action("show_message", {
|
|
135
|
-
message: "Not restored (".concat(srType, ")"),
|
|
136
|
-
type: "error"
|
|
137
|
-
});
|
|
138
|
-
case 8:
|
|
139
|
-
return _context3.abrupt("return", _context3.sent);
|
|
140
|
-
case 9:
|
|
141
|
-
case "end":
|
|
142
|
-
return _context3.stop();
|
|
143
|
-
}
|
|
144
|
-
}, _callee3);
|
|
145
|
-
}))).apply(this, arguments);
|
|
146
|
-
});
|
|
147
|
-
_this.event_add("on_delete", "on_delete-sendmsg", function (_x4) {
|
|
148
|
-
return (_ref4 = _ref4 || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(srType) {
|
|
149
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
150
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
151
|
-
case 0:
|
|
152
|
-
_context4.t0 = srType;
|
|
153
|
-
_context4.next = _context4.t0 === "normal" ? 3 : 6;
|
|
154
|
-
break;
|
|
155
|
-
case 3:
|
|
156
|
-
_context4.next = 5;
|
|
157
|
-
return _global.gfunc.run_action("show_message", {
|
|
158
|
-
message: "Deleted",
|
|
159
|
-
type: "success"
|
|
160
|
-
});
|
|
161
|
-
case 5:
|
|
162
|
-
return _context4.abrupt("return", _context4.sent);
|
|
163
|
-
case 6:
|
|
164
|
-
_context4.next = 8;
|
|
165
|
-
return _global.gfunc.run_action("show_message", {
|
|
166
|
-
message: "Not deleted (".concat(srType, ")"),
|
|
167
|
-
type: "error"
|
|
168
|
-
});
|
|
169
|
-
case 8:
|
|
170
|
-
return _context4.abrupt("return", _context4.sent);
|
|
171
|
-
case 9:
|
|
172
|
-
case "end":
|
|
173
|
-
return _context4.stop();
|
|
174
|
-
}
|
|
175
|
-
}, _callee4);
|
|
176
|
-
}))).apply(this, arguments);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
return _this;
|
|
180
|
-
}
|
|
181
|
-
/* -------------------------------------------------------------------------- */
|
|
182
|
-
_createClass(WebObjectManager, [{
|
|
183
|
-
key: "setObject",
|
|
184
|
-
value: function setObject(toObj) {
|
|
185
|
-
var res = _get(_getPrototypeOf(WebObjectManager.prototype), "setObject", this).call(this, toObj);
|
|
186
|
-
if (this.__currentObject instanceof _index.SimpleObject) {
|
|
187
|
-
this.__last_web_path == this.__currentObject.__web_path || this.__last_web_path;
|
|
188
|
-
this.__last_web_type == this.__currentObject.__web_type || this.__last_web_type;
|
|
189
|
-
}
|
|
190
|
-
return res;
|
|
191
|
-
}
|
|
192
|
-
/* -------------------------------------------------------------------------- */
|
|
193
|
-
/* Meta data */
|
|
194
|
-
/* -------------------------------------------------------------------------- */
|
|
6
|
+
*/
|
|
7
|
+
export class WebObjectManager extends ObjectManager {
|
|
8
|
+
static __object_type;
|
|
9
|
+
static __save_message = true;
|
|
10
|
+
__last_web_path = "";
|
|
11
|
+
__last_web_type = "";
|
|
12
|
+
/* -------------------------------------------------------------------------- */
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
/* ---------------- should we display a message after saving ? -------------- */
|
|
16
|
+
if (this.constructor["__save_message"]) {
|
|
17
|
+
this.event_add("on_save", "on_save-sendmsg", async (srt) => {
|
|
18
|
+
switch (srt) {
|
|
19
|
+
case "nothing":
|
|
20
|
+
return await gfunc.run_action("show_message", {
|
|
21
|
+
message: "Nothing to save",
|
|
22
|
+
type: "info",
|
|
23
|
+
});
|
|
24
|
+
case "normal":
|
|
25
|
+
return await gfunc.run_action("show_message", {
|
|
26
|
+
message: "Saved",
|
|
27
|
+
type: "success",
|
|
28
|
+
});
|
|
29
|
+
default:
|
|
30
|
+
return await gfunc.run_action("show_message", {
|
|
31
|
+
message: "Not saved",
|
|
32
|
+
type: "error",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
this.event_add("on_archive", "on_archive-sendmsg", async (srType) => {
|
|
37
|
+
switch (srType) {
|
|
38
|
+
case "normal":
|
|
39
|
+
return await gfunc.run_action("show_message", {
|
|
40
|
+
message: "Archived",
|
|
41
|
+
type: "success",
|
|
42
|
+
});
|
|
43
|
+
default:
|
|
44
|
+
return await gfunc.run_action("show_message", {
|
|
45
|
+
message: `Not archived (${srType})`,
|
|
46
|
+
type: "error",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
this.event_add("on_unarchive", "on_unarchive-sendmsg", async (srType) => {
|
|
51
|
+
switch (srType) {
|
|
52
|
+
case "normal":
|
|
53
|
+
return await gfunc.run_action("show_message", {
|
|
54
|
+
message: "Restored",
|
|
55
|
+
type: "success",
|
|
56
|
+
});
|
|
57
|
+
default:
|
|
58
|
+
return await gfunc.run_action("show_message", {
|
|
59
|
+
message: `Not restored (${srType})`,
|
|
60
|
+
type: "error",
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
this.event_add("on_delete", "on_delete-sendmsg", async (srType) => {
|
|
65
|
+
switch (srType) {
|
|
66
|
+
case "normal":
|
|
67
|
+
return await gfunc.run_action("show_message", {
|
|
68
|
+
message: "Deleted",
|
|
69
|
+
type: "success",
|
|
70
|
+
});
|
|
71
|
+
default:
|
|
72
|
+
return await gfunc.run_action("show_message", {
|
|
73
|
+
message: `Not deleted (${srType})`,
|
|
74
|
+
type: "error",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/* -------------------------------------------------------------------------- */
|
|
81
|
+
setObject(toObj) {
|
|
82
|
+
const res = super.setObject(toObj);
|
|
83
|
+
if (this.__currentObject instanceof SimpleObject) {
|
|
84
|
+
this.__last_web_path == this.__currentObject.__web_path ||
|
|
85
|
+
this.__last_web_path;
|
|
86
|
+
this.__last_web_type == this.__currentObject.__web_type ||
|
|
87
|
+
this.__last_web_type;
|
|
88
|
+
}
|
|
89
|
+
return res;
|
|
90
|
+
}
|
|
91
|
+
/* -------------------------------------------------------------------------- */
|
|
92
|
+
/* Meta data */
|
|
93
|
+
/* -------------------------------------------------------------------------- */
|
|
195
94
|
/**
|
|
196
95
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
197
96
|
* @param key
|
|
@@ -199,336 +98,122 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
|
|
|
199
98
|
* @param createIfNotExists should we create a new meta if key does not exist
|
|
200
99
|
* @param sendChange
|
|
201
100
|
* @returns
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
case 5:
|
|
250
|
-
return _context6.abrupt("return", _context6.t0);
|
|
251
|
-
case 6:
|
|
252
|
-
case "end":
|
|
253
|
-
return _context6.stop();
|
|
254
|
-
}
|
|
255
|
-
}, _callee6, this);
|
|
256
|
-
}))).apply(this, arguments);
|
|
257
|
-
} /* ------------------------------ save and load ----------------------------- */
|
|
258
|
-
}, {
|
|
259
|
-
key: "Save",
|
|
260
|
-
value: function Save() {
|
|
261
|
-
return (_Save = _Save || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
262
|
-
var _this$obj4;
|
|
263
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
264
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
265
|
-
case 0:
|
|
266
|
-
_context7.next = 2;
|
|
267
|
-
return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.Save();
|
|
268
|
-
case 2:
|
|
269
|
-
_context7.t0 = _context7.sent;
|
|
270
|
-
if (_context7.t0) {
|
|
271
|
-
_context7.next = 5;
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
_context7.t0 = false;
|
|
275
|
-
case 5:
|
|
276
|
-
return _context7.abrupt("return", _context7.t0);
|
|
277
|
-
case 6:
|
|
278
|
-
case "end":
|
|
279
|
-
return _context7.stop();
|
|
280
|
-
}
|
|
281
|
-
}, _callee7, this);
|
|
282
|
-
}))).apply(this, arguments);
|
|
283
|
-
}
|
|
284
|
-
}, {
|
|
285
|
-
key: "Load",
|
|
286
|
-
value: function Load(_x7) {
|
|
287
|
-
return (_Load = _Load || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(search) {
|
|
288
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
289
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
290
|
-
case 0:
|
|
291
|
-
throw Error("load not implented");
|
|
292
|
-
case 1:
|
|
293
|
-
case "end":
|
|
294
|
-
return _context8.stop();
|
|
295
|
-
}
|
|
296
|
-
}, _callee8);
|
|
297
|
-
}))).apply(this, arguments);
|
|
298
|
-
}
|
|
299
|
-
/* -------------------------------------------------------------------------- */
|
|
300
|
-
/* Child Functions */
|
|
301
|
-
/* -------------------------------------------------------------------------- */
|
|
302
|
-
}, {
|
|
303
|
-
key: "__web_path",
|
|
304
|
-
get: function get() {
|
|
305
|
-
var _this$obj5, _this$constructor$__o, _this$obj6, _this$constructor$__o2;
|
|
306
|
-
return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.__web_path) || ((_this$constructor$__o = this.constructor["__object_type"]) === null || _this$constructor$__o === void 0 ? void 0 : _this$constructor$__o.__web_path) || this.__last_web_path || ( //alternative
|
|
307
|
-
(_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.__web_type) || ((_this$constructor$__o2 = this.constructor["__object_type"]) === null || _this$constructor$__o2 === void 0 ? void 0 : _this$constructor$__o2.__web_type) || this.__last_web_type || "";
|
|
308
|
-
}
|
|
309
|
-
}, {
|
|
310
|
-
key: "__web_type",
|
|
311
|
-
get: function get() {
|
|
312
|
-
var _this$obj7, _this$constructor$__o3, _this$obj8, _this$constructor$__o4;
|
|
313
|
-
return ((_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.__web_type) || ((_this$constructor$__o3 = this.constructor["__object_type"]) === null || _this$constructor$__o3 === void 0 ? void 0 : _this$constructor$__o3.__web_type) || this.__last_web_type || ( //alternative
|
|
314
|
-
(_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.__web_path) || ((_this$constructor$__o4 = this.constructor["__object_type"]) === null || _this$constructor$__o4 === void 0 ? void 0 : _this$constructor$__o4.__web_path) || this.__last_web_path || "";
|
|
315
|
-
}
|
|
316
|
-
}, {
|
|
317
|
-
key: "get_webname",
|
|
318
|
-
value: function get_webname() {
|
|
319
|
-
return this.__web_path || this.__web_type || this.__cache_name || "";
|
|
320
|
-
}
|
|
321
|
-
/* -------------------------------------------------------------------------- */
|
|
322
|
-
/* Default Events */
|
|
323
|
-
/* -------------------------------------------------------------------------- */
|
|
101
|
+
*/
|
|
102
|
+
async setMetaValue(key, value, sendChange = "auto") {
|
|
103
|
+
return await this.obj?.setMetaValue(key, value, sendChange);
|
|
104
|
+
}
|
|
105
|
+
getMetaValue(key) {
|
|
106
|
+
return this.obj?.getMetaValue(key);
|
|
107
|
+
}
|
|
108
|
+
/* -------------------------------------------------------------------------- */
|
|
109
|
+
async get_deltaObject() {
|
|
110
|
+
return (await this.obj?.get_deltaObject()) || {};
|
|
111
|
+
}
|
|
112
|
+
/* ------------------------------ save and load ----------------------------- */
|
|
113
|
+
async Save() {
|
|
114
|
+
return (await this.obj?.Save()) || false;
|
|
115
|
+
}
|
|
116
|
+
async Load(search, ...p) {
|
|
117
|
+
throw Error("load not implented");
|
|
118
|
+
}
|
|
119
|
+
/* -------------------------------------------------------------------------- */
|
|
120
|
+
/* Child Functions */
|
|
121
|
+
/* -------------------------------------------------------------------------- */
|
|
122
|
+
get __web_path() {
|
|
123
|
+
return (this.obj?.__web_path ||
|
|
124
|
+
this.constructor["__object_type"]?.__web_path ||
|
|
125
|
+
this.__last_web_path ||
|
|
126
|
+
//alternative
|
|
127
|
+
this.obj?.__web_type ||
|
|
128
|
+
this.constructor["__object_type"]?.__web_type ||
|
|
129
|
+
this.__last_web_type ||
|
|
130
|
+
"");
|
|
131
|
+
}
|
|
132
|
+
get __web_type() {
|
|
133
|
+
return (this.obj?.__web_type ||
|
|
134
|
+
this.constructor["__object_type"]?.__web_type ||
|
|
135
|
+
this.__last_web_type ||
|
|
136
|
+
//alternative
|
|
137
|
+
this.obj?.__web_path ||
|
|
138
|
+
this.constructor["__object_type"]?.__web_path ||
|
|
139
|
+
this.__last_web_path ||
|
|
140
|
+
"");
|
|
141
|
+
}
|
|
142
|
+
get_webname() {
|
|
143
|
+
return this.__web_path || this.__web_type || this.__cache_name || "";
|
|
144
|
+
}
|
|
145
|
+
/* -------------------------------------------------------------------------- */
|
|
146
|
+
/* Default Events */
|
|
147
|
+
/* -------------------------------------------------------------------------- */
|
|
324
148
|
/**
|
|
325
149
|
* Use this when you load new Object
|
|
326
150
|
* @param p
|
|
327
151
|
* @returns
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
(_this$obj9 = this.obj) === null || _this$obj9 === void 0 || _this$obj9.setOriginal();
|
|
339
|
-
}
|
|
340
|
-
_context9.next = 3;
|
|
341
|
-
return this.event_run("on_new");
|
|
342
|
-
case 3:
|
|
343
|
-
_context9.next = 5;
|
|
344
|
-
return this.event_run("on_change", true);
|
|
345
|
-
case 5:
|
|
346
|
-
_context9.next = 7;
|
|
347
|
-
return this.event_run("on_after_new");
|
|
348
|
-
case 7:
|
|
349
|
-
_context9.next = 9;
|
|
350
|
-
return Promise.resolve(true);
|
|
351
|
-
case 9:
|
|
352
|
-
return _context9.abrupt("return", _context9.sent);
|
|
353
|
-
case 10:
|
|
354
|
-
case "end":
|
|
355
|
-
return _context9.stop();
|
|
356
|
-
}
|
|
357
|
-
}, _callee9, this);
|
|
358
|
-
}))).apply(this, arguments);
|
|
359
|
-
}
|
|
152
|
+
*/
|
|
153
|
+
async onNew(...p) {
|
|
154
|
+
if (this.canModify) {
|
|
155
|
+
this.obj?.setOriginal();
|
|
156
|
+
}
|
|
157
|
+
await this.event_run("on_new");
|
|
158
|
+
await this.event_run("on_change", true);
|
|
159
|
+
await this.event_run("on_after_new");
|
|
160
|
+
return await Promise.resolve(true);
|
|
161
|
+
}
|
|
360
162
|
/**
|
|
361
163
|
* Use this when you delete Object
|
|
362
164
|
* @param p
|
|
363
165
|
* @returns
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return _context10.stop();
|
|
384
|
-
}
|
|
385
|
-
}, _callee10, this);
|
|
386
|
-
}))).apply(this, arguments);
|
|
387
|
-
}
|
|
388
|
-
}, {
|
|
389
|
-
key: "onArchive",
|
|
390
|
-
value: function onArchive() {
|
|
391
|
-
return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
392
|
-
var srt;
|
|
393
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
394
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
395
|
-
case 0:
|
|
396
|
-
srt = this.getSaveResultType();
|
|
397
|
-
_context11.next = 3;
|
|
398
|
-
return this.event_run("on_archive", srt);
|
|
399
|
-
case 3:
|
|
400
|
-
_context11.next = 5;
|
|
401
|
-
return this.event_run("on_after_archive", srt);
|
|
402
|
-
case 5:
|
|
403
|
-
return _context11.abrupt("return", true);
|
|
404
|
-
case 6:
|
|
405
|
-
case "end":
|
|
406
|
-
return _context11.stop();
|
|
407
|
-
}
|
|
408
|
-
}, _callee11, this);
|
|
409
|
-
}))).apply(this, arguments);
|
|
410
|
-
}
|
|
411
|
-
}, {
|
|
412
|
-
key: "onUnArchive",
|
|
413
|
-
value: function onUnArchive() {
|
|
414
|
-
return (_onUnArchive = _onUnArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
415
|
-
var srt;
|
|
416
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
417
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
418
|
-
case 0:
|
|
419
|
-
srt = this.getSaveResultType();
|
|
420
|
-
_context12.next = 3;
|
|
421
|
-
return this.event_run("on_unarchive", srt);
|
|
422
|
-
case 3:
|
|
423
|
-
_context12.next = 5;
|
|
424
|
-
return this.event_run("on_after_unarchive", srt);
|
|
425
|
-
case 5:
|
|
426
|
-
return _context12.abrupt("return", true);
|
|
427
|
-
case 6:
|
|
428
|
-
case "end":
|
|
429
|
-
return _context12.stop();
|
|
430
|
-
}
|
|
431
|
-
}, _callee12, this);
|
|
432
|
-
}))).apply(this, arguments);
|
|
433
|
-
}
|
|
166
|
+
*/
|
|
167
|
+
async onDelete(...p) {
|
|
168
|
+
const srt = this.getSaveResultType();
|
|
169
|
+
await this.event_run("on_delete", srt);
|
|
170
|
+
await this.event_run("on_after_delete", srt);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
async onArchive(...p) {
|
|
174
|
+
const srt = this.getSaveResultType();
|
|
175
|
+
await this.event_run("on_archive", srt);
|
|
176
|
+
await this.event_run("on_after_archive", srt);
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
async onUnArchive(...p) {
|
|
180
|
+
const srt = this.getSaveResultType();
|
|
181
|
+
await this.event_run("on_unarchive", srt);
|
|
182
|
+
await this.event_run("on_after_unarchive", srt);
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
434
185
|
/**
|
|
435
186
|
* Use this when you load data to the object
|
|
436
187
|
* @param p
|
|
437
188
|
* @returns
|
|
438
|
-
*/
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
_context13.next = 3;
|
|
451
|
-
return this.event_run("on_load");
|
|
452
|
-
case 3:
|
|
453
|
-
_context13.next = 5;
|
|
454
|
-
return this.event_run("on_change", true);
|
|
455
|
-
case 5:
|
|
456
|
-
_context13.next = 7;
|
|
457
|
-
return this.event_run("on_after_load");
|
|
458
|
-
case 7:
|
|
459
|
-
_context13.next = 9;
|
|
460
|
-
return this.event_run("on_load_finished");
|
|
461
|
-
case 9:
|
|
462
|
-
return _context13.abrupt("return", true);
|
|
463
|
-
case 10:
|
|
464
|
-
case "end":
|
|
465
|
-
return _context13.stop();
|
|
466
|
-
}
|
|
467
|
-
}, _callee13, this);
|
|
468
|
-
}))).apply(this, arguments);
|
|
469
|
-
}
|
|
189
|
+
*/
|
|
190
|
+
async onLoad(...p) {
|
|
191
|
+
if (this.canModify && this.obj) {
|
|
192
|
+
this.obj.isDeleted = false;
|
|
193
|
+
this.obj.setOriginal();
|
|
194
|
+
}
|
|
195
|
+
await this.event_run("on_load");
|
|
196
|
+
await this.event_run("on_change", true);
|
|
197
|
+
await this.event_run("on_after_load");
|
|
198
|
+
await this.event_run("on_load_finished");
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
470
201
|
/**
|
|
471
202
|
* Use this after succesful save to Database
|
|
472
203
|
* @param p
|
|
473
204
|
* @returns
|
|
474
|
-
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
case 5:
|
|
490
|
-
_context14.next = 7;
|
|
491
|
-
return Promise.resolve(true);
|
|
492
|
-
case 7:
|
|
493
|
-
return _context14.abrupt("return", _context14.sent);
|
|
494
|
-
case 8:
|
|
495
|
-
case "end":
|
|
496
|
-
return _context14.stop();
|
|
497
|
-
}
|
|
498
|
-
}, _callee14, this);
|
|
499
|
-
}))).apply(this, arguments);
|
|
500
|
-
}
|
|
501
|
-
}, {
|
|
502
|
-
key: "onAfterSave",
|
|
503
|
-
value: function onAfterSave() {
|
|
504
|
-
return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
505
|
-
var srt;
|
|
506
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
507
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
508
|
-
case 0:
|
|
509
|
-
srt = this.getSaveResultType();
|
|
510
|
-
_context15.next = 3;
|
|
511
|
-
return this.event_run("on_after_save", srt);
|
|
512
|
-
case 3:
|
|
513
|
-
_context15.next = 5;
|
|
514
|
-
return this.event_run("on_save_finished", srt);
|
|
515
|
-
case 5:
|
|
516
|
-
_context15.next = 7;
|
|
517
|
-
return Promise.resolve(true);
|
|
518
|
-
case 7:
|
|
519
|
-
return _context15.abrupt("return", _context15.sent);
|
|
520
|
-
case 8:
|
|
521
|
-
case "end":
|
|
522
|
-
return _context15.stop();
|
|
523
|
-
}
|
|
524
|
-
}, _callee15, this);
|
|
525
|
-
}))).apply(this, arguments);
|
|
526
|
-
}
|
|
527
|
-
}]);
|
|
528
|
-
return WebObjectManager;
|
|
529
|
-
}(_ObjectManager2["default"]);
|
|
530
|
-
exports.WebObjectManager = WebObjectManager;
|
|
531
|
-
_defineProperty(WebObjectManager, "__object_type", void 0);
|
|
532
|
-
_defineProperty(WebObjectManager, "__save_message", true);
|
|
533
|
-
var _default = WebObjectManager;
|
|
534
|
-
exports["default"] = _default;
|
|
205
|
+
*/
|
|
206
|
+
async onSave(...p) {
|
|
207
|
+
const srt = this.getSaveResultType();
|
|
208
|
+
await this.event_run("on_save", srt);
|
|
209
|
+
await this.event_run("on_change", true);
|
|
210
|
+
return await Promise.resolve(true);
|
|
211
|
+
}
|
|
212
|
+
async onAfterSave(...p) {
|
|
213
|
+
const srt = this.getSaveResultType();
|
|
214
|
+
await this.event_run("on_after_save", srt);
|
|
215
|
+
await this.event_run("on_save_finished", srt);
|
|
216
|
+
return await Promise.resolve(true);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
export default WebObjectManager;
|