@azrico/webobject 1.5.68 → 1.5.70
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 +115 -71
- package/dist/src/WebObjects/WebObject.js +1554 -584
- package/dist/src/WebObjects/WebObjectHelper.js +35 -15
- package/dist/src/WebObjects/WebObjectHelper.test.js +67 -45
- package/dist/src/WebObjects/WebObjectManager.js +864 -265
- package/dist/src/WebObjects/WebObjectPathHelper.js +142 -71
- package/dist/src/WebObjects/WebObjectPathHelper.test.js +122 -31
- package/dist/src/index.js +115 -10
- package/dist/src/structs/DummyObject.js +32 -8
- package/dist/src/structs/MapableObject.js +121 -75
- package/dist/src/structs/MetaObject.js +121 -35
- package/dist/src/structs/ObjectArray.js +68 -43
- package/dist/src/structs/ObjectManager.d.ts +4 -3
- package/dist/src/structs/ObjectManager.js +746 -285
- package/dist/src/structs/ObjectWithTemp.d.ts +2 -2
- package/dist/src/structs/ObjectWithTemp.js +67 -28
- package/dist/src/structs/SimpleObject.d.ts +2 -1
- package/dist/src/structs/SimpleObject.js +1704 -1044
- package/package.json +2 -2
|
@@ -1,270 +1,469 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
var _WebObjectPathHelper = _interopRequireDefault(require("./WebObjectPathHelper"));
|
|
13
|
+
var _WebObjectHelper = _interopRequireDefault(require("./WebObjectHelper"));
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
16
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
|
+
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); }
|
|
19
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
23
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
24
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
25
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
26
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
27
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
28
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
29
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
30
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
31
|
+
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
32
|
+
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
|
|
33
|
+
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
34
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
35
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
36
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
37
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
38
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
39
|
+
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); }
|
|
40
|
+
var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
41
|
+
function WebObject() {
|
|
42
|
+
var _this;
|
|
43
|
+
var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
44
|
+
_classCallCheck(this, WebObject);
|
|
45
|
+
_this = _callSuper(this, WebObject, [is_readonly]);
|
|
46
|
+
_defineProperty(_this, "meta_data", void 0);
|
|
47
|
+
//created date
|
|
48
|
+
_defineProperty(_this, "_created_date", void 0);
|
|
49
|
+
//the owner of the object
|
|
50
|
+
_defineProperty(_this, "_creator", void 0);
|
|
51
|
+
//multiple users can work on one object
|
|
52
|
+
_defineProperty(_this, "_users", void 0);
|
|
53
|
+
_this.meta_data = {};
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* get a list of all user ids that work on the given object
|
|
58
|
+
* _creator + _users + attentions(old)
|
|
59
|
+
* removes duplicates
|
|
60
|
+
* @returns array of ids
|
|
61
|
+
*/
|
|
62
|
+
_inherits(WebObject, _SimpleObject);
|
|
63
|
+
return _createClass(WebObject, [{
|
|
64
|
+
key: "getAllUsers",
|
|
65
|
+
value: function getAllUsers() {
|
|
66
|
+
return WebObject.getAllUsers(this);
|
|
67
|
+
}
|
|
33
68
|
/**
|
|
34
69
|
* get a unique list of all user ids that work on the given object
|
|
35
70
|
* `_creator + _users + attentions`
|
|
36
71
|
* @returns array of ids
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
/* -------------------------------------------------------------------------- */
|
|
46
|
-
/* Meta data */
|
|
47
|
-
/* -------------------------------------------------------------------------- */
|
|
72
|
+
*/
|
|
73
|
+
}, {
|
|
74
|
+
key: "setMetaValue",
|
|
75
|
+
value: (
|
|
76
|
+
/* -------------------------------------------------------------------------- */
|
|
77
|
+
/* Meta data */
|
|
78
|
+
/* -------------------------------------------------------------------------- */
|
|
48
79
|
/**
|
|
49
80
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
50
81
|
* @param key
|
|
51
82
|
* @param value
|
|
52
83
|
* @param sendChange
|
|
53
84
|
* @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
|
-
|
|
85
|
+
*/
|
|
86
|
+
function () {
|
|
87
|
+
var _setMetaValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
|
|
88
|
+
var sendChange,
|
|
89
|
+
old_value,
|
|
90
|
+
new_metalist,
|
|
91
|
+
_args = arguments;
|
|
92
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
93
|
+
while (1) switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
sendChange = _args.length > 2 && _args[2] !== undefined ? _args[2] : "auto";
|
|
96
|
+
if (this.canModify) {
|
|
97
|
+
_context.next = 7;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (!(this.__throw_errors !== false)) {
|
|
101
|
+
_context.next = 6;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
throw Error("Cant use setMetaValue on ".concat(key, " when on readonly mode"));
|
|
105
|
+
case 6:
|
|
106
|
+
return _context.abrupt("return", false);
|
|
107
|
+
case 7:
|
|
108
|
+
if (!(!key || typeof key != "string")) {
|
|
109
|
+
_context.next = 13;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
if (!(this.__throw_errors !== false)) {
|
|
113
|
+
_context.next = 12;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
throw Error("Bad key at setMetaValue");
|
|
117
|
+
case 12:
|
|
118
|
+
return _context.abrupt("return", false);
|
|
119
|
+
case 13:
|
|
120
|
+
old_value = WebObject.getMetaValue(this, key);
|
|
121
|
+
if (!(0, _object.object_equals)(old_value, value)) {
|
|
122
|
+
_context.next = 16;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
return _context.abrupt("return", false);
|
|
126
|
+
case 16:
|
|
127
|
+
//same value, no changes
|
|
128
|
+
new_metalist = _objectSpread({}, this.get("meta_data"));
|
|
129
|
+
new_metalist[key] = value;
|
|
130
|
+
_context.next = 20;
|
|
131
|
+
return this.set("meta_data", new_metalist);
|
|
132
|
+
case 20:
|
|
133
|
+
if (!(sendChange !== false)) {
|
|
134
|
+
_context.next = 23;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
_context.next = 23;
|
|
138
|
+
return this.notifyChanged("meta", key, value);
|
|
139
|
+
case 23:
|
|
140
|
+
return _context.abrupt("return", true);
|
|
141
|
+
case 24:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context.stop();
|
|
144
|
+
}
|
|
145
|
+
}, _callee, this);
|
|
146
|
+
}));
|
|
147
|
+
function setMetaValue(_x, _x2) {
|
|
148
|
+
return _setMetaValue.apply(this, arguments);
|
|
149
|
+
}
|
|
150
|
+
return setMetaValue;
|
|
151
|
+
}()
|
|
78
152
|
/**
|
|
79
153
|
* Get meta value by key
|
|
80
154
|
* @param key
|
|
81
155
|
* @returns value or undefined
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
156
|
+
*/
|
|
157
|
+
)
|
|
158
|
+
}, {
|
|
159
|
+
key: "getMetaValue",
|
|
160
|
+
value: function getMetaValue(key) {
|
|
161
|
+
return WebObject.getMetaValue(this, key);
|
|
162
|
+
}
|
|
86
163
|
/**
|
|
87
164
|
* Get meta value by key
|
|
88
165
|
* @param o
|
|
89
166
|
* @param key
|
|
90
167
|
* @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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
168
|
+
*/
|
|
169
|
+
}, {
|
|
170
|
+
key: "Save",
|
|
171
|
+
value: function () {
|
|
172
|
+
var _Save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
173
|
+
var deltaObject, putAction, usepath, canSaveResult, resultObject;
|
|
174
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
175
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
176
|
+
case 0:
|
|
177
|
+
_context2.prev = 0;
|
|
178
|
+
if (!this.manager) {
|
|
179
|
+
_context2.next = 6;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
_context2.next = 4;
|
|
183
|
+
return this.manager.setOption("saving", true);
|
|
184
|
+
case 4:
|
|
185
|
+
_context2.next = 6;
|
|
186
|
+
return this.manager.setOption("loading", true);
|
|
187
|
+
case 6:
|
|
188
|
+
_context2.next = 8;
|
|
189
|
+
return this.get_deltaObject();
|
|
190
|
+
case 8:
|
|
191
|
+
deltaObject = _context2.sent;
|
|
192
|
+
putAction = "post";
|
|
193
|
+
_context2.next = 12;
|
|
194
|
+
return _WebObjectPathHelper["default"].get_path(this, this.isNew ? "new" : "save");
|
|
195
|
+
case 12:
|
|
196
|
+
usepath = _context2.sent;
|
|
197
|
+
if ((0, _object.object_isEmpty)(deltaObject)) {
|
|
198
|
+
_context2.next = 25;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
canSaveResult = this.canSave(deltaObject);
|
|
202
|
+
if (!(canSaveResult !== true)) {
|
|
203
|
+
_context2.next = 19;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
WebObject.addError(this, "Save not allowed", String(canSaveResult), true);
|
|
207
|
+
this.setSaveResult(false, "canceled");
|
|
208
|
+
return _context2.abrupt("return", false);
|
|
209
|
+
case 19:
|
|
210
|
+
_context2.next = 21;
|
|
211
|
+
return _global.gfunc.run_action(putAction, usepath, deltaObject);
|
|
212
|
+
case 21:
|
|
213
|
+
resultObject = _context2.sent;
|
|
214
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
215
|
+
_context2.next = 26;
|
|
216
|
+
break;
|
|
217
|
+
case 25:
|
|
218
|
+
/* nothing to save */
|
|
219
|
+
this.setSaveResult(null, "nothing");
|
|
220
|
+
case 26:
|
|
221
|
+
if (!this.isSaved) {
|
|
222
|
+
_context2.next = 30;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
_context2.next = 29;
|
|
226
|
+
return this.onSave();
|
|
227
|
+
case 29:
|
|
228
|
+
return _context2.abrupt("return", this.getSaveResult());
|
|
229
|
+
case 30:
|
|
230
|
+
_context2.prev = 30;
|
|
231
|
+
if (!this.manager) {
|
|
232
|
+
_context2.next = 36;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
_context2.next = 34;
|
|
236
|
+
return this.manager.setOption("saving", false);
|
|
237
|
+
case 34:
|
|
238
|
+
_context2.next = 36;
|
|
239
|
+
return this.manager.setOption("loading", false);
|
|
240
|
+
case 36:
|
|
241
|
+
return _context2.finish(30);
|
|
242
|
+
case 37:
|
|
243
|
+
case "end":
|
|
244
|
+
return _context2.stop();
|
|
245
|
+
}
|
|
246
|
+
}, _callee2, this, [[0,, 30, 37]]);
|
|
247
|
+
}));
|
|
248
|
+
function Save() {
|
|
249
|
+
return _Save.apply(this, arguments);
|
|
250
|
+
}
|
|
251
|
+
return Save;
|
|
252
|
+
}()
|
|
253
|
+
}, {
|
|
254
|
+
key: "Delete",
|
|
255
|
+
value: function () {
|
|
256
|
+
var _Delete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
257
|
+
var usepath, resultObject;
|
|
258
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
259
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
260
|
+
case 0:
|
|
261
|
+
if (!this.isNew) {
|
|
262
|
+
_context3.next = 2;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
return _context3.abrupt("return");
|
|
266
|
+
case 2:
|
|
267
|
+
_context3.next = 4;
|
|
268
|
+
return _WebObjectPathHelper["default"].get_path(this, "delete");
|
|
269
|
+
case 4:
|
|
270
|
+
usepath = _context3.sent;
|
|
271
|
+
_context3.next = 7;
|
|
272
|
+
return _global.gfunc.run_action("delete", usepath);
|
|
273
|
+
case 7:
|
|
274
|
+
resultObject = _context3.sent;
|
|
275
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
276
|
+
_context3.next = 11;
|
|
277
|
+
return this.onDelete();
|
|
278
|
+
case 11:
|
|
279
|
+
return _context3.abrupt("return", resultObject);
|
|
280
|
+
case 12:
|
|
281
|
+
case "end":
|
|
282
|
+
return _context3.stop();
|
|
283
|
+
}
|
|
284
|
+
}, _callee3, this);
|
|
285
|
+
}));
|
|
286
|
+
function Delete() {
|
|
287
|
+
return _Delete.apply(this, arguments);
|
|
288
|
+
}
|
|
289
|
+
return Delete;
|
|
290
|
+
}()
|
|
291
|
+
}, {
|
|
292
|
+
key: "Lock",
|
|
293
|
+
value: function () {
|
|
294
|
+
var _Lock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
295
|
+
var usepath, resultObject;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
297
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
if (!(this.isNew || this.isArchived)) {
|
|
300
|
+
_context4.next = 2;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
return _context4.abrupt("return");
|
|
304
|
+
case 2:
|
|
305
|
+
_context4.next = 4;
|
|
306
|
+
return _WebObjectPathHelper["default"].get_path(this, "lock");
|
|
307
|
+
case 4:
|
|
308
|
+
usepath = _context4.sent;
|
|
309
|
+
_context4.next = 7;
|
|
310
|
+
return _global.gfunc.run_action("post", usepath);
|
|
311
|
+
case 7:
|
|
312
|
+
resultObject = _context4.sent;
|
|
313
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
314
|
+
_context4.next = 11;
|
|
315
|
+
return this.onLock();
|
|
316
|
+
case 11:
|
|
317
|
+
return _context4.abrupt("return", resultObject);
|
|
318
|
+
case 12:
|
|
319
|
+
case "end":
|
|
320
|
+
return _context4.stop();
|
|
321
|
+
}
|
|
322
|
+
}, _callee4, this);
|
|
323
|
+
}));
|
|
324
|
+
function Lock() {
|
|
325
|
+
return _Lock.apply(this, arguments);
|
|
326
|
+
}
|
|
327
|
+
return Lock;
|
|
328
|
+
}()
|
|
329
|
+
}, {
|
|
330
|
+
key: "UnLock",
|
|
331
|
+
value: function () {
|
|
332
|
+
var _UnLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
333
|
+
var usepath, resultObject;
|
|
334
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
335
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
336
|
+
case 0:
|
|
337
|
+
if (!(this.isNew || this.isArchived)) {
|
|
338
|
+
_context5.next = 2;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
return _context5.abrupt("return");
|
|
342
|
+
case 2:
|
|
343
|
+
_context5.next = 4;
|
|
344
|
+
return _WebObjectPathHelper["default"].get_path(this, "unlock");
|
|
345
|
+
case 4:
|
|
346
|
+
usepath = _context5.sent;
|
|
347
|
+
_context5.next = 7;
|
|
348
|
+
return _global.gfunc.run_action("post", usepath);
|
|
349
|
+
case 7:
|
|
350
|
+
resultObject = _context5.sent;
|
|
351
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
352
|
+
_context5.next = 11;
|
|
353
|
+
return this.onUnLock();
|
|
354
|
+
case 11:
|
|
355
|
+
return _context5.abrupt("return", resultObject);
|
|
356
|
+
case 12:
|
|
357
|
+
case "end":
|
|
358
|
+
return _context5.stop();
|
|
359
|
+
}
|
|
360
|
+
}, _callee5, this);
|
|
361
|
+
}));
|
|
362
|
+
function UnLock() {
|
|
363
|
+
return _UnLock.apply(this, arguments);
|
|
364
|
+
}
|
|
365
|
+
return UnLock;
|
|
366
|
+
}()
|
|
367
|
+
}, {
|
|
368
|
+
key: "Archive",
|
|
369
|
+
value: function () {
|
|
370
|
+
var _Archive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
371
|
+
var usepath, resultObject;
|
|
372
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
373
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
374
|
+
case 0:
|
|
375
|
+
if (!(this.isNew || this.isArchived)) {
|
|
376
|
+
_context6.next = 2;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
return _context6.abrupt("return");
|
|
380
|
+
case 2:
|
|
381
|
+
_context6.next = 4;
|
|
382
|
+
return _WebObjectPathHelper["default"].get_path(this, "archive");
|
|
383
|
+
case 4:
|
|
384
|
+
usepath = _context6.sent;
|
|
385
|
+
_context6.next = 7;
|
|
386
|
+
return _global.gfunc.run_action("post", usepath);
|
|
387
|
+
case 7:
|
|
388
|
+
resultObject = _context6.sent;
|
|
389
|
+
this.setSaveResult(resultObject, "auto", true);
|
|
390
|
+
_context6.next = 11;
|
|
391
|
+
return this.onArchive();
|
|
392
|
+
case 11:
|
|
393
|
+
return _context6.abrupt("return", resultObject);
|
|
394
|
+
case 12:
|
|
395
|
+
case "end":
|
|
396
|
+
return _context6.stop();
|
|
397
|
+
}
|
|
398
|
+
}, _callee6, this);
|
|
399
|
+
}));
|
|
400
|
+
function Archive() {
|
|
401
|
+
return _Archive.apply(this, arguments);
|
|
402
|
+
}
|
|
403
|
+
return Archive;
|
|
404
|
+
}()
|
|
405
|
+
}, {
|
|
406
|
+
key: "UnArchive",
|
|
407
|
+
value: function () {
|
|
408
|
+
var _UnArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
409
|
+
var usepath, resultObject;
|
|
410
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
411
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
412
|
+
case 0:
|
|
413
|
+
if (!(this.isNew || !this.isArchived)) {
|
|
414
|
+
_context7.next = 2;
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
return _context7.abrupt("return");
|
|
418
|
+
case 2:
|
|
419
|
+
_context7.next = 4;
|
|
420
|
+
return _WebObjectPathHelper["default"].get_path(this, "unarchive");
|
|
421
|
+
case 4:
|
|
422
|
+
usepath = _context7.sent;
|
|
423
|
+
_context7.next = 7;
|
|
424
|
+
return _global.gfunc.run_action("post", usepath);
|
|
425
|
+
case 7:
|
|
426
|
+
resultObject = _context7.sent;
|
|
427
|
+
_context7.next = 10;
|
|
428
|
+
return this.onUnArchive();
|
|
429
|
+
case 10:
|
|
430
|
+
return _context7.abrupt("return", resultObject);
|
|
431
|
+
case 11:
|
|
432
|
+
case "end":
|
|
433
|
+
return _context7.stop();
|
|
434
|
+
}
|
|
435
|
+
}, _callee7, this);
|
|
436
|
+
}));
|
|
437
|
+
function UnArchive() {
|
|
438
|
+
return _UnArchive.apply(this, arguments);
|
|
439
|
+
}
|
|
440
|
+
return UnArchive;
|
|
441
|
+
}() /* -------------------------------------------------------------------------- */
|
|
442
|
+
}, {
|
|
443
|
+
key: "canSave",
|
|
444
|
+
value: function canSave(deltaObj) {
|
|
445
|
+
var deltaRes = this.deltaIsValid(deltaObj);
|
|
446
|
+
if (deltaRes !== true) return deltaRes;
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
}, {
|
|
450
|
+
key: "canDelete",
|
|
451
|
+
value: function canDelete() {
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
key: "canArchive",
|
|
456
|
+
value: function canArchive() {
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
key: "deltaIsValid",
|
|
461
|
+
value: function deltaIsValid(d) {
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
/* -------------------------------------------------------------------------- */
|
|
465
|
+
/* get delta */
|
|
466
|
+
/* -------------------------------------------------------------------------- */
|
|
268
467
|
/**
|
|
269
468
|
* converts this object to an basic object
|
|
270
469
|
* that can be passed into client components from server components
|
|
@@ -272,383 +471,1154 @@ export class WebObject extends SimpleObject {
|
|
|
272
471
|
* uses `get_fullDeltaObject`
|
|
273
472
|
* @param p
|
|
274
473
|
* @returns
|
|
275
|
-
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
474
|
+
*/
|
|
475
|
+
}, {
|
|
476
|
+
key: "get_basicObject",
|
|
477
|
+
value: (function () {
|
|
478
|
+
var _get_basicObject = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
479
|
+
var fullobject, key, element;
|
|
480
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
481
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
482
|
+
case 0:
|
|
483
|
+
_context8.next = 2;
|
|
484
|
+
return this.get_fullObject();
|
|
485
|
+
case 2:
|
|
486
|
+
fullobject = _context8.sent;
|
|
487
|
+
for (key in fullobject) {
|
|
488
|
+
element = fullobject[key];
|
|
489
|
+
/* --------------------------- check for id fields -------------------------- */
|
|
490
|
+
if (element != null && _typeof(element) === "object") {
|
|
491
|
+
if ((key === "id" || key.endsWith("_id")) && typeof element.toString === "function") {
|
|
492
|
+
fullobject[key] = String(element);
|
|
493
|
+
} else {
|
|
494
|
+
fullobject[key] = JSON.parse(JSON.stringify(element));
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return _context8.abrupt("return", fullobject);
|
|
499
|
+
case 5:
|
|
500
|
+
case "end":
|
|
501
|
+
return _context8.stop();
|
|
502
|
+
}
|
|
503
|
+
}, _callee8, this);
|
|
504
|
+
}));
|
|
505
|
+
function get_basicObject() {
|
|
506
|
+
return _get_basicObject.apply(this, arguments);
|
|
507
|
+
}
|
|
508
|
+
return get_basicObject;
|
|
509
|
+
}()
|
|
293
510
|
/**
|
|
294
511
|
* calls the `get_deltaObject` with
|
|
295
512
|
* `allProperties` `extraProperties`
|
|
296
513
|
* set to true
|
|
297
514
|
*
|
|
298
515
|
* @returns
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
516
|
+
*/
|
|
517
|
+
)
|
|
518
|
+
}, {
|
|
519
|
+
key: "get_fullDeltaObject",
|
|
520
|
+
value: (function () {
|
|
521
|
+
var _get_fullDeltaObject = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(p) {
|
|
522
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
523
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
524
|
+
case 0:
|
|
525
|
+
_context9.next = 2;
|
|
526
|
+
return this.get_deltaObject(_objectSpread({
|
|
527
|
+
allProperties: true,
|
|
528
|
+
extraProperties: true
|
|
529
|
+
}, p));
|
|
530
|
+
case 2:
|
|
531
|
+
return _context9.abrupt("return", _context9.sent);
|
|
532
|
+
case 3:
|
|
533
|
+
case "end":
|
|
534
|
+
return _context9.stop();
|
|
535
|
+
}
|
|
536
|
+
}, _callee9, this);
|
|
537
|
+
}));
|
|
538
|
+
function get_fullDeltaObject(_x3) {
|
|
539
|
+
return _get_fullDeltaObject.apply(this, arguments);
|
|
540
|
+
}
|
|
541
|
+
return get_fullDeltaObject;
|
|
542
|
+
}()
|
|
307
543
|
/**
|
|
308
544
|
* calls the `get_deltaObject` with
|
|
309
545
|
* `allProperties` `extraProperties` `tempProperties`
|
|
310
546
|
* set to true
|
|
311
547
|
*
|
|
312
548
|
* @returns
|
|
313
|
-
*/
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
549
|
+
*/
|
|
550
|
+
)
|
|
551
|
+
}, {
|
|
552
|
+
key: "get_fullObject",
|
|
553
|
+
value: (function () {
|
|
554
|
+
var _get_fullObject = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(p) {
|
|
555
|
+
return _regeneratorRuntime().wrap(function _callee0$(_context0) {
|
|
556
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
557
|
+
case 0:
|
|
558
|
+
_context0.next = 2;
|
|
559
|
+
return this.get_deltaObject(_objectSpread({
|
|
560
|
+
allProperties: true,
|
|
561
|
+
extraProperties: true,
|
|
562
|
+
tempProperties: true
|
|
563
|
+
}, p));
|
|
564
|
+
case 2:
|
|
565
|
+
return _context0.abrupt("return", _context0.sent);
|
|
566
|
+
case 3:
|
|
567
|
+
case "end":
|
|
568
|
+
return _context0.stop();
|
|
569
|
+
}
|
|
570
|
+
}, _callee0, this);
|
|
571
|
+
}));
|
|
572
|
+
function get_fullObject(_x4) {
|
|
573
|
+
return _get_fullObject.apply(this, arguments);
|
|
574
|
+
}
|
|
575
|
+
return get_fullObject;
|
|
576
|
+
}()
|
|
322
577
|
/**
|
|
323
578
|
* You will post this to the server for saving
|
|
324
579
|
* automatically removes unchangeable fields
|
|
325
580
|
* @returns
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
581
|
+
*/
|
|
582
|
+
)
|
|
583
|
+
}, {
|
|
584
|
+
key: "get_deltaObject",
|
|
585
|
+
value: (function () {
|
|
586
|
+
var _get_deltaObject = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(p) {
|
|
587
|
+
var final_object, useDelta, changedFields, key, changeableKeys, functionProps, index, fp, parseObj, _parseObj, _iterator, _step, _key, gotIndex, gotId, tempusers;
|
|
588
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
589
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
590
|
+
case 0:
|
|
591
|
+
_parseObj = function _parseObj3() {
|
|
592
|
+
_parseObj = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, obj) {
|
|
593
|
+
var _p, _child_changeableKeys, keydot, child_changeableKeys, newobj_dlt;
|
|
594
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
595
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
596
|
+
case 0:
|
|
597
|
+
if (!(obj == null)) {
|
|
598
|
+
_context10.next = 2;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
return _context10.abrupt("return", undefined);
|
|
602
|
+
case 2:
|
|
603
|
+
if (!Array.isArray(obj)) {
|
|
604
|
+
_context10.next = 6;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
_context10.next = 5;
|
|
608
|
+
return Promise.all(obj.map(/*#__PURE__*/function () {
|
|
609
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(r, i) {
|
|
610
|
+
return _regeneratorRuntime().wrap(function _callee1$(_context1) {
|
|
611
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
612
|
+
case 0:
|
|
613
|
+
_context1.next = 2;
|
|
614
|
+
return parseObj(key, r);
|
|
615
|
+
case 2:
|
|
616
|
+
return _context1.abrupt("return", _context1.sent);
|
|
617
|
+
case 3:
|
|
618
|
+
case "end":
|
|
619
|
+
return _context1.stop();
|
|
620
|
+
}
|
|
621
|
+
}, _callee1);
|
|
622
|
+
}));
|
|
623
|
+
return function (_x8, _x9) {
|
|
624
|
+
return _ref.apply(this, arguments);
|
|
625
|
+
};
|
|
626
|
+
}()));
|
|
627
|
+
case 5:
|
|
628
|
+
return _context10.abrupt("return", _context10.sent);
|
|
629
|
+
case 6:
|
|
630
|
+
if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
|
|
631
|
+
_context10.next = 18;
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
/* -------------------- parse changeableKeys for children -------------------- */
|
|
635
|
+
keydot = "".concat(key, ".");
|
|
636
|
+
child_changeableKeys = (_p = p) === null || _p === void 0 || (_p = _p.changeableKeys) === null || _p === void 0 ? void 0 : _p.filter(function (s) {
|
|
637
|
+
return s.startsWith(keydot);
|
|
638
|
+
}).map(function (r) {
|
|
639
|
+
return r.substring(keydot.length);
|
|
640
|
+
});
|
|
641
|
+
/**
|
|
642
|
+
* if no key is set for children consider it as undefined
|
|
643
|
+
* if we send the empty array to get_delta we get no keys
|
|
644
|
+
*/
|
|
645
|
+
if (child_changeableKeys == null || ((_child_changeableKeys = child_changeableKeys) === null || _child_changeableKeys === void 0 ? void 0 : _child_changeableKeys.length) === 0) {
|
|
646
|
+
child_changeableKeys = undefined;
|
|
647
|
+
}
|
|
648
|
+
/* -------------------------------------------------------------------------- */
|
|
649
|
+
//child elements have different kind of delta
|
|
650
|
+
_context10.next = 12;
|
|
651
|
+
return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
|
|
652
|
+
isChild: true,
|
|
653
|
+
changeableKeys: child_changeableKeys
|
|
654
|
+
}));
|
|
655
|
+
case 12:
|
|
656
|
+
newobj_dlt = _context10.sent;
|
|
657
|
+
if ((0, _object.object_isEmpty)(newobj_dlt)) {
|
|
658
|
+
_context10.next = 17;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
return _context10.abrupt("return", newobj_dlt);
|
|
662
|
+
case 17:
|
|
663
|
+
return _context10.abrupt("return", obj);
|
|
664
|
+
case 18:
|
|
665
|
+
return _context10.abrupt("return", obj);
|
|
666
|
+
case 19:
|
|
667
|
+
case "end":
|
|
668
|
+
return _context10.stop();
|
|
669
|
+
}
|
|
670
|
+
}, _callee10);
|
|
671
|
+
}));
|
|
672
|
+
return _parseObj.apply(this, arguments);
|
|
673
|
+
};
|
|
674
|
+
parseObj = function _parseObj2(_x6, _x7) {
|
|
675
|
+
return _parseObj.apply(this, arguments);
|
|
676
|
+
};
|
|
677
|
+
if (!p) p = {};
|
|
678
|
+
final_object = {};
|
|
679
|
+
useDelta = Boolean(this.__use_delta || p.useDelta);
|
|
680
|
+
/**
|
|
681
|
+
* child objects usually dont update their __delta
|
|
682
|
+
* so we read info from all of its properties
|
|
683
|
+
*/
|
|
684
|
+
changedFields = Boolean(p.allProperties || p.isChild || !useDelta) ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
|
|
685
|
+
/* ------------- parse children that have WebObject as delta ------------- */
|
|
686
|
+
_context11.t0 = _regeneratorRuntime().keys(this);
|
|
687
|
+
case 7:
|
|
688
|
+
if ((_context11.t1 = _context11.t0()).done) {
|
|
689
|
+
_context11.next = 14;
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
key = _context11.t1.value;
|
|
693
|
+
if (!(key.startsWith("__") || key in changedFields)) {
|
|
694
|
+
_context11.next = 11;
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
return _context11.abrupt("continue", 7);
|
|
698
|
+
case 11:
|
|
699
|
+
if (_WebObjectHelper["default"].isChangedWebObjectField(this[key])) {
|
|
344
700
|
/**
|
|
345
701
|
* if a child has any change we must add it into our delta
|
|
346
702
|
* notice that the changes may not be saved to database depending on __changeables
|
|
347
703
|
* but they are changes nevertheless
|
|
348
|
-
*/
|
|
349
|
-
changedFields[key] = this[key];
|
|
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
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
704
|
+
*/
|
|
705
|
+
changedFields[key] = this[key];
|
|
706
|
+
}
|
|
707
|
+
_context11.next = 7;
|
|
708
|
+
break;
|
|
709
|
+
case 14:
|
|
710
|
+
/**
|
|
711
|
+
* get keys that can be changed.
|
|
712
|
+
* intersection of keys in delta and keys that are defined as changeable
|
|
713
|
+
*/
|
|
714
|
+
changeableKeys = (0, _object.array_intersection)(Object.keys(changedFields), WebObject.getChangeableKeys(this, p));
|
|
715
|
+
/**
|
|
716
|
+
* if parameter of changeableKeys is given, limit our keys with that param
|
|
717
|
+
*/
|
|
718
|
+
if (p.changeableKeys) {
|
|
719
|
+
changeableKeys = (0, _object.array_intersection)(changeableKeys, p.changeableKeys);
|
|
720
|
+
}
|
|
721
|
+
/* -------------------------------------------------------------------------- */
|
|
722
|
+
_convert["default"].format({
|
|
723
|
+
original: this,
|
|
724
|
+
inputobject: changedFields,
|
|
725
|
+
formats: (0, _object.object_getStatic)(this, "__formatList"),
|
|
726
|
+
isNew: this.isNew,
|
|
727
|
+
changeableKeys: changeableKeys,
|
|
728
|
+
applyDefaults: true
|
|
729
|
+
});
|
|
730
|
+
/* -------------------------------------------------------------------------- */
|
|
731
|
+
/* __functionProperties */
|
|
732
|
+
/* -------------------------------------------------------------------------- */
|
|
733
|
+
functionProps = (0, _object.object_getStatic)(this, "__functionProperties");
|
|
734
|
+
for (index = 0; index < functionProps.length; index++) {
|
|
735
|
+
fp = functionProps[index];
|
|
736
|
+
if (changedFields[fp]) changedFields[fp] = (0, _object.fn_eval_this)(this, changedFields[fp]);
|
|
737
|
+
}
|
|
738
|
+
/* -------------------------------------------------------------------------- */
|
|
739
|
+
/* parse all changeableKeys */
|
|
740
|
+
/* -------------------------------------------------------------------------- */
|
|
741
|
+
_iterator = _createForOfIteratorHelper(changeableKeys);
|
|
742
|
+
_context11.prev = 20;
|
|
743
|
+
_iterator.s();
|
|
744
|
+
case 22:
|
|
745
|
+
if ((_step = _iterator.n()).done) {
|
|
746
|
+
_context11.next = 29;
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
_key = _step.value;
|
|
750
|
+
_context11.next = 26;
|
|
751
|
+
return parseObj(_key, changedFields[_key]);
|
|
752
|
+
case 26:
|
|
753
|
+
final_object[_key] = _context11.sent;
|
|
754
|
+
case 27:
|
|
755
|
+
_context11.next = 22;
|
|
756
|
+
break;
|
|
757
|
+
case 29:
|
|
758
|
+
_context11.next = 34;
|
|
759
|
+
break;
|
|
760
|
+
case 31:
|
|
761
|
+
_context11.prev = 31;
|
|
762
|
+
_context11.t2 = _context11["catch"](20);
|
|
763
|
+
_iterator.e(_context11.t2);
|
|
764
|
+
case 34:
|
|
765
|
+
_context11.prev = 34;
|
|
766
|
+
_iterator.f();
|
|
767
|
+
return _context11.finish(34);
|
|
768
|
+
case 37:
|
|
769
|
+
/* -------------------- add acrhived and date properties -------------------- */
|
|
770
|
+
if (p.allProperties) {
|
|
771
|
+
final_object["_created_date"] = this["_created_date"];
|
|
772
|
+
final_object["_archived"] = this.isArchived;
|
|
773
|
+
final_object["_deleted"] = this.isDeleted;
|
|
774
|
+
}
|
|
775
|
+
if (p.tempProperties) {
|
|
776
|
+
final_object["__temp"] = this.__temp;
|
|
777
|
+
}
|
|
778
|
+
/* ---------------------------- add id properties --------------------------- */
|
|
779
|
+
if (p.allProperties || p.needId || p.isChild) {
|
|
780
|
+
if (this["_index_key"]) final_object["_index_key"] = this["_index_key"];
|
|
781
|
+
gotIndex = this.getIndex();
|
|
782
|
+
gotId = this.getID();
|
|
783
|
+
if (gotIndex && gotIndex >= 0) final_object["_index_value"] = gotIndex;
|
|
784
|
+
if (gotId) final_object["_id"] = gotId;
|
|
785
|
+
}
|
|
786
|
+
/* -------------------------------------------------------------------------- */
|
|
787
|
+
/* fix _user property */
|
|
788
|
+
/* -------------------------------------------------------------------------- */
|
|
789
|
+
if (final_object["_users"]) {
|
|
790
|
+
tempusers = final_object["_users"];
|
|
791
|
+
if (typeof tempusers === "string") tempusers = tempusers.split(",").filter(function (s) {
|
|
792
|
+
return s;
|
|
793
|
+
});
|
|
794
|
+
final_object["_users"] = (0, _object.wrap_array)(tempusers);
|
|
795
|
+
}
|
|
796
|
+
if (!p.clean) {
|
|
797
|
+
_context11.next = 43;
|
|
798
|
+
break;
|
|
799
|
+
}
|
|
800
|
+
return _context11.abrupt("return", (0, _object.object_clean)(final_object, false, true));
|
|
801
|
+
case 43:
|
|
802
|
+
return _context11.abrupt("return", final_object);
|
|
803
|
+
case 44:
|
|
804
|
+
case "end":
|
|
805
|
+
return _context11.stop();
|
|
806
|
+
}
|
|
807
|
+
}, _callee11, this, [[20, 31, 34, 37]]);
|
|
808
|
+
}));
|
|
809
|
+
function get_deltaObject(_x5) {
|
|
810
|
+
return _get_deltaObject.apply(this, arguments);
|
|
811
|
+
}
|
|
812
|
+
return get_deltaObject;
|
|
813
|
+
}() /* --------------------------------- Getters -------------------------------- */)
|
|
814
|
+
}, {
|
|
815
|
+
key: "manager",
|
|
816
|
+
get: function get() {
|
|
817
|
+
return this.get_managerClass() || undefined;
|
|
818
|
+
}
|
|
819
|
+
}, {
|
|
820
|
+
key: "__web_path",
|
|
821
|
+
get: function get() {
|
|
822
|
+
return this.constructor["__web_path"] || this.__db_name;
|
|
823
|
+
}
|
|
824
|
+
}, {
|
|
825
|
+
key: "get_webpath",
|
|
826
|
+
value: function get_webpath() {
|
|
827
|
+
return this.__web_path || this.__db_name || "";
|
|
828
|
+
}
|
|
829
|
+
}, {
|
|
830
|
+
key: "onDelete",
|
|
831
|
+
value: (/* -------------------------------------------------------------------------- */function () {
|
|
832
|
+
var _onDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
833
|
+
var _this$manager;
|
|
834
|
+
var _len,
|
|
835
|
+
p,
|
|
836
|
+
_key2,
|
|
837
|
+
_args12 = arguments;
|
|
838
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
839
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
840
|
+
case 0:
|
|
841
|
+
if (this.isSaved) this.isDeleted = true;
|
|
842
|
+
for (_len = _args12.length, p = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
|
|
843
|
+
p[_key2] = _args12[_key2];
|
|
844
|
+
}
|
|
845
|
+
_context12.next = 4;
|
|
846
|
+
return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
|
|
847
|
+
case 4:
|
|
848
|
+
return _context12.abrupt("return", _context12.sent);
|
|
849
|
+
case 5:
|
|
850
|
+
case "end":
|
|
851
|
+
return _context12.stop();
|
|
852
|
+
}
|
|
853
|
+
}, _callee12, this);
|
|
854
|
+
}));
|
|
855
|
+
function onDelete() {
|
|
856
|
+
return _onDelete.apply(this, arguments);
|
|
857
|
+
}
|
|
858
|
+
return onDelete;
|
|
859
|
+
}())
|
|
860
|
+
}, {
|
|
861
|
+
key: "onArchive",
|
|
862
|
+
value: function () {
|
|
863
|
+
var _onArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
864
|
+
var _this$manager2;
|
|
865
|
+
var _len2,
|
|
866
|
+
p,
|
|
867
|
+
_key3,
|
|
868
|
+
_args13 = arguments;
|
|
869
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
870
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
871
|
+
case 0:
|
|
872
|
+
if (this.isSaved) this.isArchived = true;
|
|
873
|
+
for (_len2 = _args13.length, p = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
|
|
874
|
+
p[_key3] = _args13[_key3];
|
|
875
|
+
}
|
|
876
|
+
_context13.next = 4;
|
|
877
|
+
return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onArchive.apply(_this$manager2, p);
|
|
878
|
+
case 4:
|
|
879
|
+
return _context13.abrupt("return", _context13.sent);
|
|
880
|
+
case 5:
|
|
881
|
+
case "end":
|
|
882
|
+
return _context13.stop();
|
|
883
|
+
}
|
|
884
|
+
}, _callee13, this);
|
|
885
|
+
}));
|
|
886
|
+
function onArchive() {
|
|
887
|
+
return _onArchive.apply(this, arguments);
|
|
888
|
+
}
|
|
889
|
+
return onArchive;
|
|
890
|
+
}()
|
|
891
|
+
}, {
|
|
892
|
+
key: "onUnArchive",
|
|
893
|
+
value: function () {
|
|
894
|
+
var _onUnArchive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
895
|
+
var _this$manager3;
|
|
896
|
+
var _len3,
|
|
897
|
+
p,
|
|
898
|
+
_key4,
|
|
899
|
+
_args14 = arguments;
|
|
900
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
901
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
902
|
+
case 0:
|
|
903
|
+
if (this.isSaved) this.isArchived = false;
|
|
904
|
+
for (_len3 = _args14.length, p = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {
|
|
905
|
+
p[_key4] = _args14[_key4];
|
|
906
|
+
}
|
|
907
|
+
_context14.next = 4;
|
|
908
|
+
return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onUnArchive.apply(_this$manager3, p);
|
|
909
|
+
case 4:
|
|
910
|
+
return _context14.abrupt("return", _context14.sent);
|
|
911
|
+
case 5:
|
|
912
|
+
case "end":
|
|
913
|
+
return _context14.stop();
|
|
914
|
+
}
|
|
915
|
+
}, _callee14, this);
|
|
916
|
+
}));
|
|
917
|
+
function onUnArchive() {
|
|
918
|
+
return _onUnArchive.apply(this, arguments);
|
|
919
|
+
}
|
|
920
|
+
return onUnArchive;
|
|
921
|
+
}()
|
|
922
|
+
}, {
|
|
923
|
+
key: "onLock",
|
|
924
|
+
value: function () {
|
|
925
|
+
var _onLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
926
|
+
var _this$manager4;
|
|
927
|
+
var _len4,
|
|
928
|
+
p,
|
|
929
|
+
_key5,
|
|
930
|
+
_args15 = arguments;
|
|
931
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
932
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
933
|
+
case 0:
|
|
934
|
+
if (this.isSaved) this.isLocked = true;
|
|
935
|
+
for (_len4 = _args15.length, p = new Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {
|
|
936
|
+
p[_key5] = _args15[_key5];
|
|
937
|
+
}
|
|
938
|
+
_context15.next = 4;
|
|
939
|
+
return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onLock.apply(_this$manager4, p);
|
|
940
|
+
case 4:
|
|
941
|
+
return _context15.abrupt("return", _context15.sent);
|
|
942
|
+
case 5:
|
|
943
|
+
case "end":
|
|
944
|
+
return _context15.stop();
|
|
945
|
+
}
|
|
946
|
+
}, _callee15, this);
|
|
947
|
+
}));
|
|
948
|
+
function onLock() {
|
|
949
|
+
return _onLock.apply(this, arguments);
|
|
950
|
+
}
|
|
951
|
+
return onLock;
|
|
952
|
+
}()
|
|
953
|
+
}, {
|
|
954
|
+
key: "onUnLock",
|
|
955
|
+
value: function () {
|
|
956
|
+
var _onUnLock = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
957
|
+
var _this$manager5;
|
|
958
|
+
var _len5,
|
|
959
|
+
p,
|
|
960
|
+
_key6,
|
|
961
|
+
_args16 = arguments;
|
|
962
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
963
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
964
|
+
case 0:
|
|
965
|
+
if (this.isSaved) this.isLocked = false;
|
|
966
|
+
for (_len5 = _args16.length, p = new Array(_len5), _key6 = 0; _key6 < _len5; _key6++) {
|
|
967
|
+
p[_key6] = _args16[_key6];
|
|
968
|
+
}
|
|
969
|
+
_context16.next = 4;
|
|
970
|
+
return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onUnLock.apply(_this$manager5, p);
|
|
971
|
+
case 4:
|
|
972
|
+
return _context16.abrupt("return", _context16.sent);
|
|
973
|
+
case 5:
|
|
974
|
+
case "end":
|
|
975
|
+
return _context16.stop();
|
|
976
|
+
}
|
|
977
|
+
}, _callee16, this);
|
|
978
|
+
}));
|
|
979
|
+
function onUnLock() {
|
|
980
|
+
return _onUnLock.apply(this, arguments);
|
|
981
|
+
}
|
|
982
|
+
return onUnLock;
|
|
983
|
+
}()
|
|
984
|
+
}, {
|
|
985
|
+
key: "onLoad",
|
|
986
|
+
value: function () {
|
|
987
|
+
var _onLoad = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
988
|
+
var _this$manager6;
|
|
989
|
+
var _len6,
|
|
990
|
+
p,
|
|
991
|
+
_key7,
|
|
992
|
+
_args17 = arguments;
|
|
993
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
994
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
995
|
+
case 0:
|
|
996
|
+
this.isDeleted = false;
|
|
997
|
+
for (_len6 = _args17.length, p = new Array(_len6), _key7 = 0; _key7 < _len6; _key7++) {
|
|
998
|
+
p[_key7] = _args17[_key7];
|
|
999
|
+
}
|
|
1000
|
+
_context17.next = 4;
|
|
1001
|
+
return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onLoad.apply(_this$manager6, p);
|
|
1002
|
+
case 4:
|
|
1003
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1004
|
+
case 5:
|
|
1005
|
+
case "end":
|
|
1006
|
+
return _context17.stop();
|
|
1007
|
+
}
|
|
1008
|
+
}, _callee17, this);
|
|
1009
|
+
}));
|
|
1010
|
+
function onLoad() {
|
|
1011
|
+
return _onLoad.apply(this, arguments);
|
|
1012
|
+
}
|
|
1013
|
+
return onLoad;
|
|
1014
|
+
}()
|
|
1015
|
+
}, {
|
|
1016
|
+
key: "onSave",
|
|
1017
|
+
value: function () {
|
|
1018
|
+
var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1019
|
+
var _this$manager8;
|
|
1020
|
+
var srObject,
|
|
1021
|
+
_this$manager7,
|
|
1022
|
+
_len7,
|
|
1023
|
+
p,
|
|
1024
|
+
_key8,
|
|
1025
|
+
_args18 = arguments;
|
|
1026
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1027
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1028
|
+
case 0:
|
|
1029
|
+
if (!this.isSaved) {
|
|
1030
|
+
_context18.next = 7;
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
this.apply_changes();
|
|
1034
|
+
srObject = this.getSaveResult(true);
|
|
1035
|
+
if (!this.saveResultHasID(srObject)) {
|
|
1036
|
+
_context18.next = 7;
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
/* -------------------------------------------------------------------------- */
|
|
1040
|
+
WebObject.LoadIdsFromSaveResult(this, srObject);
|
|
1041
|
+
_context18.next = 7;
|
|
1042
|
+
return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.event_run("on_id_change");
|
|
1043
|
+
case 7:
|
|
1044
|
+
for (_len7 = _args18.length, p = new Array(_len7), _key8 = 0; _key8 < _len7; _key8++) {
|
|
1045
|
+
p[_key8] = _args18[_key8];
|
|
1046
|
+
}
|
|
1047
|
+
_context18.next = 10;
|
|
1048
|
+
return (_this$manager8 = this.manager) === null || _this$manager8 === void 0 ? void 0 : _this$manager8.onSave.apply(_this$manager8, p);
|
|
1049
|
+
case 10:
|
|
1050
|
+
_context18.next = 12;
|
|
1051
|
+
return this.onAfterSave();
|
|
1052
|
+
case 12:
|
|
1053
|
+
return _context18.abrupt("return", true);
|
|
1054
|
+
case 13:
|
|
1055
|
+
case "end":
|
|
1056
|
+
return _context18.stop();
|
|
1057
|
+
}
|
|
1058
|
+
}, _callee18, this);
|
|
1059
|
+
}));
|
|
1060
|
+
function onSave() {
|
|
1061
|
+
return _onSave.apply(this, arguments);
|
|
1062
|
+
}
|
|
1063
|
+
return onSave;
|
|
1064
|
+
}()
|
|
1065
|
+
}, {
|
|
1066
|
+
key: "onAfterSave",
|
|
1067
|
+
value: function () {
|
|
1068
|
+
var _onAfterSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1069
|
+
var _this$manager9;
|
|
1070
|
+
var _len8,
|
|
1071
|
+
p,
|
|
1072
|
+
_key9,
|
|
1073
|
+
_args19 = arguments;
|
|
1074
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1075
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1076
|
+
case 0:
|
|
1077
|
+
for (_len8 = _args19.length, p = new Array(_len8), _key9 = 0; _key9 < _len8; _key9++) {
|
|
1078
|
+
p[_key9] = _args19[_key9];
|
|
1079
|
+
}
|
|
1080
|
+
_context19.next = 3;
|
|
1081
|
+
return (_this$manager9 = this.manager) === null || _this$manager9 === void 0 ? void 0 : _this$manager9.onAfterSave.apply(_this$manager9, p);
|
|
1082
|
+
case 3:
|
|
1083
|
+
return _context19.abrupt("return", true);
|
|
1084
|
+
case 4:
|
|
1085
|
+
case "end":
|
|
1086
|
+
return _context19.stop();
|
|
1087
|
+
}
|
|
1088
|
+
}, _callee19, this);
|
|
1089
|
+
}));
|
|
1090
|
+
function onAfterSave() {
|
|
1091
|
+
return _onAfterSave.apply(this, arguments);
|
|
1092
|
+
}
|
|
1093
|
+
return onAfterSave;
|
|
1094
|
+
}()
|
|
1095
|
+
}, {
|
|
1096
|
+
key: "getSaveResult",
|
|
1097
|
+
value: function getSaveResult() {
|
|
1098
|
+
var _this2 = this;
|
|
1099
|
+
var original = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1100
|
+
var srObject = _superPropGet(WebObject, "getSaveResult", this, 3)([original]);
|
|
1101
|
+
if (!srObject) return false;
|
|
1102
|
+
if (Array.isArray(srObject)) {
|
|
1103
|
+
var actual_sr = srObject.find(function (s) {
|
|
1104
|
+
return _this2.saveResultHasID(s);
|
|
1105
|
+
});
|
|
1106
|
+
if (actual_sr) srObject = actual_sr;
|
|
1107
|
+
}
|
|
1108
|
+
return srObject;
|
|
1109
|
+
}
|
|
1110
|
+
}, {
|
|
1111
|
+
key: "onNew",
|
|
1112
|
+
value: function () {
|
|
1113
|
+
var _onNew = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1114
|
+
var _this$manager0;
|
|
1115
|
+
var _len9,
|
|
1116
|
+
p,
|
|
1117
|
+
_key0,
|
|
1118
|
+
_args20 = arguments;
|
|
1119
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1120
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1121
|
+
case 0:
|
|
1122
|
+
for (_len9 = _args20.length, p = new Array(_len9), _key0 = 0; _key0 < _len9; _key0++) {
|
|
1123
|
+
p[_key0] = _args20[_key0];
|
|
1124
|
+
}
|
|
1125
|
+
_context20.next = 3;
|
|
1126
|
+
return (_this$manager0 = this.manager) === null || _this$manager0 === void 0 ? void 0 : _this$manager0.onNew.apply(_this$manager0, p);
|
|
1127
|
+
case 3:
|
|
1128
|
+
return _context20.abrupt("return", _context20.sent);
|
|
1129
|
+
case 4:
|
|
1130
|
+
case "end":
|
|
1131
|
+
return _context20.stop();
|
|
1132
|
+
}
|
|
1133
|
+
}, _callee20, this);
|
|
1134
|
+
}));
|
|
1135
|
+
function onNew() {
|
|
1136
|
+
return _onNew.apply(this, arguments);
|
|
1137
|
+
}
|
|
1138
|
+
return onNew;
|
|
1139
|
+
}() /* -------------------------------------------------------------------------- */
|
|
1140
|
+
}, {
|
|
1141
|
+
key: "saveResultHasID",
|
|
1142
|
+
value: function saveResultHasID(s) {
|
|
1143
|
+
return WebObject.saveResultHasID(s);
|
|
1144
|
+
}
|
|
1145
|
+
}], [{
|
|
1146
|
+
key: "getAllUsers",
|
|
1147
|
+
value: function getAllUsers(obj) {
|
|
1148
|
+
if (_typeof(obj) != "object") return [];
|
|
1149
|
+
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) {
|
|
1150
|
+
return String(_typeof(r) === "object" ? WebObject.getID(r) : r);
|
|
1151
|
+
}).filter(function (s) {
|
|
1152
|
+
return s;
|
|
1153
|
+
}));
|
|
1154
|
+
}
|
|
1155
|
+
}, {
|
|
1156
|
+
key: "getMetaValue",
|
|
1157
|
+
value: function getMetaValue(o, key) {
|
|
1158
|
+
if (o == null) return null;
|
|
1159
|
+
if (!key || typeof key != "string") return undefined;
|
|
1160
|
+
var metalist = {};
|
|
1161
|
+
if (_typeof(o) === "object") {
|
|
1162
|
+
metalist = typeof o.get === "function" ? o.get("meta_data") : o.meta_data;
|
|
1163
|
+
}
|
|
1164
|
+
return metalist[key];
|
|
1165
|
+
}
|
|
1166
|
+
/* -------------------------------------------------------------------------- */
|
|
1167
|
+
/* Save */
|
|
1168
|
+
/* -------------------------------------------------------------------------- */
|
|
1169
|
+
}, {
|
|
1170
|
+
key: "zipSaveList",
|
|
1171
|
+
value: function zipSaveList(svlist) {
|
|
1172
|
+
if (_typeof(svlist) === "object") svlist = JSON.stringify(svlist);
|
|
1173
|
+
return (0, _string.string_compress)(svlist);
|
|
1174
|
+
}
|
|
1175
|
+
}, {
|
|
1176
|
+
key: "unzipSaveList",
|
|
1177
|
+
value: function unzipSaveList(svlist) {
|
|
1178
|
+
try {
|
|
1179
|
+
if (_typeof(svlist) === "object") {
|
|
1180
|
+
if (Array.isArray(svlist)) return svlist;
|
|
1181
|
+
if (svlist.__save_list) return this.unzipSaveList(svlist.__save_list);
|
|
1182
|
+
} else if (typeof svlist === "string") return (0, _object.wrap_array)(JSON.parse((0, _string.string_decompress)(svlist)));
|
|
1183
|
+
} catch (_unused) {}
|
|
1184
|
+
return (0, _object.wrap_array)(svlist);
|
|
1185
|
+
}
|
|
1186
|
+
}, {
|
|
1187
|
+
key: "saveList",
|
|
1188
|
+
value: function () {
|
|
1189
|
+
var _saveList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(itemList) {
|
|
1190
|
+
var _extraOptions$chunksi;
|
|
1191
|
+
var extraOptions,
|
|
1192
|
+
chunks,
|
|
1193
|
+
putAddress,
|
|
1194
|
+
index,
|
|
1195
|
+
items_to_save,
|
|
1196
|
+
save_array,
|
|
1197
|
+
k,
|
|
1198
|
+
item,
|
|
1199
|
+
dlt,
|
|
1200
|
+
resultObject,
|
|
1201
|
+
_index,
|
|
1202
|
+
res,
|
|
1203
|
+
_item,
|
|
1204
|
+
_index2,
|
|
1205
|
+
_item2,
|
|
1206
|
+
_args21 = arguments;
|
|
1207
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1208
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1209
|
+
case 0:
|
|
1210
|
+
extraOptions = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
|
|
1211
|
+
if (!extraOptions) extraOptions = {};
|
|
1212
|
+
chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
|
|
1213
|
+
delete extraOptions.chunksize;
|
|
1214
|
+
putAddress = this.get_webpath();
|
|
1215
|
+
index = 0;
|
|
1216
|
+
case 6:
|
|
1217
|
+
if (!(index < chunks.length)) {
|
|
1218
|
+
_context21.next = 36;
|
|
1219
|
+
break;
|
|
1220
|
+
}
|
|
1221
|
+
items_to_save = chunks[index];
|
|
1222
|
+
save_array = [];
|
|
1223
|
+
k = 0;
|
|
1224
|
+
case 10:
|
|
1225
|
+
if (!(k < items_to_save.length)) {
|
|
1226
|
+
_context21.next = 19;
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
item = items_to_save[k];
|
|
1230
|
+
_context21.next = 14;
|
|
1231
|
+
return item.get_deltaObject();
|
|
1232
|
+
case 14:
|
|
1233
|
+
dlt = _context21.sent;
|
|
1234
|
+
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
1235
|
+
_id: item.getID()
|
|
1236
|
+
}, dlt));
|
|
1237
|
+
case 16:
|
|
1238
|
+
k++;
|
|
1239
|
+
_context21.next = 10;
|
|
1240
|
+
break;
|
|
1241
|
+
case 19:
|
|
1242
|
+
_context21.next = 21;
|
|
1243
|
+
return _global.gfunc.run_action("post", putAddress, _objectSpread({
|
|
1244
|
+
__save_list: WebObject.zipSaveList(save_array)
|
|
1245
|
+
}, extraOptions));
|
|
1246
|
+
case 21:
|
|
1247
|
+
resultObject = _context21.sent;
|
|
1248
|
+
if (!Array.isArray(resultObject)) {
|
|
1249
|
+
_context21.next = 33;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
_index = 0;
|
|
1253
|
+
case 24:
|
|
1254
|
+
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
1255
|
+
_context21.next = 33;
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
res = resultObject[_index];
|
|
1259
|
+
_item = items_to_save[_index];
|
|
1260
|
+
_item.setSaveResult(res);
|
|
1261
|
+
_context21.next = 30;
|
|
1262
|
+
return _item.onSave();
|
|
1263
|
+
case 30:
|
|
1264
|
+
_index++;
|
|
1265
|
+
_context21.next = 24;
|
|
1266
|
+
break;
|
|
1267
|
+
case 33:
|
|
1268
|
+
index++;
|
|
1269
|
+
_context21.next = 6;
|
|
1270
|
+
break;
|
|
1271
|
+
case 36:
|
|
1272
|
+
_index2 = 0;
|
|
1273
|
+
case 37:
|
|
1274
|
+
if (!(_index2 < itemList.length)) {
|
|
1275
|
+
_context21.next = 46;
|
|
1276
|
+
break;
|
|
1277
|
+
}
|
|
1278
|
+
_item2 = itemList[_index2];
|
|
1279
|
+
if (_item2.isSaved) {
|
|
1280
|
+
_context21.next = 41;
|
|
1281
|
+
break;
|
|
1282
|
+
}
|
|
1283
|
+
return _context21.abrupt("return", false);
|
|
1284
|
+
case 41:
|
|
1285
|
+
if (!(_item2.getSaveResultType() != "normal")) {
|
|
1286
|
+
_context21.next = 43;
|
|
1287
|
+
break;
|
|
1288
|
+
}
|
|
1289
|
+
return _context21.abrupt("return", false);
|
|
1290
|
+
case 43:
|
|
1291
|
+
_index2++;
|
|
1292
|
+
_context21.next = 37;
|
|
1293
|
+
break;
|
|
1294
|
+
case 46:
|
|
1295
|
+
return _context21.abrupt("return", true);
|
|
1296
|
+
case 47:
|
|
1297
|
+
case "end":
|
|
1298
|
+
return _context21.stop();
|
|
1299
|
+
}
|
|
1300
|
+
}, _callee21, this);
|
|
1301
|
+
}));
|
|
1302
|
+
function saveList(_x0) {
|
|
1303
|
+
return _saveList.apply(this, arguments);
|
|
1304
|
+
}
|
|
1305
|
+
return saveList;
|
|
1306
|
+
}()
|
|
1307
|
+
}, {
|
|
1308
|
+
key: "get_webpath",
|
|
1309
|
+
value: function get_webpath() {
|
|
1310
|
+
return this.__web_path || this.__db_name || "";
|
|
1311
|
+
}
|
|
1312
|
+
}, {
|
|
1313
|
+
key: "get_dbname",
|
|
1314
|
+
value: function get_dbname() {
|
|
1315
|
+
return this.__db_name || this.__web_path || "";
|
|
1316
|
+
}
|
|
1317
|
+
}, {
|
|
1318
|
+
key: "saveResultHasID",
|
|
1319
|
+
value: function saveResultHasID(s) {
|
|
1320
|
+
if (_typeof(s) !== "object" || s == null || !s) return false;
|
|
1321
|
+
return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
|
|
1322
|
+
}
|
|
543
1323
|
/**
|
|
544
1324
|
* Load Id and _index_value from the given save result into our object
|
|
545
1325
|
* @param o
|
|
546
1326
|
* @param srObject
|
|
547
1327
|
* @returns
|
|
548
|
-
*/
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
1328
|
+
*/
|
|
1329
|
+
}, {
|
|
1330
|
+
key: "LoadIdsFromSaveResult",
|
|
1331
|
+
value: function LoadIdsFromSaveResult(o, srObject) {
|
|
1332
|
+
if (_typeof(o) !== "object" || _typeof(srObject) !== "object") return;
|
|
1333
|
+
/* -------------------------------------------------------------------------- */
|
|
1334
|
+
var srID = srObject.insertedId || srObject._id || WebObject.getID(srObject);
|
|
1335
|
+
if (srID) {
|
|
1336
|
+
o._id = srID;
|
|
1337
|
+
}
|
|
1338
|
+
/* -------------------------------------------------------------------------- */
|
|
1339
|
+
if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
|
|
1340
|
+
o._index_value = Number(srObject._index_value);
|
|
1341
|
+
}
|
|
1342
|
+
/* -------------------------------------------------------------------------- */
|
|
1343
|
+
if (srObject._index_key) {
|
|
1344
|
+
o._index_key = srObject._index_key;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
/* -------------------------------------------------------------------------- */
|
|
567
1348
|
/**
|
|
568
1349
|
* get a single web object
|
|
569
1350
|
* default order of parameters : search,readonly,fetchID
|
|
570
|
-
*/
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
break;
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
1351
|
+
*/
|
|
1352
|
+
}, {
|
|
1353
|
+
key: "get_single",
|
|
1354
|
+
value: (function () {
|
|
1355
|
+
var _get_single = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1356
|
+
var _p$shift;
|
|
1357
|
+
var _len0,
|
|
1358
|
+
p,
|
|
1359
|
+
_key1,
|
|
1360
|
+
search,
|
|
1361
|
+
readonly,
|
|
1362
|
+
fetchID,
|
|
1363
|
+
result,
|
|
1364
|
+
params,
|
|
1365
|
+
_args22 = arguments;
|
|
1366
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1367
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1368
|
+
case 0:
|
|
1369
|
+
for (_len0 = _args22.length, p = new Array(_len0), _key1 = 0; _key1 < _len0; _key1++) {
|
|
1370
|
+
p[_key1] = _args22[_key1];
|
|
1371
|
+
}
|
|
1372
|
+
search = p.shift();
|
|
1373
|
+
readonly = (_p$shift = p.shift()) !== null && _p$shift !== void 0 ? _p$shift : false;
|
|
1374
|
+
fetchID = p.shift();
|
|
1375
|
+
if (!(0, _object.object_isEmpty)(search)) {
|
|
1376
|
+
_context22.next = 6;
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1379
|
+
return _context22.abrupt("return", undefined);
|
|
1380
|
+
case 6:
|
|
1381
|
+
params = {};
|
|
1382
|
+
params.__context = readonly ? "view" : "edit";
|
|
1383
|
+
_context22.t0 = _typeof(search);
|
|
1384
|
+
_context22.next = _context22.t0 === "string" ? 11 : _context22.t0 === "number" ? 11 : _context22.t0 === "object" ? 16 : 16;
|
|
1385
|
+
break;
|
|
1386
|
+
case 11:
|
|
1387
|
+
search = String(search);
|
|
1388
|
+
// const usepath =
|
|
1389
|
+
// (await WebObjectPathHelper.get_path(this, "get")) +
|
|
1390
|
+
// "/" +
|
|
1391
|
+
// search;
|
|
1392
|
+
// res = await gfunc.run_action("get", usepath, params, {
|
|
1393
|
+
// fetchID: fetchID,
|
|
1394
|
+
// });
|
|
1395
|
+
_context22.next = 14;
|
|
1396
|
+
return this.get_list({
|
|
1397
|
+
__searchid: search
|
|
1398
|
+
}, readonly, fetchID);
|
|
1399
|
+
case 14:
|
|
1400
|
+
result = _context22.sent;
|
|
1401
|
+
return _context22.abrupt("break", 20);
|
|
1402
|
+
case 16:
|
|
1403
|
+
_context22.next = 18;
|
|
1404
|
+
return this.get_list(search, readonly, fetchID);
|
|
1405
|
+
case 18:
|
|
1406
|
+
result = _context22.sent;
|
|
1407
|
+
return _context22.abrupt("break", 20);
|
|
1408
|
+
case 20:
|
|
1409
|
+
if (result) result = (0, _object.array_first)(result);
|
|
1410
|
+
if (!(0, _object.object_isEmpty)(result)) {
|
|
1411
|
+
result = this.ensure(this, result);
|
|
1412
|
+
WebObject.setReadonly(result, readonly);
|
|
1413
|
+
}
|
|
1414
|
+
return _context22.abrupt("return", result);
|
|
1415
|
+
case 23:
|
|
1416
|
+
case "end":
|
|
1417
|
+
return _context22.stop();
|
|
1418
|
+
}
|
|
1419
|
+
}, _callee22, this);
|
|
1420
|
+
}));
|
|
1421
|
+
function get_single() {
|
|
1422
|
+
return _get_single.apply(this, arguments);
|
|
1423
|
+
}
|
|
1424
|
+
return get_single;
|
|
1425
|
+
}()
|
|
606
1426
|
/**
|
|
607
1427
|
* Get a list of web objects
|
|
608
1428
|
* default order of parameters : search,readonly,fetchID
|
|
609
|
-
*/
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
1429
|
+
*/
|
|
1430
|
+
)
|
|
1431
|
+
}, {
|
|
1432
|
+
key: "get_list",
|
|
1433
|
+
value: (function () {
|
|
1434
|
+
var _get_list = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1435
|
+
var _p$shift2;
|
|
1436
|
+
var _len1,
|
|
1437
|
+
p,
|
|
1438
|
+
_key10,
|
|
1439
|
+
search,
|
|
1440
|
+
readonly,
|
|
1441
|
+
fetchID,
|
|
1442
|
+
usepath,
|
|
1443
|
+
result_items,
|
|
1444
|
+
res,
|
|
1445
|
+
_args23 = arguments;
|
|
1446
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1447
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1448
|
+
case 0:
|
|
1449
|
+
for (_len1 = _args23.length, p = new Array(_len1), _key10 = 0; _key10 < _len1; _key10++) {
|
|
1450
|
+
p[_key10] = _args23[_key10];
|
|
1451
|
+
}
|
|
1452
|
+
search = p.shift();
|
|
1453
|
+
readonly = (_p$shift2 = p.shift()) !== null && _p$shift2 !== void 0 ? _p$shift2 : false;
|
|
1454
|
+
fetchID = p.shift();
|
|
1455
|
+
if (!search) search = {};
|
|
1456
|
+
_context23.next = 7;
|
|
1457
|
+
return _WebObjectPathHelper["default"].get_path(this, "get");
|
|
1458
|
+
case 7:
|
|
1459
|
+
usepath = _context23.sent;
|
|
1460
|
+
_context23.next = 10;
|
|
1461
|
+
return _global.gfunc.run_action("get", usepath, search, {
|
|
1462
|
+
fetchID: fetchID
|
|
1463
|
+
});
|
|
1464
|
+
case 10:
|
|
1465
|
+
result_items = _context23.sent;
|
|
1466
|
+
// const selftype = (this.constructor ||
|
|
1467
|
+
// Object.getPrototypeOf(this)) as any;
|
|
1468
|
+
res = WebObject.map_rowindex(WebObject.mapto(this, result_items, readonly));
|
|
1469
|
+
WebObject.setReadonly(res, readonly);
|
|
1470
|
+
return _context23.abrupt("return", res);
|
|
1471
|
+
case 14:
|
|
1472
|
+
case "end":
|
|
1473
|
+
return _context23.stop();
|
|
1474
|
+
}
|
|
1475
|
+
}, _callee23, this);
|
|
1476
|
+
}));
|
|
1477
|
+
function get_list() {
|
|
1478
|
+
return _get_list.apply(this, arguments);
|
|
1479
|
+
}
|
|
1480
|
+
return get_list;
|
|
1481
|
+
}()
|
|
624
1482
|
/**
|
|
625
1483
|
* uses `get_list` and then saves the result to `gcache`
|
|
626
1484
|
* then uses the `equals` function to return matched results
|
|
627
1485
|
* @param search
|
|
628
1486
|
* @returns
|
|
629
|
-
*/
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
1487
|
+
*/
|
|
1488
|
+
)
|
|
1489
|
+
}, {
|
|
1490
|
+
key: "get_list_cache",
|
|
1491
|
+
value: (function () {
|
|
1492
|
+
var _get_list_cache = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(search) {
|
|
1493
|
+
var _this3 = this;
|
|
1494
|
+
var all_data;
|
|
1495
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1496
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1497
|
+
case 0:
|
|
1498
|
+
_context25.next = 2;
|
|
1499
|
+
return _global.gcache.get_temp_cache(this.get_webpath(), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1500
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1501
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1502
|
+
case 0:
|
|
1503
|
+
_context24.next = 2;
|
|
1504
|
+
return _this3.get_list();
|
|
1505
|
+
case 2:
|
|
1506
|
+
return _context24.abrupt("return", _context24.sent);
|
|
1507
|
+
case 3:
|
|
1508
|
+
case "end":
|
|
1509
|
+
return _context24.stop();
|
|
1510
|
+
}
|
|
1511
|
+
}, _callee24);
|
|
1512
|
+
})));
|
|
1513
|
+
case 2:
|
|
1514
|
+
all_data = _context25.sent;
|
|
1515
|
+
if (search) {
|
|
1516
|
+
_context25.next = 5;
|
|
1517
|
+
break;
|
|
1518
|
+
}
|
|
1519
|
+
return _context25.abrupt("return", all_data);
|
|
1520
|
+
case 5:
|
|
1521
|
+
return _context25.abrupt("return", all_data.filter(function (s) {
|
|
1522
|
+
return _this3.equals(s, search);
|
|
1523
|
+
}));
|
|
1524
|
+
case 6:
|
|
1525
|
+
case "end":
|
|
1526
|
+
return _context25.stop();
|
|
1527
|
+
}
|
|
1528
|
+
}, _callee25, this);
|
|
1529
|
+
}));
|
|
1530
|
+
function get_list_cache(_x1) {
|
|
1531
|
+
return _get_list_cache.apply(this, arguments);
|
|
1532
|
+
}
|
|
1533
|
+
return get_list_cache;
|
|
1534
|
+
}()
|
|
636
1535
|
/**
|
|
637
1536
|
* uses `get_list_cache` then the `equals` function to return matched result
|
|
638
1537
|
* @param search
|
|
639
1538
|
* @returns
|
|
640
|
-
*/
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
1539
|
+
*/
|
|
1540
|
+
)
|
|
1541
|
+
}, {
|
|
1542
|
+
key: "get_single_cache",
|
|
1543
|
+
value: (function () {
|
|
1544
|
+
var _get_single_cache = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(search) {
|
|
1545
|
+
var _this4 = this;
|
|
1546
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1547
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1548
|
+
case 0:
|
|
1549
|
+
_context26.next = 2;
|
|
1550
|
+
return this.get_list_cache();
|
|
1551
|
+
case 2:
|
|
1552
|
+
return _context26.abrupt("return", _context26.sent.find(function (s) {
|
|
1553
|
+
return _this4.equals(s, search);
|
|
1554
|
+
}));
|
|
1555
|
+
case 3:
|
|
1556
|
+
case "end":
|
|
1557
|
+
return _context26.stop();
|
|
1558
|
+
}
|
|
1559
|
+
}, _callee26, this);
|
|
1560
|
+
}));
|
|
1561
|
+
function get_single_cache(_x10) {
|
|
1562
|
+
return _get_single_cache.apply(this, arguments);
|
|
1563
|
+
}
|
|
1564
|
+
return get_single_cache;
|
|
1565
|
+
}()
|
|
644
1566
|
/**
|
|
645
1567
|
* Get a list of web objects and convert them to basic objects
|
|
646
1568
|
* can be passed to client components
|
|
647
1569
|
* default order of parameters : search,readonly,fetchID
|
|
648
|
-
*/
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
1570
|
+
*/
|
|
1571
|
+
)
|
|
1572
|
+
}, {
|
|
1573
|
+
key: "get_basicList",
|
|
1574
|
+
value: (function () {
|
|
1575
|
+
var _get_basicList = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
1576
|
+
var itemlist,
|
|
1577
|
+
_args28 = arguments;
|
|
1578
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1579
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1580
|
+
case 0:
|
|
1581
|
+
_context28.next = 2;
|
|
1582
|
+
return this.get_list.apply(this, _args28);
|
|
1583
|
+
case 2:
|
|
1584
|
+
itemlist = _context28.sent;
|
|
1585
|
+
_context28.next = 5;
|
|
1586
|
+
return Promise.all(itemlist.map(/*#__PURE__*/function () {
|
|
1587
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(r) {
|
|
1588
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1589
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1590
|
+
case 0:
|
|
1591
|
+
_context27.next = 2;
|
|
1592
|
+
return r.get_basicObject();
|
|
1593
|
+
case 2:
|
|
1594
|
+
return _context27.abrupt("return", _context27.sent);
|
|
1595
|
+
case 3:
|
|
1596
|
+
case "end":
|
|
1597
|
+
return _context27.stop();
|
|
1598
|
+
}
|
|
1599
|
+
}, _callee27);
|
|
1600
|
+
}));
|
|
1601
|
+
return function (_x11) {
|
|
1602
|
+
return _ref3.apply(this, arguments);
|
|
1603
|
+
};
|
|
1604
|
+
}()));
|
|
1605
|
+
case 5:
|
|
1606
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1607
|
+
case 6:
|
|
1608
|
+
case "end":
|
|
1609
|
+
return _context28.stop();
|
|
1610
|
+
}
|
|
1611
|
+
}, _callee28, this);
|
|
1612
|
+
}));
|
|
1613
|
+
function get_basicList() {
|
|
1614
|
+
return _get_basicList.apply(this, arguments);
|
|
1615
|
+
}
|
|
1616
|
+
return get_basicList;
|
|
1617
|
+
}())
|
|
1618
|
+
}]);
|
|
1619
|
+
}(_index3.SimpleObject);
|
|
1620
|
+
_defineProperty(WebObject, "__web_path", "");
|
|
1621
|
+
_defineProperty(WebObject, "__protectedProperties", ["_users"]);
|
|
1622
|
+
//you cant create a new weboject without these properties
|
|
1623
|
+
_defineProperty(WebObject, "__requiredProperties", []);
|
|
1624
|
+
var _default = exports["default"] = WebObject;
|