@azrico/webobject 1.4.129 → 1.4.130

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,96 +1,207 @@
1
- import { SimpleObject } from "../index";
2
- import ObjectManager from "../structs/ObjectManager";
3
- import { gfunc } from "@azrico/global";
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
+ 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 _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
19
+ 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); }
20
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
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 _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); }
23
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
24
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
25
+ 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); }
26
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
29
+ 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); }
4
30
  /**
5
31
  * This class manages the events of an Simple Object
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
- /* -------------------------------------------------------------------------- */
32
+ */
33
+ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
34
+ _inherits(WebObjectManager, _ObjectManager);
35
+ /* -------------------------------------------------------------------------- */
36
+ function WebObjectManager() {
37
+ var _this;
38
+ _classCallCheck(this, WebObjectManager);
39
+ _this = _callSuper(this, WebObjectManager);
40
+ /* ---------------- should we display a message after saving ? -------------- */
41
+ _defineProperty(_assertThisInitialized(_this), "__last_web_path", "");
42
+ _defineProperty(_assertThisInitialized(_this), "__last_web_type", "");
43
+ if (_this.constructor["__save_message"]) {
44
+ _this.event_add("on_save", "on_save-sendmsg", /*#__PURE__*/function () {
45
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(srt) {
46
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
47
+ while (1) switch (_context.prev = _context.next) {
48
+ case 0:
49
+ _context.t0 = srt;
50
+ _context.next = _context.t0 === "nothing" ? 3 : _context.t0 === "normal" ? 6 : 9;
51
+ break;
52
+ case 3:
53
+ _context.next = 5;
54
+ return _global.gfunc.run_action("show_message", {
55
+ message: "Nothing to save",
56
+ type: "info"
57
+ });
58
+ case 5:
59
+ return _context.abrupt("return", _context.sent);
60
+ case 6:
61
+ _context.next = 8;
62
+ return _global.gfunc.run_action("show_message", {
63
+ message: "Saved",
64
+ type: "success"
65
+ });
66
+ case 8:
67
+ return _context.abrupt("return", _context.sent);
68
+ case 9:
69
+ _context.next = 11;
70
+ return _global.gfunc.run_action("show_message", {
71
+ message: "Not saved",
72
+ type: "error"
73
+ });
74
+ case 11:
75
+ return _context.abrupt("return", _context.sent);
76
+ case 12:
77
+ case "end":
78
+ return _context.stop();
79
+ }
80
+ }, _callee);
81
+ }));
82
+ return function (_x) {
83
+ return _ref.apply(this, arguments);
84
+ };
85
+ }());
86
+ _this.event_add("on_archive", "on_archive-sendmsg", /*#__PURE__*/function () {
87
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(srType) {
88
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
+ while (1) switch (_context2.prev = _context2.next) {
90
+ case 0:
91
+ _context2.t0 = srType;
92
+ _context2.next = _context2.t0 === "normal" ? 3 : 6;
93
+ break;
94
+ case 3:
95
+ _context2.next = 5;
96
+ return _global.gfunc.run_action("show_message", {
97
+ message: "Archived",
98
+ type: "success"
99
+ });
100
+ case 5:
101
+ return _context2.abrupt("return", _context2.sent);
102
+ case 6:
103
+ _context2.next = 8;
104
+ return _global.gfunc.run_action("show_message", {
105
+ message: "Not archived (".concat(srType, ")"),
106
+ type: "error"
107
+ });
108
+ case 8:
109
+ return _context2.abrupt("return", _context2.sent);
110
+ case 9:
111
+ case "end":
112
+ return _context2.stop();
113
+ }
114
+ }, _callee2);
115
+ }));
116
+ return function (_x2) {
117
+ return _ref2.apply(this, arguments);
118
+ };
119
+ }());
120
+ _this.event_add("on_unarchive", "on_unarchive-sendmsg", /*#__PURE__*/function () {
121
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(srType) {
122
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
123
+ while (1) switch (_context3.prev = _context3.next) {
124
+ case 0:
125
+ _context3.t0 = srType;
126
+ _context3.next = _context3.t0 === "normal" ? 3 : 6;
127
+ break;
128
+ case 3:
129
+ _context3.next = 5;
130
+ return _global.gfunc.run_action("show_message", {
131
+ message: "Restored",
132
+ type: "success"
133
+ });
134
+ case 5:
135
+ return _context3.abrupt("return", _context3.sent);
136
+ case 6:
137
+ _context3.next = 8;
138
+ return _global.gfunc.run_action("show_message", {
139
+ message: "Not restored (".concat(srType, ")"),
140
+ type: "error"
141
+ });
142
+ case 8:
143
+ return _context3.abrupt("return", _context3.sent);
144
+ case 9:
145
+ case "end":
146
+ return _context3.stop();
147
+ }
148
+ }, _callee3);
149
+ }));
150
+ return function (_x3) {
151
+ return _ref3.apply(this, arguments);
152
+ };
153
+ }());
154
+ _this.event_add("on_delete", "on_delete-sendmsg", /*#__PURE__*/function () {
155
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(srType) {
156
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
157
+ while (1) switch (_context4.prev = _context4.next) {
158
+ case 0:
159
+ _context4.t0 = srType;
160
+ _context4.next = _context4.t0 === "normal" ? 3 : 6;
161
+ break;
162
+ case 3:
163
+ _context4.next = 5;
164
+ return _global.gfunc.run_action("show_message", {
165
+ message: "Deleted",
166
+ type: "success"
167
+ });
168
+ case 5:
169
+ return _context4.abrupt("return", _context4.sent);
170
+ case 6:
171
+ _context4.next = 8;
172
+ return _global.gfunc.run_action("show_message", {
173
+ message: "Not deleted (".concat(srType, ")"),
174
+ type: "error"
175
+ });
176
+ case 8:
177
+ return _context4.abrupt("return", _context4.sent);
178
+ case 9:
179
+ case "end":
180
+ return _context4.stop();
181
+ }
182
+ }, _callee4);
183
+ }));
184
+ return function (_x4) {
185
+ return _ref4.apply(this, arguments);
186
+ };
187
+ }());
188
+ }
189
+ return _this;
190
+ }
191
+ /* -------------------------------------------------------------------------- */
192
+ _createClass(WebObjectManager, [{
193
+ key: "setObject",
194
+ value: function setObject(toObj) {
195
+ var res = _get(_getPrototypeOf(WebObjectManager.prototype), "setObject", this).call(this, toObj);
196
+ if (this.__currentObject instanceof _index.SimpleObject) {
197
+ this.__last_web_path == this.__currentObject.__web_path || this.__last_web_path;
198
+ this.__last_web_type == this.__currentObject.__web_type || this.__last_web_type;
199
+ }
200
+ return res;
201
+ }
202
+ /* -------------------------------------------------------------------------- */
203
+ /* Meta data */
204
+ /* -------------------------------------------------------------------------- */
94
205
  /**
95
206
  * Update meta value of this object , meta data is stored in meta_data variable
96
207
  * @param key
@@ -98,122 +209,380 @@ export class WebObjectManager extends ObjectManager {
98
209
  * @param createIfNotExists should we create a new meta if key does not exist
99
210
  * @param sendChange
100
211
  * @returns
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
- /* -------------------------------------------------------------------------- */
212
+ */
213
+ }, {
214
+ key: "setMetaValue",
215
+ value: (function () {
216
+ var _setMetaValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
217
+ var _this$obj;
218
+ var sendChange,
219
+ _args5 = arguments;
220
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
221
+ while (1) switch (_context5.prev = _context5.next) {
222
+ case 0:
223
+ sendChange = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : "auto";
224
+ _context5.next = 3;
225
+ return (_this$obj = this.obj) === null || _this$obj === void 0 ? void 0 : _this$obj.setMetaValue(key, value, sendChange);
226
+ case 3:
227
+ return _context5.abrupt("return", _context5.sent);
228
+ case 4:
229
+ case "end":
230
+ return _context5.stop();
231
+ }
232
+ }, _callee5, this);
233
+ }));
234
+ function setMetaValue(_x5, _x6) {
235
+ return _setMetaValue.apply(this, arguments);
236
+ }
237
+ return setMetaValue;
238
+ }())
239
+ }, {
240
+ key: "getMetaValue",
241
+ value: function getMetaValue(key) {
242
+ var _this$obj2;
243
+ return (_this$obj2 = this.obj) === null || _this$obj2 === void 0 ? void 0 : _this$obj2.getMetaValue(key);
244
+ }
245
+ /* -------------------------------------------------------------------------- */
246
+ }, {
247
+ key: "get_deltaObject",
248
+ value: (function () {
249
+ var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
250
+ var _this$obj3;
251
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
252
+ while (1) switch (_context6.prev = _context6.next) {
253
+ case 0:
254
+ _context6.next = 2;
255
+ return (_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.get_deltaObject();
256
+ case 2:
257
+ _context6.t0 = _context6.sent;
258
+ if (_context6.t0) {
259
+ _context6.next = 5;
260
+ break;
261
+ }
262
+ _context6.t0 = {};
263
+ case 5:
264
+ return _context6.abrupt("return", _context6.t0);
265
+ case 6:
266
+ case "end":
267
+ return _context6.stop();
268
+ }
269
+ }, _callee6, this);
270
+ }));
271
+ function get_deltaObject() {
272
+ return _get_deltaObject.apply(this, arguments);
273
+ }
274
+ return get_deltaObject;
275
+ }() /* ------------------------------ save and load ----------------------------- */)
276
+ }, {
277
+ key: "Save",
278
+ value: (function () {
279
+ var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
280
+ var _this$obj4;
281
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
282
+ while (1) switch (_context7.prev = _context7.next) {
283
+ case 0:
284
+ _context7.next = 2;
285
+ return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.Save();
286
+ case 2:
287
+ _context7.t0 = _context7.sent;
288
+ if (_context7.t0) {
289
+ _context7.next = 5;
290
+ break;
291
+ }
292
+ _context7.t0 = false;
293
+ case 5:
294
+ return _context7.abrupt("return", _context7.t0);
295
+ case 6:
296
+ case "end":
297
+ return _context7.stop();
298
+ }
299
+ }, _callee7, this);
300
+ }));
301
+ function Save() {
302
+ return _Save.apply(this, arguments);
303
+ }
304
+ return Save;
305
+ }())
306
+ }, {
307
+ key: "Load",
308
+ value: function () {
309
+ var _Load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(search) {
310
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
311
+ while (1) switch (_context8.prev = _context8.next) {
312
+ case 0:
313
+ throw Error("load not implented");
314
+ case 1:
315
+ case "end":
316
+ return _context8.stop();
317
+ }
318
+ }, _callee8);
319
+ }));
320
+ function Load(_x7) {
321
+ return _Load.apply(this, arguments);
322
+ }
323
+ return Load;
324
+ }()
325
+ /* -------------------------------------------------------------------------- */
326
+ /* Child Functions */
327
+ /* -------------------------------------------------------------------------- */
328
+ }, {
329
+ key: "__web_path",
330
+ get: function get() {
331
+ var _this$obj5, _this$constructor$__o, _this$obj6, _this$constructor$__o2;
332
+ 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
333
+ (_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 || "";
334
+ }
335
+ }, {
336
+ key: "__web_type",
337
+ get: function get() {
338
+ var _this$obj7, _this$constructor$__o3, _this$obj8, _this$constructor$__o4;
339
+ 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
340
+ (_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 || "";
341
+ }
342
+ }, {
343
+ key: "get_webname",
344
+ value: function get_webname() {
345
+ return this.__web_path || this.__web_type || this.__cache_name || "";
346
+ }
347
+ /* -------------------------------------------------------------------------- */
348
+ /* Default Events */
349
+ /* -------------------------------------------------------------------------- */
148
350
  /**
149
351
  * Use this when you load new Object
150
352
  * @param p
151
353
  * @returns
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
- }
354
+ */
355
+ }, {
356
+ key: "onNew",
357
+ value: (function () {
358
+ var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
359
+ var _this$obj9;
360
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
361
+ while (1) switch (_context9.prev = _context9.next) {
362
+ case 0:
363
+ if (this.canModify) {
364
+ (_this$obj9 = this.obj) === null || _this$obj9 === void 0 || _this$obj9.setOriginal();
365
+ }
366
+ _context9.next = 3;
367
+ return this.event_run("on_new");
368
+ case 3:
369
+ _context9.next = 5;
370
+ return this.event_run("on_change", true);
371
+ case 5:
372
+ _context9.next = 7;
373
+ return this.event_run("on_after_new");
374
+ case 7:
375
+ _context9.next = 9;
376
+ return Promise.resolve(true);
377
+ case 9:
378
+ return _context9.abrupt("return", _context9.sent);
379
+ case 10:
380
+ case "end":
381
+ return _context9.stop();
382
+ }
383
+ }, _callee9, this);
384
+ }));
385
+ function onNew() {
386
+ return _onNew.apply(this, arguments);
387
+ }
388
+ return onNew;
389
+ }()
162
390
  /**
163
391
  * Use this when you delete Object
164
392
  * @param p
165
393
  * @returns
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
- }
394
+ */
395
+ )
396
+ }, {
397
+ key: "onDelete",
398
+ value: (function () {
399
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
400
+ var srt;
401
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
402
+ while (1) switch (_context10.prev = _context10.next) {
403
+ case 0:
404
+ srt = this.getSaveResultType();
405
+ _context10.next = 3;
406
+ return this.event_run("on_delete", srt);
407
+ case 3:
408
+ _context10.next = 5;
409
+ return this.event_run("on_after_delete", srt);
410
+ case 5:
411
+ return _context10.abrupt("return", true);
412
+ case 6:
413
+ case "end":
414
+ return _context10.stop();
415
+ }
416
+ }, _callee10, this);
417
+ }));
418
+ function onDelete() {
419
+ return _onDelete.apply(this, arguments);
420
+ }
421
+ return onDelete;
422
+ }())
423
+ }, {
424
+ key: "onArchive",
425
+ value: function () {
426
+ var _onArchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
427
+ var srt;
428
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
429
+ while (1) switch (_context11.prev = _context11.next) {
430
+ case 0:
431
+ srt = this.getSaveResultType();
432
+ _context11.next = 3;
433
+ return this.event_run("on_archive", srt);
434
+ case 3:
435
+ _context11.next = 5;
436
+ return this.event_run("on_after_archive", srt);
437
+ case 5:
438
+ return _context11.abrupt("return", true);
439
+ case 6:
440
+ case "end":
441
+ return _context11.stop();
442
+ }
443
+ }, _callee11, this);
444
+ }));
445
+ function onArchive() {
446
+ return _onArchive.apply(this, arguments);
447
+ }
448
+ return onArchive;
449
+ }()
450
+ }, {
451
+ key: "onUnArchive",
452
+ value: function () {
453
+ var _onUnArchive = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
454
+ var srt;
455
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
456
+ while (1) switch (_context12.prev = _context12.next) {
457
+ case 0:
458
+ srt = this.getSaveResultType();
459
+ _context12.next = 3;
460
+ return this.event_run("on_unarchive", srt);
461
+ case 3:
462
+ _context12.next = 5;
463
+ return this.event_run("on_after_unarchive", srt);
464
+ case 5:
465
+ return _context12.abrupt("return", true);
466
+ case 6:
467
+ case "end":
468
+ return _context12.stop();
469
+ }
470
+ }, _callee12, this);
471
+ }));
472
+ function onUnArchive() {
473
+ return _onUnArchive.apply(this, arguments);
474
+ }
475
+ return onUnArchive;
476
+ }()
185
477
  /**
186
478
  * Use this when you load data to the object
187
479
  * @param p
188
480
  * @returns
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
- }
481
+ */
482
+ }, {
483
+ key: "onLoad",
484
+ value: (function () {
485
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
486
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
487
+ while (1) switch (_context13.prev = _context13.next) {
488
+ case 0:
489
+ if (this.canModify && this.obj) {
490
+ this.obj.isDeleted = false;
491
+ this.obj.setOriginal();
492
+ }
493
+ _context13.next = 3;
494
+ return this.event_run("on_load");
495
+ case 3:
496
+ _context13.next = 5;
497
+ return this.event_run("on_change", true);
498
+ case 5:
499
+ _context13.next = 7;
500
+ return this.event_run("on_after_load");
501
+ case 7:
502
+ _context13.next = 9;
503
+ return this.event_run("on_load_finished");
504
+ case 9:
505
+ return _context13.abrupt("return", true);
506
+ case 10:
507
+ case "end":
508
+ return _context13.stop();
509
+ }
510
+ }, _callee13, this);
511
+ }));
512
+ function onLoad() {
513
+ return _onLoad.apply(this, arguments);
514
+ }
515
+ return onLoad;
516
+ }()
201
517
  /**
202
518
  * Use this after succesful save to Database
203
519
  * @param p
204
520
  * @returns
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;
521
+ */
522
+ )
523
+ }, {
524
+ key: "onSave",
525
+ value: (function () {
526
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
527
+ var srt;
528
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
529
+ while (1) switch (_context14.prev = _context14.next) {
530
+ case 0:
531
+ srt = this.getSaveResultType();
532
+ _context14.next = 3;
533
+ return this.event_run("on_save", srt);
534
+ case 3:
535
+ _context14.next = 5;
536
+ return this.event_run("on_change", true);
537
+ case 5:
538
+ _context14.next = 7;
539
+ return Promise.resolve(true);
540
+ case 7:
541
+ return _context14.abrupt("return", _context14.sent);
542
+ case 8:
543
+ case "end":
544
+ return _context14.stop();
545
+ }
546
+ }, _callee14, this);
547
+ }));
548
+ function onSave() {
549
+ return _onSave.apply(this, arguments);
550
+ }
551
+ return onSave;
552
+ }())
553
+ }, {
554
+ key: "onAfterSave",
555
+ value: function () {
556
+ var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
557
+ var srt;
558
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
559
+ while (1) switch (_context15.prev = _context15.next) {
560
+ case 0:
561
+ srt = this.getSaveResultType();
562
+ _context15.next = 3;
563
+ return this.event_run("on_after_save", srt);
564
+ case 3:
565
+ _context15.next = 5;
566
+ return this.event_run("on_save_finished", srt);
567
+ case 5:
568
+ _context15.next = 7;
569
+ return Promise.resolve(true);
570
+ case 7:
571
+ return _context15.abrupt("return", _context15.sent);
572
+ case 8:
573
+ case "end":
574
+ return _context15.stop();
575
+ }
576
+ }, _callee15, this);
577
+ }));
578
+ function onAfterSave() {
579
+ return _onAfterSave.apply(this, arguments);
580
+ }
581
+ return onAfterSave;
582
+ }()
583
+ }]);
584
+ return WebObjectManager;
585
+ }(_ObjectManager2["default"]);
586
+ _defineProperty(WebObjectManager, "__object_type", void 0);
587
+ _defineProperty(WebObjectManager, "__save_message", true);
588
+ var _default = exports["default"] = WebObjectManager;