@azrico/webobject 1.4.7 → 1.4.9
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 +51 -20
- package/dist/src/WebObjects/WebObject.js +749 -305
- package/dist/src/WebObjects/WebObjectManager.js +363 -121
- package/dist/src/index.js +104 -9
- package/dist/src/structs/DummyObject.js +35 -8
- package/dist/src/structs/MapableObject.js +113 -74
- package/dist/src/structs/MetaObject.js +125 -35
- package/dist/src/structs/ObjectArray.js +71 -43
- package/dist/src/structs/ObjectManager.js +538 -214
- package/dist/src/structs/SimpleObject.d.ts +1 -1
- package/dist/src/structs/SimpleObject.js +1079 -731
- package/package.json +1 -1
|
@@ -1,328 +1,772 @@
|
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.WebObject = void 0;
|
|
7
|
+
var _SimpleObject2 = _interopRequireDefault(require("../structs/SimpleObject"));
|
|
8
|
+
var _object = require("@azrico/object");
|
|
9
|
+
var _global = require("@azrico/global");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
|
+
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; } } }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
18
|
+
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); } }
|
|
19
|
+
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); }); }; }
|
|
20
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
+
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); } }
|
|
22
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
23
|
+
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); }
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
31
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
32
|
+
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; }
|
|
33
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
34
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
35
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
36
|
+
var _isValidSR = /*#__PURE__*/new WeakSet();
|
|
37
|
+
var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
38
|
+
_inherits(WebObject, _SimpleObject);
|
|
39
|
+
var _super = _createSuper(WebObject);
|
|
40
|
+
function WebObject() {
|
|
41
|
+
var _this;
|
|
42
|
+
var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
43
|
+
_classCallCheck(this, WebObject);
|
|
44
|
+
_this = _super.call(this, is_readonly);
|
|
45
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _isValidSR);
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "meta_data", void 0);
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "_id", "");
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "_creator", void 0);
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "_created_date", "");
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "get_webtype", function () {
|
|
51
|
+
return _this.__web_type || _this.get_webpath();
|
|
52
|
+
});
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "get_webpath", function () {
|
|
54
|
+
return _this.__web_path;
|
|
55
|
+
});
|
|
56
|
+
_this.meta_data = [];
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
/* -------------------------------------------------------------------------- */
|
|
60
|
+
/* Meta data */
|
|
61
|
+
/* -------------------------------------------------------------------------- */
|
|
62
|
+
/**
|
|
63
|
+
* Update meta value of this object , meta data is stored in meta_data variable
|
|
64
|
+
* @param key
|
|
65
|
+
* @param value
|
|
66
|
+
* @param createIfNotExists should we create a new meta if key does not exist
|
|
67
|
+
* @param sendChange
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
_createClass(WebObject, [{
|
|
71
|
+
key: "setMetaValue",
|
|
72
|
+
value: function setMetaValue(key, value) {
|
|
73
|
+
var createIfNotExists = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
74
|
+
var sendChange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
|
|
75
|
+
if (!this.canModify) {
|
|
76
|
+
if (this.__throw_errors !== false) throw Error("Cant use setMetaValue on ".concat(key, " when on readonly mode"));else return false;
|
|
77
|
+
}
|
|
78
|
+
if (!key || typeof key != "string") {
|
|
79
|
+
if (this.__throw_errors !== false) throw Error("Bad key at setMetaValue");else return false;
|
|
80
|
+
}
|
|
81
|
+
var old_value = WebObject.getMetaValue(this, key);
|
|
82
|
+
if ((0, _object.object_equals)(old_value, value)) return false; //same value, no changes
|
|
83
|
+
var old_metalist = (0, _object.to_array)(this.getValue("meta_data")).map(function (s) {
|
|
84
|
+
return (0, _object.object_shallow_clone)(s);
|
|
85
|
+
});
|
|
86
|
+
var new_metalist = (0, _object.setInArray)(old_metalist, "key", key, "value", value, createIfNotExists);
|
|
87
|
+
this.setValue("meta_data", new_metalist);
|
|
88
|
+
if (sendChange !== false) this.notifyChanged("meta", key, value);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
49
91
|
/**
|
|
50
92
|
* Get meta object by key
|
|
51
93
|
* @param key
|
|
52
94
|
* @returns meta object
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
95
|
+
*/
|
|
96
|
+
}, {
|
|
97
|
+
key: "getMeta",
|
|
98
|
+
value: function getMeta(key) {
|
|
99
|
+
return WebObject.getMeta(this, key);
|
|
100
|
+
}
|
|
57
101
|
/**
|
|
58
102
|
* Get meta value by key
|
|
59
103
|
* @param key
|
|
60
104
|
* @returns value or undefined
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
105
|
+
*/
|
|
106
|
+
}, {
|
|
107
|
+
key: "getMetaValue",
|
|
108
|
+
value: function getMetaValue(key) {
|
|
109
|
+
return WebObject.getMetaValue(this, key);
|
|
110
|
+
}
|
|
65
111
|
/**
|
|
66
112
|
* Get meta object by key
|
|
67
113
|
* @param o
|
|
68
114
|
* @param key
|
|
69
115
|
* @returns meta object
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.setSaveResult(false, "canceled");
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
async Delete() {
|
|
144
|
-
if (this.__throw_errors !== false)
|
|
145
|
-
throw new Error("Delete not implented");
|
|
146
|
-
WebObject.addError(this, "Delete not implented", "NOSAVE", true);
|
|
147
|
-
this.setSaveResult(false, "canceled");
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
/* -------------------------------------------------------------------------- */
|
|
151
|
-
canSave(deltaObj) {
|
|
152
|
-
const deltaRes = this.deltaIsValid(deltaObj);
|
|
153
|
-
if (deltaRes !== true)
|
|
154
|
-
return deltaRes;
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
deltaIsValid(d) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
static isResultValid(result_object) {
|
|
161
|
-
if (object_isEmpty(result_object))
|
|
162
|
-
return false;
|
|
163
|
-
if (object_isTrue(result_object.acknowledged)) {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
116
|
+
*/
|
|
117
|
+
}, {
|
|
118
|
+
key: "Save",
|
|
119
|
+
value: function () {
|
|
120
|
+
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
121
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
122
|
+
while (1) switch (_context.prev = _context.next) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!(this.__throw_errors !== false)) {
|
|
125
|
+
_context.next = 2;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
throw new Error("Save not implented");
|
|
129
|
+
case 2:
|
|
130
|
+
WebObject.addError(this, "Save not implented", "NOSAVE", true);
|
|
131
|
+
this.setSaveResult(false, "canceled");
|
|
132
|
+
return _context.abrupt("return", false);
|
|
133
|
+
case 5:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context.stop();
|
|
136
|
+
}
|
|
137
|
+
}, _callee, this);
|
|
138
|
+
}));
|
|
139
|
+
function Save() {
|
|
140
|
+
return _Save.apply(this, arguments);
|
|
141
|
+
}
|
|
142
|
+
return Save;
|
|
143
|
+
}()
|
|
144
|
+
}, {
|
|
145
|
+
key: "Delete",
|
|
146
|
+
value: function () {
|
|
147
|
+
var _Delete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
148
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
149
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
if (!(this.__throw_errors !== false)) {
|
|
152
|
+
_context2.next = 2;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
throw new Error("Delete not implented");
|
|
156
|
+
case 2:
|
|
157
|
+
WebObject.addError(this, "Delete not implented", "NOSAVE", true);
|
|
158
|
+
this.setSaveResult(false, "canceled");
|
|
159
|
+
return _context2.abrupt("return", false);
|
|
160
|
+
case 5:
|
|
161
|
+
case "end":
|
|
162
|
+
return _context2.stop();
|
|
163
|
+
}
|
|
164
|
+
}, _callee2, this);
|
|
165
|
+
}));
|
|
166
|
+
function Delete() {
|
|
167
|
+
return _Delete.apply(this, arguments);
|
|
168
|
+
}
|
|
169
|
+
return Delete;
|
|
170
|
+
}() /* -------------------------------------------------------------------------- */
|
|
171
|
+
}, {
|
|
172
|
+
key: "canSave",
|
|
173
|
+
value: function canSave(deltaObj) {
|
|
174
|
+
var deltaRes = this.deltaIsValid(deltaObj);
|
|
175
|
+
if (deltaRes !== true) return deltaRes;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "deltaIsValid",
|
|
180
|
+
value: function deltaIsValid(d) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "get_deltaObject",
|
|
185
|
+
value:
|
|
168
186
|
/**
|
|
169
187
|
* You will post this to the server for saving
|
|
170
188
|
* automatically removes unchangable fields
|
|
171
189
|
* @returns
|
|
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
|
-
|
|
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
|
-
|
|
190
|
+
*/
|
|
191
|
+
function () {
|
|
192
|
+
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
|
|
193
|
+
var _this2 = this;
|
|
194
|
+
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, _iterator, _step, key;
|
|
195
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
196
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
197
|
+
case 0:
|
|
198
|
+
_parseObj = function _parseObj3() {
|
|
199
|
+
_parseObj = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(obj) {
|
|
200
|
+
var newobj_dlt;
|
|
201
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
202
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
203
|
+
case 0:
|
|
204
|
+
if (!(obj == null)) {
|
|
205
|
+
_context4.next = 2;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
return _context4.abrupt("return", undefined);
|
|
209
|
+
case 2:
|
|
210
|
+
if (!Array.isArray(obj)) {
|
|
211
|
+
_context4.next = 6;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
_context4.next = 5;
|
|
215
|
+
return Promise.all(obj.map( /*#__PURE__*/function () {
|
|
216
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(r) {
|
|
217
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
218
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
_context3.next = 2;
|
|
221
|
+
return parseObj(r);
|
|
222
|
+
case 2:
|
|
223
|
+
return _context3.abrupt("return", _context3.sent);
|
|
224
|
+
case 3:
|
|
225
|
+
case "end":
|
|
226
|
+
return _context3.stop();
|
|
227
|
+
}
|
|
228
|
+
}, _callee3);
|
|
229
|
+
}));
|
|
230
|
+
return function (_x3) {
|
|
231
|
+
return _ref.apply(this, arguments);
|
|
232
|
+
};
|
|
233
|
+
}()));
|
|
234
|
+
case 5:
|
|
235
|
+
return _context4.abrupt("return", _context4.sent);
|
|
236
|
+
case 6:
|
|
237
|
+
if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
|
|
238
|
+
_context4.next = 15;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
_context4.next = 9;
|
|
242
|
+
return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
|
|
243
|
+
isChild: true
|
|
244
|
+
}));
|
|
245
|
+
case 9:
|
|
246
|
+
newobj_dlt = _context4.sent;
|
|
247
|
+
if ((0, _object.object_isEmpty)(newobj_dlt)) {
|
|
248
|
+
_context4.next = 14;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
return _context4.abrupt("return", newobj_dlt);
|
|
252
|
+
case 14:
|
|
253
|
+
return _context4.abrupt("return", obj);
|
|
254
|
+
case 15:
|
|
255
|
+
return _context4.abrupt("return", obj);
|
|
256
|
+
case 16:
|
|
257
|
+
case "end":
|
|
258
|
+
return _context4.stop();
|
|
259
|
+
}
|
|
260
|
+
}, _callee4);
|
|
261
|
+
}));
|
|
262
|
+
return _parseObj.apply(this, arguments);
|
|
263
|
+
};
|
|
264
|
+
parseObj = function _parseObj2(_x2) {
|
|
265
|
+
return _parseObj.apply(this, arguments);
|
|
266
|
+
};
|
|
267
|
+
if (!p) p = {};
|
|
268
|
+
final_object = {}; //@ts-ignore
|
|
269
|
+
isChild = Boolean(p.isChild || p.ischild); //@ts-ignore
|
|
270
|
+
useDelta = this.__use_delta || Boolean(p.useDelta || p.usedelta); //@ts-ignore
|
|
271
|
+
allProperties = Boolean(p.allProperties || p.allproperties);
|
|
272
|
+
chkChangables = this.__changeables != null || this.__unchangeables != null;
|
|
273
|
+
useExtraProps = Boolean(p.extraProperties); //child objects usually dont update their __delta, so we read info from all of its properties
|
|
274
|
+
dlt = allProperties || !useDelta && isChild && chkChangables ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
|
|
275
|
+
allkeys = Object.keys(dlt);
|
|
276
|
+
changableKeys = chkChangables ? allkeys.filter(function (s) {
|
|
277
|
+
return _SimpleObject2["default"].canChangeKey(_this2, s, useExtraProps);
|
|
278
|
+
}) : allkeys;
|
|
279
|
+
_iterator = _createForOfIteratorHelper(changableKeys);
|
|
280
|
+
_context5.prev = 13;
|
|
281
|
+
_iterator.s();
|
|
282
|
+
case 15:
|
|
283
|
+
if ((_step = _iterator.n()).done) {
|
|
284
|
+
_context5.next = 22;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
key = _step.value;
|
|
288
|
+
_context5.next = 19;
|
|
289
|
+
return parseObj(dlt[key]);
|
|
290
|
+
case 19:
|
|
291
|
+
final_object[key] = _context5.sent;
|
|
292
|
+
case 20:
|
|
293
|
+
_context5.next = 15;
|
|
294
|
+
break;
|
|
295
|
+
case 22:
|
|
296
|
+
_context5.next = 27;
|
|
297
|
+
break;
|
|
298
|
+
case 24:
|
|
299
|
+
_context5.prev = 24;
|
|
300
|
+
_context5.t0 = _context5["catch"](13);
|
|
301
|
+
_iterator.e(_context5.t0);
|
|
302
|
+
case 27:
|
|
303
|
+
_context5.prev = 27;
|
|
304
|
+
_iterator.f();
|
|
305
|
+
return _context5.finish(27);
|
|
306
|
+
case 30:
|
|
307
|
+
if (allProperties) {
|
|
308
|
+
final_object["_id"] = this.getID();
|
|
309
|
+
final_object["_index_value"] = this.getIndex();
|
|
310
|
+
final_object["_index_key"] = this["_index_key"];
|
|
311
|
+
final_object["_created_date"] = this["_created_date"];
|
|
312
|
+
}
|
|
313
|
+
return _context5.abrupt("return", final_object);
|
|
314
|
+
case 32:
|
|
315
|
+
case "end":
|
|
316
|
+
return _context5.stop();
|
|
317
|
+
}
|
|
318
|
+
}, _callee5, this, [[13, 24, 27, 30]]);
|
|
319
|
+
}));
|
|
320
|
+
function get_deltaObject(_x) {
|
|
321
|
+
return _get_deltaObject.apply(this, arguments);
|
|
322
|
+
}
|
|
323
|
+
return get_deltaObject;
|
|
324
|
+
}() /* --------------------------------- Getters -------------------------------- */
|
|
325
|
+
}, {
|
|
326
|
+
key: "__web_path",
|
|
327
|
+
get: function get() {
|
|
328
|
+
return this.constructor["__web_path"];
|
|
329
|
+
}
|
|
330
|
+
}, {
|
|
331
|
+
key: "__web_type",
|
|
332
|
+
get: function get() {
|
|
333
|
+
return this.constructor["__web_type"];
|
|
334
|
+
}
|
|
335
|
+
}, {
|
|
336
|
+
key: "manager",
|
|
337
|
+
get: function get() {
|
|
338
|
+
return this.get_managerClass() || undefined;
|
|
339
|
+
}
|
|
340
|
+
/* -------------------------------------------------------------------------- */
|
|
341
|
+
}, {
|
|
342
|
+
key: "onDelete",
|
|
343
|
+
value: function () {
|
|
344
|
+
var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
345
|
+
var _this$manager;
|
|
346
|
+
var _len,
|
|
347
|
+
p,
|
|
348
|
+
_key,
|
|
349
|
+
_args6 = arguments;
|
|
350
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
351
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
352
|
+
case 0:
|
|
353
|
+
this.isDeleted = true;
|
|
354
|
+
for (_len = _args6.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
355
|
+
p[_key] = _args6[_key];
|
|
356
|
+
}
|
|
357
|
+
_context6.next = 4;
|
|
358
|
+
return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
|
|
359
|
+
case 4:
|
|
360
|
+
return _context6.abrupt("return", _context6.sent);
|
|
361
|
+
case 5:
|
|
362
|
+
case "end":
|
|
363
|
+
return _context6.stop();
|
|
364
|
+
}
|
|
365
|
+
}, _callee6, this);
|
|
366
|
+
}));
|
|
367
|
+
function onDelete() {
|
|
368
|
+
return _onDelete.apply(this, arguments);
|
|
369
|
+
}
|
|
370
|
+
return onDelete;
|
|
371
|
+
}()
|
|
372
|
+
}, {
|
|
373
|
+
key: "onLoad",
|
|
374
|
+
value: function () {
|
|
375
|
+
var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
376
|
+
var _this$manager2;
|
|
377
|
+
var _len2,
|
|
378
|
+
p,
|
|
379
|
+
_key2,
|
|
380
|
+
_args7 = arguments;
|
|
381
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
382
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
383
|
+
case 0:
|
|
384
|
+
this.isDeleted = false;
|
|
385
|
+
for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
386
|
+
p[_key2] = _args7[_key2];
|
|
387
|
+
}
|
|
388
|
+
_context7.next = 4;
|
|
389
|
+
return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
|
|
390
|
+
case 4:
|
|
391
|
+
return _context7.abrupt("return", _context7.sent);
|
|
392
|
+
case 5:
|
|
393
|
+
case "end":
|
|
394
|
+
return _context7.stop();
|
|
395
|
+
}
|
|
396
|
+
}, _callee7, this);
|
|
397
|
+
}));
|
|
398
|
+
function onLoad() {
|
|
399
|
+
return _onLoad.apply(this, arguments);
|
|
400
|
+
}
|
|
401
|
+
return onLoad;
|
|
402
|
+
}()
|
|
403
|
+
}, {
|
|
404
|
+
key: "onSave",
|
|
405
|
+
value: function () {
|
|
406
|
+
var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
407
|
+
var _this3 = this,
|
|
408
|
+
_this$manager4;
|
|
409
|
+
var srObject,
|
|
410
|
+
actual_sr,
|
|
411
|
+
_this$manager3,
|
|
412
|
+
_len3,
|
|
413
|
+
p,
|
|
414
|
+
_key3,
|
|
415
|
+
_args8 = arguments;
|
|
416
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
417
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
418
|
+
case 0:
|
|
419
|
+
if (!this.isSaved) {
|
|
420
|
+
_context8.next = 10;
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
this.apply_changes();
|
|
424
|
+
srObject = this.getSaveResult(true);
|
|
425
|
+
if (!(srObject != null)) {
|
|
426
|
+
_context8.next = 10;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
//we may have some extra data in the save result.
|
|
430
|
+
//try to find the main data
|
|
431
|
+
if (Array.isArray(srObject)) {
|
|
432
|
+
actual_sr = srObject.find(function (s) {
|
|
433
|
+
return _classPrivateMethodGet(_this3, _isValidSR, _isValidSR2).call(_this3, s);
|
|
434
|
+
});
|
|
435
|
+
if (actual_sr) srObject = actual_sr;
|
|
436
|
+
}
|
|
437
|
+
if (!_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
|
|
438
|
+
_context8.next = 10;
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
if (srObject.insertedId || srObject._id) {
|
|
442
|
+
this._id = srObject.insertedId || srObject._id;
|
|
443
|
+
}
|
|
444
|
+
if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
|
|
445
|
+
this._index_value = Number(srObject._index_value);
|
|
446
|
+
}
|
|
447
|
+
_context8.next = 10;
|
|
448
|
+
return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
|
|
449
|
+
case 10:
|
|
450
|
+
for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
451
|
+
p[_key3] = _args8[_key3];
|
|
452
|
+
}
|
|
453
|
+
_context8.next = 13;
|
|
454
|
+
return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
|
|
455
|
+
case 13:
|
|
456
|
+
return _context8.abrupt("return", _context8.sent);
|
|
457
|
+
case 14:
|
|
458
|
+
case "end":
|
|
459
|
+
return _context8.stop();
|
|
460
|
+
}
|
|
461
|
+
}, _callee8, this);
|
|
462
|
+
}));
|
|
463
|
+
function onSave() {
|
|
464
|
+
return _onSave.apply(this, arguments);
|
|
465
|
+
}
|
|
466
|
+
return onSave;
|
|
467
|
+
}()
|
|
468
|
+
}, {
|
|
469
|
+
key: "onNew",
|
|
470
|
+
value: function () {
|
|
471
|
+
var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
472
|
+
var _this$manager5;
|
|
473
|
+
var _len4,
|
|
474
|
+
p,
|
|
475
|
+
_key4,
|
|
476
|
+
_args9 = arguments;
|
|
477
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
478
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
479
|
+
case 0:
|
|
480
|
+
for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
481
|
+
p[_key4] = _args9[_key4];
|
|
482
|
+
}
|
|
483
|
+
_context9.next = 3;
|
|
484
|
+
return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onNew.apply(_this$manager5, p);
|
|
485
|
+
case 3:
|
|
486
|
+
return _context9.abrupt("return", _context9.sent);
|
|
487
|
+
case 4:
|
|
488
|
+
case "end":
|
|
489
|
+
return _context9.stop();
|
|
490
|
+
}
|
|
491
|
+
}, _callee9, this);
|
|
492
|
+
}));
|
|
493
|
+
function onNew() {
|
|
494
|
+
return _onNew.apply(this, arguments);
|
|
495
|
+
}
|
|
496
|
+
return onNew;
|
|
497
|
+
}()
|
|
498
|
+
/* -------------------------------------------------------------------------- */
|
|
284
499
|
/**
|
|
285
500
|
* get a single web object
|
|
286
501
|
* default order of parameters : search,readonly,fetchID
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
502
|
+
*/
|
|
503
|
+
}], [{
|
|
504
|
+
key: "getMeta",
|
|
505
|
+
value: function getMeta(o, key) {
|
|
506
|
+
if (o == null) return null;
|
|
507
|
+
if (!key || typeof key != "string") return undefined;
|
|
508
|
+
var metalist = [];
|
|
509
|
+
if (_typeof(o) === "object") {
|
|
510
|
+
metalist = typeof o.getValue === "function" ? o.getValue("meta_data") : o.meta_data;
|
|
511
|
+
}
|
|
512
|
+
return (0, _object.getInArray)(metalist, "key", key);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Get meta value by key
|
|
516
|
+
* @param o
|
|
517
|
+
* @param key
|
|
518
|
+
* @returns value or undefined
|
|
519
|
+
*/
|
|
520
|
+
}, {
|
|
521
|
+
key: "getMetaValue",
|
|
522
|
+
value: function getMetaValue(o, key) {
|
|
523
|
+
var _WebObject$getMeta;
|
|
524
|
+
return (_WebObject$getMeta = WebObject.getMeta(o, key)) === null || _WebObject$getMeta === void 0 ? void 0 : _WebObject$getMeta.value;
|
|
525
|
+
}
|
|
526
|
+
/* -------------------------------------------------------------------------- */
|
|
527
|
+
/* Save */
|
|
528
|
+
/* -------------------------------------------------------------------------- */
|
|
529
|
+
}, {
|
|
530
|
+
key: "saveList",
|
|
531
|
+
value: function () {
|
|
532
|
+
var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(itemList) {
|
|
533
|
+
var chunks, putAddress, index, items_to_save, save_array, k, item, dlt, resultObject, _index, res, _item, _index2, _item2;
|
|
534
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
535
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
536
|
+
case 0:
|
|
537
|
+
chunks = (0, _object.array_chunks)(itemList, 30);
|
|
538
|
+
putAddress = this.get_webname();
|
|
539
|
+
index = 0;
|
|
540
|
+
case 3:
|
|
541
|
+
if (!(index < chunks.length)) {
|
|
542
|
+
_context10.next = 33;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
items_to_save = chunks[index];
|
|
546
|
+
save_array = [];
|
|
547
|
+
k = 0;
|
|
548
|
+
case 7:
|
|
549
|
+
if (!(k < items_to_save.length)) {
|
|
550
|
+
_context10.next = 16;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
item = items_to_save[k];
|
|
554
|
+
_context10.next = 11;
|
|
555
|
+
return item.get_deltaObject();
|
|
556
|
+
case 11:
|
|
557
|
+
dlt = _context10.sent;
|
|
558
|
+
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
559
|
+
_id: item.getID()
|
|
560
|
+
}, dlt));
|
|
561
|
+
case 13:
|
|
562
|
+
k++;
|
|
563
|
+
_context10.next = 7;
|
|
564
|
+
break;
|
|
565
|
+
case 16:
|
|
566
|
+
_context10.next = 18;
|
|
567
|
+
return _global.gfunc.run_action("post", putAddress, {
|
|
568
|
+
__save_list: save_array
|
|
569
|
+
});
|
|
570
|
+
case 18:
|
|
571
|
+
resultObject = _context10.sent;
|
|
572
|
+
if (!Array.isArray(resultObject)) {
|
|
573
|
+
_context10.next = 30;
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
_index = 0;
|
|
577
|
+
case 21:
|
|
578
|
+
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
579
|
+
_context10.next = 30;
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
res = resultObject[_index];
|
|
583
|
+
_item = items_to_save[_index];
|
|
584
|
+
_item.setSaveResult(res);
|
|
585
|
+
_context10.next = 27;
|
|
586
|
+
return _item.onSave();
|
|
587
|
+
case 27:
|
|
588
|
+
_index++;
|
|
589
|
+
_context10.next = 21;
|
|
590
|
+
break;
|
|
591
|
+
case 30:
|
|
592
|
+
index++;
|
|
593
|
+
_context10.next = 3;
|
|
594
|
+
break;
|
|
595
|
+
case 33:
|
|
596
|
+
_index2 = 0;
|
|
597
|
+
case 34:
|
|
598
|
+
if (!(_index2 < itemList.length)) {
|
|
599
|
+
_context10.next = 43;
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
_item2 = itemList[_index2];
|
|
603
|
+
if (_item2.isSaved) {
|
|
604
|
+
_context10.next = 38;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
return _context10.abrupt("return", false);
|
|
608
|
+
case 38:
|
|
609
|
+
if (!(_item2.getSaveResultType() != "normal")) {
|
|
610
|
+
_context10.next = 40;
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
return _context10.abrupt("return", false);
|
|
614
|
+
case 40:
|
|
615
|
+
_index2++;
|
|
616
|
+
_context10.next = 34;
|
|
617
|
+
break;
|
|
618
|
+
case 43:
|
|
619
|
+
return _context10.abrupt("return", true);
|
|
620
|
+
case 44:
|
|
621
|
+
case "end":
|
|
622
|
+
return _context10.stop();
|
|
623
|
+
}
|
|
624
|
+
}, _callee10, this);
|
|
625
|
+
}));
|
|
626
|
+
function saveList(_x4) {
|
|
627
|
+
return _saveList.apply(this, arguments);
|
|
628
|
+
}
|
|
629
|
+
return saveList;
|
|
630
|
+
}()
|
|
631
|
+
}, {
|
|
632
|
+
key: "isResultValid",
|
|
633
|
+
value: function isResultValid(result_object) {
|
|
634
|
+
if ((0, _object.object_isEmpty)(result_object)) return false;
|
|
635
|
+
if ((0, _object.object_isTrue)(result_object.acknowledged)) {
|
|
636
|
+
return true;
|
|
637
|
+
}
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
}, {
|
|
641
|
+
key: "get_webname",
|
|
642
|
+
value: function get_webname() {
|
|
643
|
+
return this.__web_path || this.__web_type || this.__cache_name;
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
key: "get_single",
|
|
647
|
+
value: function () {
|
|
648
|
+
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
649
|
+
var _len5,
|
|
650
|
+
p,
|
|
651
|
+
_key5,
|
|
652
|
+
search,
|
|
653
|
+
readonly,
|
|
654
|
+
fetchID,
|
|
655
|
+
res,
|
|
656
|
+
params,
|
|
657
|
+
_args11 = arguments;
|
|
658
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
659
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
660
|
+
case 0:
|
|
661
|
+
for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
662
|
+
p[_key5] = _args11[_key5];
|
|
663
|
+
}
|
|
664
|
+
search = p.shift();
|
|
665
|
+
readonly = p.shift();
|
|
666
|
+
fetchID = p.shift();
|
|
667
|
+
if (!(0, _object.object_isEmpty)(search)) {
|
|
668
|
+
_context11.next = 6;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
return _context11.abrupt("return", undefined);
|
|
672
|
+
case 6:
|
|
673
|
+
params = {};
|
|
674
|
+
params.context = readonly ? "view" : "edit";
|
|
675
|
+
_context11.t0 = _typeof(search);
|
|
676
|
+
_context11.next = _context11.t0 === "string" ? 11 : _context11.t0 === "number" ? 11 : _context11.t0 === "object" ? 19 : 19;
|
|
677
|
+
break;
|
|
678
|
+
case 11:
|
|
679
|
+
search = String(search);
|
|
680
|
+
_context11.t1 = this;
|
|
681
|
+
_context11.t2 = this;
|
|
682
|
+
_context11.next = 16;
|
|
683
|
+
return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
|
|
684
|
+
fetchID: fetchID
|
|
685
|
+
});
|
|
686
|
+
case 16:
|
|
687
|
+
_context11.t3 = _context11.sent;
|
|
688
|
+
res = _context11.t1.ensure.call(_context11.t1, _context11.t2, _context11.t3);
|
|
689
|
+
return _context11.abrupt("break", 25);
|
|
690
|
+
case 19:
|
|
691
|
+
_context11.t4 = _object.object_first;
|
|
692
|
+
_context11.next = 22;
|
|
693
|
+
return this.get_list(search, readonly, fetchID);
|
|
694
|
+
case 22:
|
|
695
|
+
_context11.t5 = _context11.sent;
|
|
696
|
+
res = (0, _context11.t4)(_context11.t5);
|
|
697
|
+
return _context11.abrupt("break", 25);
|
|
698
|
+
case 25:
|
|
699
|
+
WebObject.setReadonly(res, readonly);
|
|
700
|
+
return _context11.abrupt("return", res);
|
|
701
|
+
case 27:
|
|
702
|
+
case "end":
|
|
703
|
+
return _context11.stop();
|
|
704
|
+
}
|
|
705
|
+
}, _callee11, this);
|
|
706
|
+
}));
|
|
707
|
+
function get_single() {
|
|
708
|
+
return _get_single.apply(this, arguments);
|
|
709
|
+
}
|
|
710
|
+
return get_single;
|
|
711
|
+
}()
|
|
311
712
|
/**
|
|
312
713
|
* Get a list of web objects
|
|
313
714
|
* default order of parameters : search,readonly,fetchID
|
|
314
|
-
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
715
|
+
*/
|
|
716
|
+
}, {
|
|
717
|
+
key: "get_list",
|
|
718
|
+
value: function () {
|
|
719
|
+
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
720
|
+
var _len6,
|
|
721
|
+
p,
|
|
722
|
+
_key6,
|
|
723
|
+
search,
|
|
724
|
+
readonly,
|
|
725
|
+
fetchID,
|
|
726
|
+
result_items,
|
|
727
|
+
selftype,
|
|
728
|
+
res,
|
|
729
|
+
_args12 = arguments;
|
|
730
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
731
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
732
|
+
case 0:
|
|
733
|
+
for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
734
|
+
p[_key6] = _args12[_key6];
|
|
735
|
+
}
|
|
736
|
+
search = p.shift();
|
|
737
|
+
readonly = p.shift();
|
|
738
|
+
fetchID = p.shift();
|
|
739
|
+
if (!search) search = {};
|
|
740
|
+
_context12.next = 7;
|
|
741
|
+
return _global.gfunc.run_action("get", this.__web_path, search, {
|
|
742
|
+
fetchID: fetchID
|
|
743
|
+
});
|
|
744
|
+
case 7:
|
|
745
|
+
result_items = _context12.sent;
|
|
746
|
+
selftype = this.prototype;
|
|
747
|
+
res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
|
|
748
|
+
WebObject.setReadonly(res, readonly);
|
|
749
|
+
return _context12.abrupt("return", res);
|
|
750
|
+
case 12:
|
|
751
|
+
case "end":
|
|
752
|
+
return _context12.stop();
|
|
753
|
+
}
|
|
754
|
+
}, _callee12, this);
|
|
755
|
+
}));
|
|
756
|
+
function get_list() {
|
|
757
|
+
return _get_list.apply(this, arguments);
|
|
758
|
+
}
|
|
759
|
+
return get_list;
|
|
760
|
+
}()
|
|
761
|
+
}]);
|
|
762
|
+
return WebObject;
|
|
763
|
+
}(_SimpleObject2["default"]);
|
|
764
|
+
exports.WebObject = WebObject;
|
|
765
|
+
function _isValidSR2(s) {
|
|
766
|
+
if (_typeof(s) !== "object" && s == null) return false;
|
|
767
|
+
return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
|
|
768
|
+
}
|
|
769
|
+
_defineProperty(WebObject, "__web_path", "");
|
|
770
|
+
_defineProperty(WebObject, "__web_type", "");
|
|
771
|
+
var _default = WebObject;
|
|
772
|
+
exports["default"] = _default;
|