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