@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.
@@ -1,1067 +1,487 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.WebObject = void 0;
7
- var _index3 = require("../index");
8
- var _object = require("@azrico/object");
9
- var _string = require("@azrico/string");
10
- var _global = require("@azrico/global");
11
- var _convert = _interopRequireDefault(require("@azrico/convert"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
- 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); }
14
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
- 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; }
18
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
- 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); } }
21
- 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); }); }; }
22
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
- 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); } }
24
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
25
- 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); }
26
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
27
- 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); }
28
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
- 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); }; }
30
- 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); }
31
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
- 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; } }
33
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
- 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; }
35
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
36
- 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); }
37
- var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Delete, _Archive, _UnArchive, _get_deltaObject, _onDelete, _onArchive, _onUnArchive, _onLoad, _onSave, _onAfterSave, _onNew, _saveList, _get_single, _get_list) {
38
- _inherits(WebObject, _SimpleObject);
39
- var _super = _createSuper(WebObject);
40
- function WebObject() {
41
- var _this;
42
- var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
43
- _classCallCheck(this, WebObject);
44
- _this = _super.call(this, is_readonly);
45
- _defineProperty(_assertThisInitialized(_this), "meta_data", void 0);
46
- _defineProperty(_assertThisInitialized(_this), "_id", "");
47
- _defineProperty(_assertThisInitialized(_this), "_created_date", void 0);
48
- //the owner of the object
49
- _defineProperty(_assertThisInitialized(_this), "_creator", void 0);
50
- //multiple users can work on one object
51
- _defineProperty(_assertThisInitialized(_this), "_users", void 0);
52
- _this.meta_data = {};
53
- return _this;
54
- }
55
- /**
56
- * get a list of all user ids that work on the given object
57
- * _creator + _users + attentions(old)
58
- * removes duplicates
59
- * @returns array of ids
60
- */
61
- _createClass(WebObject, [{
62
- key: "getAllUsers",
63
- value: function getAllUsers() {
64
- return WebObject.getAllUsers(this);
65
- }
1
+ import { SimpleObject } from "../index";
2
+ import { array_chunks, array_merge, array_remove_duplicates, fn_eval_this, object_equals, object_first, object_getStatic, object_isEmpty, wrap_array, } from "@azrico/object";
3
+ import { string_compress, string_decompress } from "@azrico/string";
4
+ import { gfunc } from "@azrico/global";
5
+ import FormatHelper from "@azrico/convert";
6
+ export class WebObject extends SimpleObject {
7
+ static __web_path = "";
8
+ static __web_type = "";
9
+ static __protectedProperties = ["_users"];
10
+ //you cant create a new weboject without these properties
11
+ static __requiredProperties = [];
12
+ meta_data;
13
+ _id = "";
14
+ _created_date;
15
+ //the owner of the object
16
+ _creator;
17
+ //multiple users can work on one object
18
+ _users;
19
+ constructor(is_readonly = false) {
20
+ super(is_readonly);
21
+ this.meta_data = {};
22
+ }
66
23
  /**
67
24
  * get a list of all user ids that work on the given object
68
25
  * _creator + _users + attentions(old)
69
26
  * removes duplicates
70
27
  * @returns array of ids
71
- */
72
- }, {
73
- key: "setMetaValue",
74
- value:
75
- /* -------------------------------------------------------------------------- */
76
- /* Meta data */
77
- /* -------------------------------------------------------------------------- */
28
+ */
29
+ getAllUsers() {
30
+ return WebObject.getAllUsers(this);
31
+ }
32
+ /**
33
+ * get a list of all user ids that work on the given object
34
+ * _creator + _users + attentions(old)
35
+ * removes duplicates
36
+ * @returns array of ids
37
+ */
38
+ static getAllUsers(obj) {
39
+ if (typeof obj != "object")
40
+ return [];
41
+ return array_remove_duplicates(array_merge(obj._creator, wrap_array(obj._users), wrap_array(obj.attentions))
42
+ .map((r) => String(typeof r === "object" ? WebObject.getID(r) : r))
43
+ .filter((s) => s));
44
+ }
45
+ /* -------------------------------------------------------------------------- */
46
+ /* Meta data */
47
+ /* -------------------------------------------------------------------------- */
78
48
  /**
79
49
  * Update meta value of this object , meta data is stored in meta_data variable
80
50
  * @param key
81
51
  * @param value
82
52
  * @param sendChange
83
53
  * @returns
84
- */
85
- function setMetaValue(_x, _x2) {
86
- return (_setMetaValue = _setMetaValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
87
- var sendChange,
88
- old_value,
89
- new_metalist,
90
- _args = arguments;
91
- return _regeneratorRuntime().wrap(function _callee$(_context) {
92
- while (1) switch (_context.prev = _context.next) {
93
- case 0:
94
- sendChange = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
95
- if (this.canModify) {
96
- _context.next = 7;
97
- break;
98
- }
99
- if (!(this.__throw_errors !== false)) {
100
- _context.next = 6;
101
- break;
102
- }
103
- throw Error("Cant use setMetaValue on ".concat(key, " when on readonly mode"));
104
- case 6:
105
- return _context.abrupt("return", false);
106
- case 7:
107
- if (!(!key || typeof key != "string")) {
108
- _context.next = 13;
109
- break;
110
- }
111
- if (!(this.__throw_errors !== false)) {
112
- _context.next = 12;
113
- break;
114
- }
115
- throw Error("Bad key at setMetaValue");
116
- case 12:
117
- return _context.abrupt("return", false);
118
- case 13:
119
- old_value = WebObject.getMetaValue(this, key);
120
- if (!(0, _object.object_equals)(old_value, value)) {
121
- _context.next = 16;
122
- break;
123
- }
124
- return _context.abrupt("return", false);
125
- case 16:
126
- //same value, no changes
127
- new_metalist = _objectSpread({}, this.getValue("meta_data"));
128
- new_metalist[key] = value;
129
- _context.next = 20;
130
- return this.setValue("meta_data", new_metalist);
131
- case 20:
132
- if (!(sendChange !== false)) {
133
- _context.next = 23;
134
- break;
135
- }
136
- _context.next = 23;
137
- return this.notifyChanged("meta", key, value);
138
- case 23:
139
- return _context.abrupt("return", true);
140
- case 24:
141
- case "end":
142
- return _context.stop();
143
- }
144
- }, _callee, this);
145
- }))).apply(this, arguments);
146
- }
54
+ */
55
+ async setMetaValue(key, value, sendChange = "auto") {
56
+ if (!this.canModify) {
57
+ if (this.__throw_errors !== false)
58
+ throw Error(`Cant use setMetaValue on ${key} when on readonly mode`);
59
+ else
60
+ return false;
61
+ }
62
+ if (!key || typeof key != "string") {
63
+ if (this.__throw_errors !== false)
64
+ throw Error(`Bad key at setMetaValue`);
65
+ else
66
+ return false;
67
+ }
68
+ const old_value = WebObject.getMetaValue(this, key);
69
+ if (object_equals(old_value, value))
70
+ return false; //same value, no changes
71
+ const new_metalist = { ...this.getValue("meta_data") };
72
+ new_metalist[key] = value;
73
+ await this.setValue("meta_data", new_metalist);
74
+ if (sendChange !== false)
75
+ await this.notifyChanged("meta", key, value);
76
+ return true;
77
+ }
147
78
  /**
148
79
  * Get meta value by key
149
80
  * @param key
150
81
  * @returns value or undefined
151
- */
152
- }, {
153
- key: "getMetaValue",
154
- value: function getMetaValue(key) {
155
- return WebObject.getMetaValue(this, key);
156
- }
82
+ */
83
+ getMetaValue(key) {
84
+ return WebObject.getMetaValue(this, key);
85
+ }
157
86
  /**
158
87
  * Get meta value by key
159
88
  * @param o
160
89
  * @param key
161
90
  * @returns value or undefined
162
- */
163
- }, {
164
- key: "Save",
165
- value: function Save() {
166
- return (_Save = _Save || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
167
- var deltaObject, putAction, putAddress, canSaveResult, resultObject;
168
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
169
- while (1) switch (_context2.prev = _context2.next) {
170
- case 0:
171
- _context2.next = 2;
172
- return this.get_deltaObject();
173
- case 2:
174
- deltaObject = _context2.sent;
175
- putAction = "post";
176
- putAddress = this.isNew ? "".concat(this.__web_path) : "".concat(this.__web_path, "/").concat(this.getID()); //save
177
- if ((0, _object.object_isEmpty)(deltaObject)) {
178
- _context2.next = 18;
179
- break;
180
- }
181
- canSaveResult = this.canSave(deltaObject);
182
- if (!(canSaveResult !== true)) {
183
- _context2.next = 11;
184
- break;
185
- }
186
- WebObject.addError(this, "Save not allowed", String(canSaveResult), true);
187
- this.setSaveResult(false, "canceled");
188
- return _context2.abrupt("return", false);
189
- case 11:
190
- _context2.next = 13;
191
- return _global.gfunc.run_action(putAction, putAddress, deltaObject);
192
- case 13:
193
- resultObject = _context2.sent;
194
- this.setSaveResult(resultObject, "auto");
195
- if (!this.__saveResultIsSuccess) {
196
- console.error("bad save result : ", resultObject);
197
- WebObject.addError(this, "Save result is not valid", "the response from server was not a valid saveresult object !", true);
198
- }
199
- _context2.next = 19;
200
- break;
201
- case 18:
202
- /* nothing to save */
203
- this.setSaveResult(null, "nothing");
204
- case 19:
205
- if (!this.isSaved) {
206
- _context2.next = 23;
207
- break;
208
- }
209
- _context2.next = 22;
210
- return this.onSave();
211
- case 22:
212
- return _context2.abrupt("return", this.getSaveResult());
213
- case 23:
214
- case "end":
215
- return _context2.stop();
216
- }
217
- }, _callee2, this);
218
- }))).apply(this, arguments);
219
- }
220
- }, {
221
- key: "Delete",
222
- value: function Delete() {
223
- return (_Delete = _Delete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
224
- var resultObject;
225
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
226
- while (1) switch (_context3.prev = _context3.next) {
227
- case 0:
228
- if (!this.isNew) {
229
- _context3.next = 2;
230
- break;
231
- }
232
- return _context3.abrupt("return");
233
- case 2:
234
- _context3.next = 4;
235
- return _global.gfunc.run_action("delete", "".concat(this.__web_path, "/").concat(this.getID()));
236
- case 4:
237
- resultObject = _context3.sent;
238
- this.setSaveResult(resultObject, "auto", true);
239
- _context3.next = 8;
240
- return this.onDelete();
241
- case 8:
242
- return _context3.abrupt("return", resultObject);
243
- case 9:
244
- case "end":
245
- return _context3.stop();
246
- }
247
- }, _callee3, this);
248
- }))).apply(this, arguments);
249
- }
250
- }, {
251
- key: "Archive",
252
- value: function Archive() {
253
- return (_Archive = _Archive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
254
- var resultObject;
255
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
256
- while (1) switch (_context4.prev = _context4.next) {
257
- case 0:
258
- if (!(this.isNew || this.isArchived)) {
259
- _context4.next = 2;
260
- break;
261
- }
262
- return _context4.abrupt("return");
263
- case 2:
264
- _context4.next = 4;
265
- return _global.gfunc.run_action("post", "".concat(this.get_webname(), "/").concat(this.getID(), "/archive"));
266
- case 4:
267
- resultObject = _context4.sent;
268
- this.setSaveResult(resultObject, "auto", true);
269
- _context4.next = 8;
270
- return this.onArchive();
271
- case 8:
272
- return _context4.abrupt("return", resultObject);
273
- case 9:
274
- case "end":
275
- return _context4.stop();
276
- }
277
- }, _callee4, this);
278
- }))).apply(this, arguments);
279
- }
280
- }, {
281
- key: "UnArchive",
282
- value: function UnArchive() {
283
- return (_UnArchive = _UnArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
284
- var resultObject;
285
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
286
- while (1) switch (_context5.prev = _context5.next) {
287
- case 0:
288
- if (!(this.isNew || !this.isArchived)) {
289
- _context5.next = 2;
290
- break;
291
- }
292
- return _context5.abrupt("return");
293
- case 2:
294
- _context5.next = 4;
295
- return _global.gfunc.run_action("post", "".concat(this.get_webname(), "/").concat(this.getID(), "/unarchive"));
296
- case 4:
297
- resultObject = _context5.sent;
298
- this.setSaveResult(resultObject, "auto", true);
299
- _context5.next = 8;
300
- return this.onUnArchive();
301
- case 8:
302
- return _context5.abrupt("return", resultObject);
303
- case 9:
304
- case "end":
305
- return _context5.stop();
306
- }
307
- }, _callee5, this);
308
- }))).apply(this, arguments);
309
- } /* -------------------------------------------------------------------------- */
310
- }, {
311
- key: "canSave",
312
- value: function canSave(deltaObj) {
313
- var deltaRes = this.deltaIsValid(deltaObj);
314
- if (deltaRes !== true) return deltaRes;
315
- return true;
316
- }
317
- }, {
318
- key: "canDelete",
319
- value: function canDelete() {
320
- return true;
321
- }
322
- }, {
323
- key: "canArchive",
324
- value: function canArchive() {
325
- return true;
326
- }
327
- }, {
328
- key: "deltaIsValid",
329
- value: function deltaIsValid(d) {
330
- return true;
331
- }
91
+ */
92
+ static getMetaValue(o, key) {
93
+ if (o == null)
94
+ return null;
95
+ if (!key || typeof key != "string")
96
+ return undefined;
97
+ let metalist = {};
98
+ if (typeof o === "object") {
99
+ metalist =
100
+ typeof o.getValue === "function"
101
+ ? o.getValue("meta_data")
102
+ : o.meta_data;
103
+ }
104
+ return metalist[key];
105
+ }
106
+ /* -------------------------------------------------------------------------- */
107
+ /* Save */
108
+ /* -------------------------------------------------------------------------- */
109
+ static zipSaveList(svlist) {
110
+ if (typeof svlist === "object")
111
+ svlist = JSON.stringify(svlist);
112
+ return string_compress(svlist);
113
+ }
114
+ static unzipSaveList(svlist) {
115
+ try {
116
+ if (typeof svlist === "object") {
117
+ if (Array.isArray(svlist))
118
+ return svlist;
119
+ if (svlist.__save_list)
120
+ return this.unzipSaveList(svlist.__save_list);
121
+ }
122
+ else if (typeof svlist === "string")
123
+ return wrap_array(JSON.parse(string_decompress(svlist)));
124
+ }
125
+ catch { }
126
+ return wrap_array(svlist);
127
+ }
128
+ static async saveList(itemList, extraOptions = {}) {
129
+ if (!extraOptions)
130
+ extraOptions = {};
131
+ const chunks = array_chunks(itemList, extraOptions.chunksize ?? 50);
132
+ delete extraOptions.chunksize;
133
+ const putAddress = this.get_webname();
134
+ for (let index = 0; index < chunks.length; index++) {
135
+ const items_to_save = chunks[index];
136
+ const save_array = [];
137
+ for (let k = 0; k < items_to_save.length; k++) {
138
+ const item = items_to_save[k];
139
+ const dlt = await item.get_deltaObject();
140
+ save_array.push(item.isNew
141
+ ? {
142
+ ...dlt,
143
+ }
144
+ : {
145
+ _id: item.getID(),
146
+ ...dlt,
147
+ });
148
+ }
149
+ const resultObject = await gfunc.run_action("post", putAddress, {
150
+ __save_list: WebObject.zipSaveList(save_array),
151
+ ...extraOptions,
152
+ });
153
+ if (Array.isArray(resultObject)) {
154
+ for (let index = 0; index < Math.min(resultObject.length, items_to_save.length); index++) {
155
+ const res = resultObject[index];
156
+ const item = items_to_save[index];
157
+ item.setSaveResult(res);
158
+ await item.onSave();
159
+ }
160
+ }
161
+ }
162
+ for (let index = 0; index < itemList.length; index++) {
163
+ const item = itemList[index];
164
+ if (!item.isSaved)
165
+ return false;
166
+ if (item.getSaveResultType() != "normal")
167
+ return false;
168
+ }
169
+ return true;
170
+ }
171
+ async Save() {
172
+ const deltaObject = await this.get_deltaObject();
173
+ const putAction = "post";
174
+ const putAddress = this.isNew
175
+ ? `${this.__web_path}`
176
+ : `${this.__web_path}/${this.getID()}`;
177
+ //save
178
+ if (!object_isEmpty(deltaObject)) {
179
+ const canSaveResult = this.canSave(deltaObject);
180
+ if (canSaveResult !== true) {
181
+ WebObject.addError(this, "Save not allowed", String(canSaveResult), true);
182
+ this.setSaveResult(false, "canceled");
183
+ return false;
184
+ }
185
+ const resultObject = await gfunc.run_action(putAction, putAddress, deltaObject);
186
+ this.setSaveResult(resultObject, "auto");
187
+ if (!this.__saveResultIsSuccess) {
188
+ console.error("bad save result : ", resultObject);
189
+ WebObject.addError(this, "Save result is not valid", "the response from server was not a valid saveresult object !", true);
190
+ }
191
+ }
192
+ else {
193
+ /* nothing to save */
194
+ this.setSaveResult(null, "nothing");
195
+ }
196
+ if (this.isSaved) {
197
+ await this.onSave();
198
+ return this.getSaveResult();
199
+ }
200
+ }
201
+ async Delete() {
202
+ if (this.isNew)
203
+ return;
204
+ const resultObject = await gfunc.run_action("delete", `${this.__web_path}/${this.getID()}`);
205
+ this.setSaveResult(resultObject, "auto", true);
206
+ await this.onDelete();
207
+ return resultObject;
208
+ }
209
+ async Archive() {
210
+ if (this.isNew || this.isArchived)
211
+ return;
212
+ const resultObject = await gfunc.run_action("post", `${this.get_webname()}/${this.getID()}/archive`);
213
+ this.setSaveResult(resultObject, "auto", true);
214
+ await this.onArchive();
215
+ return resultObject;
216
+ }
217
+ async UnArchive() {
218
+ if (this.isNew || !this.isArchived)
219
+ return;
220
+ const resultObject = await gfunc.run_action("post", `${this.get_webname()}/${this.getID()}/unarchive`);
221
+ this.setSaveResult(resultObject, "auto", true);
222
+ await this.onUnArchive();
223
+ return resultObject;
224
+ }
225
+ /* -------------------------------------------------------------------------- */
226
+ canSave(deltaObj) {
227
+ const deltaRes = this.deltaIsValid(deltaObj);
228
+ if (deltaRes !== true)
229
+ return deltaRes;
230
+ return true;
231
+ }
232
+ canDelete() {
233
+ return true;
234
+ }
235
+ canArchive() {
236
+ return true;
237
+ }
238
+ deltaIsValid(d) {
239
+ return true;
240
+ }
332
241
  /**
333
242
  * You will post this to the server for saving
334
243
  * automatically removes unchangable fields
335
244
  * @returns
336
- */
337
- }, {
338
- key: "get_deltaObject",
339
- value: function get_deltaObject(_x3) {
340
- return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(p) {
341
- var _this2 = this,
342
- _parseObj;
343
- var final_object, isChild, useDelta, allProperties, needId, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, parseObj, _iterator, _step, key, tempusers;
344
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
345
- while (1) switch (_context8.prev = _context8.next) {
346
- case 0:
347
- parseObj = function _parseObj2(_x4) {
348
- return (_parseObj = _parseObj || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(obj) {
349
- var _ref;
350
- var newobj_dlt;
351
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
352
- while (1) switch (_context7.prev = _context7.next) {
353
- case 0:
354
- if (!(obj == null)) {
355
- _context7.next = 2;
356
- break;
357
- }
358
- return _context7.abrupt("return", undefined);
359
- case 2:
360
- if (!Array.isArray(obj)) {
361
- _context7.next = 6;
362
- break;
363
- }
364
- _context7.next = 5;
365
- return Promise.all(obj.map(function (_x5) {
366
- return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(r) {
367
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
368
- while (1) switch (_context6.prev = _context6.next) {
369
- case 0:
370
- _context6.next = 2;
371
- return parseObj(r);
372
- case 2:
373
- return _context6.abrupt("return", _context6.sent);
374
- case 3:
375
- case "end":
376
- return _context6.stop();
377
- }
378
- }, _callee6);
379
- }))).apply(this, arguments);
380
- }));
381
- case 5:
382
- return _context7.abrupt("return", _context7.sent);
383
- case 6:
384
- if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
385
- _context7.next = 15;
386
- break;
387
- }
388
- _context7.next = 9;
389
- return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
390
- isChild: true
391
- }));
392
- case 9:
393
- newobj_dlt = _context7.sent;
394
- if ((0, _object.object_isEmpty)(newobj_dlt)) {
395
- _context7.next = 14;
396
- break;
397
- }
398
- return _context7.abrupt("return", newobj_dlt);
399
- case 14:
400
- return _context7.abrupt("return", obj);
401
- case 15:
402
- return _context7.abrupt("return", obj);
403
- case 16:
404
- case "end":
405
- return _context7.stop();
406
- }
407
- }, _callee7);
408
- }))).apply(this, arguments);
409
- };
410
- if (!p) p = {};
411
- final_object = {}; //@ts-ignore
412
- isChild = Boolean(p.isChild || p.ischild); //@ts-ignore
413
- useDelta = this.__use_delta || Boolean(p.useDelta || p.usedelta); //@ts-ignore
414
- allProperties = Boolean(p.allProperties || p.allproperties); //@ts-ignore
415
- needId = Boolean(p.needId || p.needid);
416
- chkChangables = this.__changeables != null || this.__unchangeables != null;
417
- useExtraProps = Boolean(p.extraProperties); //child objects usually dont update their __delta, so we read info from all of its properties
418
- dlt = allProperties || !useDelta && isChild && chkChangables ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
419
- allkeys = Object.keys(dlt);
420
- changableKeys = chkChangables ? allkeys.filter(function (s) {
421
- return _index3.SimpleObject.canChangeKey(_this2, s, {
422
- useExtraProps: useExtraProps,
423
- ignoreProtected: allProperties
424
- });
425
- }) : allkeys;
426
- _context8.next = 14;
427
- return _convert["default"].applyFormats({
428
- inputobject: dlt,
429
- formats: (0, _object.object_getStatic)(this, "__formatList"),
430
- changableKeys: changableKeys
431
- });
432
- case 14:
433
- /* -------------------------------------------------------------------------- */
434
- /* __functionProperties */
435
- /* -------------------------------------------------------------------------- */
436
- functionProps = (0, _object.object_getStatic)(this, "__functionProperties");
437
- if (Array.isArray(functionProps)) {
438
- for (index = 0; index < functionProps.length; index++) {
439
- fp = functionProps[index];
440
- if (dlt[fp]) dlt[fp] = (0, _object.fn_eval_this)(this, dlt[fp]);
441
- }
442
- }
443
- /* -------------------------------------------------------------------------- */
444
- /* parse all changableKeys */
445
- /* -------------------------------------------------------------------------- */
446
- _iterator = _createForOfIteratorHelper(changableKeys);
447
- _context8.prev = 17;
448
- _iterator.s();
449
- case 19:
450
- if ((_step = _iterator.n()).done) {
451
- _context8.next = 26;
452
- break;
453
- }
454
- key = _step.value;
455
- _context8.next = 23;
456
- return parseObj(dlt[key]);
457
- case 23:
458
- final_object[key] = _context8.sent;
459
- case 24:
460
- _context8.next = 19;
461
- break;
462
- case 26:
463
- _context8.next = 31;
464
- break;
465
- case 28:
466
- _context8.prev = 28;
467
- _context8.t0 = _context8["catch"](17);
468
- _iterator.e(_context8.t0);
469
- case 31:
470
- _context8.prev = 31;
471
- _iterator.f();
472
- return _context8.finish(31);
473
- case 34:
474
- /* -------------------------------------------------------------------------- */
475
- /* add id properties */
476
- /* -------------------------------------------------------------------------- */
477
- if (allProperties) {
478
- final_object["_created_date"] = this["_created_date"];
479
- final_object["_archived"] = this.isArchived;
480
- final_object["_deleted"] = this.isDeleted;
481
- }
482
- if (allProperties || needId) {
483
- if (this["_index_key"]) final_object["_index_key"] = this["_index_key"];
484
- if (this.getIndex()) final_object["_index_value"] = this.getIndex();
485
- if (this.getID()) final_object["_id"] = this.getID();
486
- }
487
- /* -------------------------------------------------------------------------- */
488
- /* fix _user property */
489
- /* -------------------------------------------------------------------------- */
490
- if (final_object["_users"]) {
491
- tempusers = final_object["_users"];
492
- if (typeof tempusers === "string") tempusers = tempusers.split(",").filter(function (s) {
493
- return s;
494
- });
495
- final_object["_users"] = (0, _object.wrap_array)(tempusers);
496
- }
497
- return _context8.abrupt("return", final_object);
498
- case 38:
499
- case "end":
500
- return _context8.stop();
501
- }
502
- }, _callee8, this, [[17, 28, 31, 34]]);
503
- }))).apply(this, arguments);
504
- } /* --------------------------------- Getters -------------------------------- */
505
- }, {
506
- key: "__web_path",
507
- get: function get() {
508
- return this.constructor["__web_path"] || this.constructor["__web_type"];
509
- }
510
- }, {
511
- key: "__web_type",
512
- get: function get() {
513
- return this.constructor["__web_type"] || this.constructor["__web_path"];
514
- }
515
- }, {
516
- key: "manager",
517
- get: function get() {
518
- return this.get_managerClass() || undefined;
519
- }
520
- }, {
521
- key: "get_webname",
522
- value: function get_webname() {
523
- return this.__web_path || this.__web_type || this.__cache_name || "";
524
- }
525
- }, {
526
- key: "onDelete",
527
- value: /* -------------------------------------------------------------------------- */function onDelete() {
528
- return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
529
- var _this$manager;
530
- var _len,
531
- p,
532
- _key,
533
- _args9 = arguments;
534
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
535
- while (1) switch (_context9.prev = _context9.next) {
536
- case 0:
537
- if (this.isSaved) this.isDeleted = true;
538
- for (_len = _args9.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
539
- p[_key] = _args9[_key];
540
- }
541
- _context9.next = 4;
542
- return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
543
- case 4:
544
- return _context9.abrupt("return", _context9.sent);
545
- case 5:
546
- case "end":
547
- return _context9.stop();
548
- }
549
- }, _callee9, this);
550
- }))).apply(this, arguments);
551
- }
552
- }, {
553
- key: "onArchive",
554
- value: function onArchive() {
555
- return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
556
- var _this$manager2;
557
- var _len2,
558
- p,
559
- _key2,
560
- _args10 = arguments;
561
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
562
- while (1) switch (_context10.prev = _context10.next) {
563
- case 0:
564
- if (this.isSaved) this.isArchived = true;
565
- for (_len2 = _args10.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
566
- p[_key2] = _args10[_key2];
567
- }
568
- _context10.next = 4;
569
- return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onArchive.apply(_this$manager2, p);
570
- case 4:
571
- return _context10.abrupt("return", _context10.sent);
572
- case 5:
573
- case "end":
574
- return _context10.stop();
575
- }
576
- }, _callee10, this);
577
- }))).apply(this, arguments);
578
- }
579
- }, {
580
- key: "onUnArchive",
581
- value: function onUnArchive() {
582
- return (_onUnArchive = _onUnArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
583
- var _this$manager3;
584
- var _len3,
585
- p,
586
- _key3,
587
- _args11 = arguments;
588
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
589
- while (1) switch (_context11.prev = _context11.next) {
590
- case 0:
591
- if (this.isSaved) this.isArchived = false;
592
- for (_len3 = _args11.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
593
- p[_key3] = _args11[_key3];
594
- }
595
- _context11.next = 4;
596
- return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onUnArchive.apply(_this$manager3, p);
597
- case 4:
598
- return _context11.abrupt("return", _context11.sent);
599
- case 5:
600
- case "end":
601
- return _context11.stop();
602
- }
603
- }, _callee11, this);
604
- }))).apply(this, arguments);
605
- }
606
- }, {
607
- key: "onLoad",
608
- value: function onLoad() {
609
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
610
- var _this$manager4;
611
- var _len4,
612
- p,
613
- _key4,
614
- _args12 = arguments;
615
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
616
- while (1) switch (_context12.prev = _context12.next) {
617
- case 0:
618
- this.isDeleted = false;
619
- for (_len4 = _args12.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
620
- p[_key4] = _args12[_key4];
621
- }
622
- _context12.next = 4;
623
- return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onLoad.apply(_this$manager4, p);
624
- case 4:
625
- return _context12.abrupt("return", _context12.sent);
626
- case 5:
627
- case "end":
628
- return _context12.stop();
629
- }
630
- }, _callee12, this);
631
- }))).apply(this, arguments);
632
- }
633
- }, {
634
- key: "onSave",
635
- value: function onSave() {
636
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
637
- var _this$manager6;
638
- var srObject,
639
- _this$manager5,
640
- _len5,
641
- p,
642
- _key5,
643
- _args13 = arguments;
644
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
645
- while (1) switch (_context13.prev = _context13.next) {
646
- case 0:
647
- if (!this.isSaved) {
648
- _context13.next = 7;
649
- break;
650
- }
651
- this.apply_changes();
652
- srObject = this.getSaveResult(true);
653
- if (!this.saveResultHasID(srObject)) {
654
- _context13.next = 7;
655
- break;
656
- }
657
- /* -------------------------------------------------------------------------- */
658
- WebObject.LoadIdsFromSaveResult(this, srObject);
659
- _context13.next = 7;
660
- return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.event_run("on_id_change");
661
- case 7:
662
- for (_len5 = _args13.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
663
- p[_key5] = _args13[_key5];
664
- }
665
- _context13.next = 10;
666
- return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onSave.apply(_this$manager6, p);
667
- case 10:
668
- _context13.next = 12;
669
- return this.onAfterSave();
670
- case 12:
671
- return _context13.abrupt("return", true);
672
- case 13:
673
- case "end":
674
- return _context13.stop();
675
- }
676
- }, _callee13, this);
677
- }))).apply(this, arguments);
678
- }
679
- }, {
680
- key: "onAfterSave",
681
- value: function onAfterSave() {
682
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
683
- var _this$manager7;
684
- var _len6,
685
- p,
686
- _key6,
687
- _args14 = arguments;
688
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
689
- while (1) switch (_context14.prev = _context14.next) {
690
- case 0:
691
- for (_len6 = _args14.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
692
- p[_key6] = _args14[_key6];
693
- }
694
- _context14.next = 3;
695
- return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.onAfterSave.apply(_this$manager7, p);
696
- case 3:
697
- return _context14.abrupt("return", true);
698
- case 4:
699
- case "end":
700
- return _context14.stop();
701
- }
702
- }, _callee14, this);
703
- }))).apply(this, arguments);
704
- }
705
- }, {
706
- key: "getSaveResult",
707
- value: function getSaveResult() {
708
- var _this3 = this;
709
- var original = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
710
- var srObject = _get(_getPrototypeOf(WebObject.prototype), "getSaveResult", this).call(this, original);
711
- if (!srObject) return false;
712
- if (Array.isArray(srObject)) {
713
- var actual_sr = srObject.find(function (s) {
714
- return _this3.saveResultHasID(s);
715
- });
716
- if (actual_sr) srObject = actual_sr;
717
- }
718
- return srObject;
719
- }
720
- }, {
721
- key: "onNew",
722
- value: function onNew() {
723
- return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
724
- var _this$manager8;
725
- var _len7,
726
- p,
727
- _key7,
728
- _args15 = arguments;
729
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
730
- while (1) switch (_context15.prev = _context15.next) {
731
- case 0:
732
- for (_len7 = _args15.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
733
- p[_key7] = _args15[_key7];
734
- }
735
- _context15.next = 3;
736
- return (_this$manager8 = this.manager) === null || _this$manager8 === void 0 ? void 0 : _this$manager8.onNew.apply(_this$manager8, p);
737
- case 3:
738
- return _context15.abrupt("return", _context15.sent);
739
- case 4:
740
- case "end":
741
- return _context15.stop();
742
- }
743
- }, _callee15, this);
744
- }))).apply(this, arguments);
745
- } /* -------------------------------------------------------------------------- */
746
- }, {
747
- key: "saveResultHasID",
748
- value: function saveResultHasID(s) {
749
- return WebObject.saveResultHasID(s);
750
- }
751
- }], [{
752
- key: "getAllUsers",
753
- value: function getAllUsers(obj) {
754
- if (_typeof(obj) != "object") return [];
755
- return (0, _object.array_remove_duplicates)((0, _object.array_merge)(obj._creator, (0, _object.wrap_array)(obj._users), (0, _object.wrap_array)(obj.attentions)).map(function (r) {
756
- return String(_typeof(r) === "object" ? WebObject.getID(r) : r);
757
- }).filter(function (s) {
758
- return s;
759
- }));
760
- }
761
- }, {
762
- key: "getMetaValue",
763
- value: function getMetaValue(o, key) {
764
- if (o == null) return null;
765
- if (!key || typeof key != "string") return undefined;
766
- var metalist = {};
767
- if (_typeof(o) === "object") {
768
- metalist = typeof o.getValue === "function" ? o.getValue("meta_data") : o.meta_data;
769
- }
770
- return metalist[key];
771
- }
772
- /* -------------------------------------------------------------------------- */
773
- /* Save */
774
- /* -------------------------------------------------------------------------- */
775
- }, {
776
- key: "zipSaveList",
777
- value: function zipSaveList(svlist) {
778
- if (_typeof(svlist) === "object") svlist = JSON.stringify(svlist);
779
- return (0, _string.string_compress)(svlist);
780
- }
781
- }, {
782
- key: "unzipSaveList",
783
- value: function unzipSaveList(svlist) {
784
- try {
785
- if (_typeof(svlist) === "object") {
786
- if (Array.isArray(svlist)) return svlist;
787
- if (svlist.__save_list) return this.unzipSaveList(svlist.__save_list);
788
- } else if (typeof svlist === "string") return (0, _object.wrap_array)(JSON.parse((0, _string.string_decompress)(svlist)));
789
- } catch (_unused) {}
790
- return (0, _object.wrap_array)(svlist);
791
- }
792
- }, {
793
- key: "saveList",
794
- value: function saveList(_x6) {
795
- return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(itemList) {
796
- var _extraOptions$chunksi;
797
- var extraOptions,
798
- chunks,
799
- putAddress,
800
- index,
801
- items_to_save,
802
- save_array,
803
- k,
804
- item,
805
- dlt,
806
- resultObject,
807
- _index,
808
- res,
809
- _item,
810
- _index2,
811
- _item2,
812
- _args16 = arguments;
813
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
814
- while (1) switch (_context16.prev = _context16.next) {
815
- case 0:
816
- extraOptions = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
817
- if (!extraOptions) extraOptions = {};
818
- chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
819
- delete extraOptions.chunksize;
820
- putAddress = this.get_webname();
821
- index = 0;
822
- case 6:
823
- if (!(index < chunks.length)) {
824
- _context16.next = 36;
825
- break;
826
- }
827
- items_to_save = chunks[index];
828
- save_array = [];
829
- k = 0;
830
- case 10:
831
- if (!(k < items_to_save.length)) {
832
- _context16.next = 19;
833
- break;
834
- }
835
- item = items_to_save[k];
836
- _context16.next = 14;
837
- return item.get_deltaObject();
838
- case 14:
839
- dlt = _context16.sent;
840
- save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
841
- _id: item.getID()
842
- }, dlt));
843
- case 16:
844
- k++;
845
- _context16.next = 10;
846
- break;
847
- case 19:
848
- _context16.next = 21;
849
- return _global.gfunc.run_action("post", putAddress, _objectSpread({
850
- __save_list: WebObject.zipSaveList(save_array)
851
- }, extraOptions));
852
- case 21:
853
- resultObject = _context16.sent;
854
- if (!Array.isArray(resultObject)) {
855
- _context16.next = 33;
856
- break;
857
- }
858
- _index = 0;
859
- case 24:
860
- if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
861
- _context16.next = 33;
862
- break;
863
- }
864
- res = resultObject[_index];
865
- _item = items_to_save[_index];
866
- _item.setSaveResult(res);
867
- _context16.next = 30;
868
- return _item.onSave();
869
- case 30:
870
- _index++;
871
- _context16.next = 24;
872
- break;
873
- case 33:
874
- index++;
875
- _context16.next = 6;
876
- break;
877
- case 36:
878
- _index2 = 0;
879
- case 37:
880
- if (!(_index2 < itemList.length)) {
881
- _context16.next = 46;
882
- break;
883
- }
884
- _item2 = itemList[_index2];
885
- if (_item2.isSaved) {
886
- _context16.next = 41;
887
- break;
888
- }
889
- return _context16.abrupt("return", false);
890
- case 41:
891
- if (!(_item2.getSaveResultType() != "normal")) {
892
- _context16.next = 43;
893
- break;
894
- }
895
- return _context16.abrupt("return", false);
896
- case 43:
897
- _index2++;
898
- _context16.next = 37;
899
- break;
900
- case 46:
901
- return _context16.abrupt("return", true);
902
- case 47:
903
- case "end":
904
- return _context16.stop();
905
- }
906
- }, _callee16, this);
907
- }))).apply(this, arguments);
908
- }
909
- }, {
910
- key: "get_webname",
911
- value: function get_webname() {
912
- return this.__web_path || this.__web_type || this.__cache_name || "";
913
- }
914
- }, {
915
- key: "saveResultHasID",
916
- value: function saveResultHasID(s) {
917
- if (_typeof(s) !== "object" || s == null || !s) return false;
918
- return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
919
- }
245
+ */
246
+ async get_deltaObject(p) {
247
+ if (!p)
248
+ p = {};
249
+ const final_object = {};
250
+ //@ts-ignore
251
+ const isChild = Boolean(p.isChild || p.ischild);
252
+ //@ts-ignore
253
+ const useDelta = this.__use_delta || Boolean(p.useDelta || p.usedelta);
254
+ //@ts-ignore
255
+ const allProperties = Boolean(p.allProperties || p.allproperties);
256
+ //@ts-ignore
257
+ const needId = Boolean(p.needId || p.needid);
258
+ const chkChangables = this.__changeables != null || this.__unchangeables != null;
259
+ const useExtraProps = Boolean(p.extraProperties);
260
+ //child objects usually dont update their __delta, so we read info from all of its properties
261
+ const dlt = allProperties || (!useDelta && isChild && chkChangables)
262
+ ? { ...this.allproperties }
263
+ : { ...this.__delta };
264
+ const allkeys = Object.keys(dlt);
265
+ const changableKeys = chkChangables
266
+ ? allkeys.filter((s) => SimpleObject.canChangeKey(this, s, {
267
+ useExtraProps: useExtraProps,
268
+ ignoreProtected: allProperties,
269
+ }))
270
+ : allkeys;
271
+ await FormatHelper.applyFormats({
272
+ inputobject: dlt,
273
+ formats: object_getStatic(this, "__formatList"),
274
+ changableKeys: changableKeys,
275
+ });
276
+ /* -------------------------------------------------------------------------- */
277
+ /* __functionProperties */
278
+ /* -------------------------------------------------------------------------- */
279
+ const functionProps = object_getStatic(this, "__functionProperties");
280
+ if (Array.isArray(functionProps)) {
281
+ for (let index = 0; index < functionProps.length; index++) {
282
+ const fp = functionProps[index];
283
+ if (dlt[fp])
284
+ dlt[fp] = fn_eval_this(this, dlt[fp]);
285
+ }
286
+ }
287
+ /* -------------------------------------------------------------------------- */
288
+ /* parse all changableKeys */
289
+ /* -------------------------------------------------------------------------- */
290
+ async function parseObj(obj) {
291
+ if (obj == null)
292
+ return undefined;
293
+ if (Array.isArray(obj))
294
+ return await Promise.all(obj.map(async (r) => await parseObj(r)));
295
+ if (obj instanceof WebObject &&
296
+ typeof obj.get_deltaObject === "function") {
297
+ //child elements have different kind of delta
298
+ const newobj_dlt = await obj.get_deltaObject({
299
+ ...p,
300
+ isChild: true,
301
+ });
302
+ if (!object_isEmpty(newobj_dlt))
303
+ return newobj_dlt;
304
+ else
305
+ return obj;
306
+ }
307
+ return obj;
308
+ }
309
+ for (const key of changableKeys) {
310
+ final_object[key] = await parseObj(dlt[key]);
311
+ }
312
+ /* -------------------------------------------------------------------------- */
313
+ /* add id properties */
314
+ /* -------------------------------------------------------------------------- */
315
+ if (allProperties) {
316
+ final_object["_created_date"] = this["_created_date"];
317
+ final_object["_archived"] = this.isArchived;
318
+ final_object["_deleted"] = this.isDeleted;
319
+ }
320
+ if (allProperties || needId) {
321
+ if (this["_index_key"])
322
+ final_object["_index_key"] = this["_index_key"];
323
+ if (this.getIndex())
324
+ final_object["_index_value"] = this.getIndex();
325
+ if (this.getID())
326
+ final_object["_id"] = this.getID();
327
+ }
328
+ /* -------------------------------------------------------------------------- */
329
+ /* fix _user property */
330
+ /* -------------------------------------------------------------------------- */
331
+ if (final_object["_users"]) {
332
+ let tempusers = final_object["_users"];
333
+ if (typeof tempusers === "string")
334
+ tempusers = tempusers.split(",").filter((s) => s);
335
+ final_object["_users"] = wrap_array(tempusers);
336
+ }
337
+ return final_object;
338
+ }
339
+ /* --------------------------------- Getters -------------------------------- */
340
+ get __web_path() {
341
+ return this.constructor["__web_path"] || this.constructor["__web_type"];
342
+ }
343
+ get __web_type() {
344
+ return this.constructor["__web_type"] || this.constructor["__web_path"];
345
+ }
346
+ get manager() {
347
+ return this.get_managerClass() || undefined;
348
+ }
349
+ get_webname() {
350
+ return this.__web_path || this.__web_type || this.__cache_name || "";
351
+ }
352
+ static get_webname() {
353
+ return this.__web_path || this.__web_type || this.__cache_name || "";
354
+ }
355
+ /* -------------------------------------------------------------------------- */
356
+ async onDelete(...p) {
357
+ if (this.isSaved)
358
+ this.isDeleted = true;
359
+ return await this.manager?.onDelete(...p); //events are handled by the manager
360
+ }
361
+ async onArchive(...p) {
362
+ if (this.isSaved)
363
+ this.isArchived = true;
364
+ return await this.manager?.onArchive(...p); //events are handled by the manager
365
+ }
366
+ async onUnArchive(...p) {
367
+ if (this.isSaved)
368
+ this.isArchived = false;
369
+ return await this.manager?.onUnArchive(...p); //events are handled by the manager
370
+ }
371
+ async onLoad(...p) {
372
+ this.isDeleted = false;
373
+ return await this.manager?.onLoad(...p); //events are handled by the manager
374
+ }
375
+ async onSave(...p) {
376
+ if (this.isSaved) {
377
+ this.apply_changes();
378
+ var srObject = this.getSaveResult(true);
379
+ if (this.saveResultHasID(srObject)) {
380
+ /* -------------------------------------------------------------------------- */
381
+ WebObject.LoadIdsFromSaveResult(this, srObject);
382
+ await this.manager?.event_run("on_id_change");
383
+ }
384
+ }
385
+ await this.manager?.onSave(...p); //events are handled by the manager
386
+ await this.onAfterSave();
387
+ return true;
388
+ }
389
+ async onAfterSave(...p) {
390
+ await this.manager?.onAfterSave(...p); //events are handled by the manager
391
+ return true;
392
+ }
393
+ getSaveResult(original = false) {
394
+ let srObject = super.getSaveResult(original);
395
+ if (!srObject)
396
+ return false;
397
+ if (Array.isArray(srObject)) {
398
+ const actual_sr = srObject.find((s) => this.saveResultHasID(s));
399
+ if (actual_sr)
400
+ srObject = actual_sr;
401
+ }
402
+ return srObject;
403
+ }
404
+ async onNew(...p) {
405
+ return await this.manager?.onNew(...p); //events are handled by the manager
406
+ }
407
+ /* -------------------------------------------------------------------------- */
408
+ saveResultHasID(s) {
409
+ return WebObject.saveResultHasID(s);
410
+ }
411
+ static saveResultHasID(s) {
412
+ if (typeof s !== "object" || s == null || !s)
413
+ return false;
414
+ return (s.insertedId ||
415
+ s._id ||
416
+ (s._index_value && !Number.isNaN(s._index_value)));
417
+ }
920
418
  /**
921
419
  * Load Id and _index_value from the given save result into our object
922
420
  * @param o
923
421
  * @param srObject
924
422
  * @returns
925
- */
926
- }, {
927
- key: "LoadIdsFromSaveResult",
928
- value: function LoadIdsFromSaveResult(o, srObject) {
929
- if (_typeof(o) !== "object" || _typeof(srObject) !== "object") return;
930
- /* -------------------------------------------------------------------------- */
931
- var srID = srObject.insertedId || srObject._id || WebObject.getID(srObject);
932
- if (srID) {
933
- o._id = srID;
934
- }
935
- /* -------------------------------------------------------------------------- */
936
- if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
937
- o._index_value = Number(srObject._index_value);
938
- }
939
- /* -------------------------------------------------------------------------- */
940
- if (srObject._index_key) {
941
- o._index_key = srObject._index_key;
942
- }
943
- }
944
- /* -------------------------------------------------------------------------- */
423
+ */
424
+ static LoadIdsFromSaveResult(o, srObject) {
425
+ if (typeof o !== "object" || typeof srObject !== "object")
426
+ return;
427
+ /* -------------------------------------------------------------------------- */
428
+ const srID = srObject.insertedId || srObject._id || WebObject.getID(srObject);
429
+ if (srID) {
430
+ o._id = srID;
431
+ }
432
+ /* -------------------------------------------------------------------------- */
433
+ if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
434
+ o._index_value = Number(srObject._index_value);
435
+ }
436
+ /* -------------------------------------------------------------------------- */
437
+ if (srObject._index_key) {
438
+ o._index_key = srObject._index_key;
439
+ }
440
+ }
441
+ /* -------------------------------------------------------------------------- */
945
442
  /**
946
443
  * get a single web object
947
444
  * default order of parameters : search,readonly,fetchID
948
- */
949
- }, {
950
- key: "get_single",
951
- value: function get_single() {
952
- return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
953
- var _len8,
954
- p,
955
- _key8,
956
- search,
957
- readonly,
958
- fetchID,
959
- res,
960
- params,
961
- _args17 = arguments;
962
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
963
- while (1) switch (_context17.prev = _context17.next) {
964
- case 0:
965
- for (_len8 = _args17.length, p = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
966
- p[_key8] = _args17[_key8];
967
- }
968
- search = p.shift();
969
- readonly = p.shift();
970
- fetchID = p.shift();
971
- if (!(0, _object.object_isEmpty)(search)) {
972
- _context17.next = 6;
973
- break;
974
- }
975
- return _context17.abrupt("return", undefined);
976
- case 6:
977
- params = {};
978
- params.context = readonly ? "view" : "edit";
979
- _context17.t0 = _typeof(search);
980
- _context17.next = _context17.t0 === "string" ? 11 : _context17.t0 === "number" ? 11 : _context17.t0 === "object" ? 19 : 19;
981
- break;
982
- case 11:
983
- search = String(search);
984
- _context17.t1 = this;
985
- _context17.t2 = this;
986
- _context17.next = 16;
987
- return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
988
- fetchID: fetchID
989
- });
990
- case 16:
991
- _context17.t3 = _context17.sent;
992
- res = _context17.t1.ensure.call(_context17.t1, _context17.t2, _context17.t3);
993
- return _context17.abrupt("break", 25);
994
- case 19:
995
- _context17.t4 = _object.object_first;
996
- _context17.next = 22;
997
- return this.get_list(search, readonly, fetchID);
998
- case 22:
999
- _context17.t5 = _context17.sent;
1000
- res = (0, _context17.t4)(_context17.t5);
1001
- return _context17.abrupt("break", 25);
1002
- case 25:
1003
- WebObject.setReadonly(res, readonly);
1004
- return _context17.abrupt("return", res);
1005
- case 27:
1006
- case "end":
1007
- return _context17.stop();
1008
- }
1009
- }, _callee17, this);
1010
- }))).apply(this, arguments);
1011
- }
445
+ */
446
+ static async get_single(...p) {
447
+ let search = p.shift();
448
+ let readonly = p.shift();
449
+ let fetchID = p.shift();
450
+ if (object_isEmpty(search))
451
+ return undefined;
452
+ let res;
453
+ const params = {};
454
+ params.context = readonly ? "view" : "edit";
455
+ switch (typeof search) {
456
+ case "string":
457
+ case "number":
458
+ search = String(search);
459
+ res = this.ensure(this, await gfunc.run_action("get", this.__web_path + "/" + search, params, { fetchID: fetchID }));
460
+ break;
461
+ case "object":
462
+ default:
463
+ res = object_first(await this.get_list(search, readonly, fetchID));
464
+ break;
465
+ }
466
+ WebObject.setReadonly(res, readonly);
467
+ return res;
468
+ }
1012
469
  /**
1013
470
  * Get a list of web objects
1014
471
  * default order of parameters : search,readonly,fetchID
1015
- */
1016
- }, {
1017
- key: "get_list",
1018
- value: function get_list() {
1019
- return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1020
- var _len9,
1021
- p,
1022
- _key9,
1023
- search,
1024
- readonly,
1025
- fetchID,
1026
- result_items,
1027
- res,
1028
- _args18 = arguments;
1029
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1030
- while (1) switch (_context18.prev = _context18.next) {
1031
- case 0:
1032
- for (_len9 = _args18.length, p = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
1033
- p[_key9] = _args18[_key9];
1034
- }
1035
- search = p.shift();
1036
- readonly = p.shift();
1037
- fetchID = p.shift();
1038
- if (!search) search = {};
1039
- _context18.next = 7;
1040
- return _global.gfunc.run_action("get", this.get_webname(), search, {
1041
- fetchID: fetchID
1042
- });
1043
- case 7:
1044
- result_items = _context18.sent;
1045
- // const selftype = (this.constructor ||
1046
- // Object.getPrototypeOf(this)) as any;
1047
- res = WebObject.map_rowindex(WebObject.mapto(this, result_items, readonly));
1048
- WebObject.setReadonly(res, readonly);
1049
- return _context18.abrupt("return", res);
1050
- case 11:
1051
- case "end":
1052
- return _context18.stop();
1053
- }
1054
- }, _callee18, this);
1055
- }))).apply(this, arguments);
1056
- }
1057
- }]);
1058
- return WebObject;
1059
- }(_index3.SimpleObject);
1060
- exports.WebObject = WebObject;
1061
- _defineProperty(WebObject, "__web_path", "");
1062
- _defineProperty(WebObject, "__web_type", "");
1063
- _defineProperty(WebObject, "__protectedProperties", ["_users"]);
1064
- //you cant create a new weboject without these properties
1065
- _defineProperty(WebObject, "__requiredProperties", []);
1066
- var _default = WebObject;
1067
- exports["default"] = _default;
472
+ */
473
+ static async get_list(...p) {
474
+ let search = p.shift();
475
+ let readonly = p.shift();
476
+ let fetchID = p.shift();
477
+ if (!search)
478
+ search = {};
479
+ let result_items = await gfunc.run_action("get", this.get_webname(), search, { fetchID: fetchID });
480
+ // const selftype = (this.constructor ||
481
+ // Object.getPrototypeOf(this)) as any;
482
+ const res = WebObject.map_rowindex(WebObject.mapto(this, result_items, readonly));
483
+ WebObject.setReadonly(res, readonly);
484
+ return res;
485
+ }
486
+ }
487
+ export default WebObject;