@azrico/webobject 1.2.36 → 1.3.1
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.
|
@@ -27,9 +27,13 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
27
27
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
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
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"); } }
|
|
30
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; }
|
|
31
33
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
32
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();
|
|
33
37
|
var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
34
38
|
_inherits(WebObject, _SimpleObject);
|
|
35
39
|
var _super = _createSuper(WebObject);
|
|
@@ -38,6 +42,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
38
42
|
var is_readonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
39
43
|
_classCallCheck(this, WebObject);
|
|
40
44
|
_this = _super.call(this, is_readonly);
|
|
45
|
+
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _isValidSR);
|
|
41
46
|
_defineProperty(_assertThisInitialized(_this), "meta_data", void 0);
|
|
42
47
|
_defineProperty(_assertThisInitialized(_this), "_id", "");
|
|
43
48
|
_defineProperty(_assertThisInitialized(_this), "_created_date", "");
|
|
@@ -372,22 +377,47 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
372
377
|
key: "onSave",
|
|
373
378
|
value: function () {
|
|
374
379
|
var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
375
|
-
var
|
|
376
|
-
|
|
380
|
+
var _this3 = this,
|
|
381
|
+
_this$manager2;
|
|
382
|
+
var srObject,
|
|
383
|
+
actual_sr,
|
|
384
|
+
_len2,
|
|
377
385
|
p,
|
|
378
386
|
_key2,
|
|
379
387
|
_args7 = arguments;
|
|
380
388
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
381
389
|
while (1) switch (_context7.prev = _context7.next) {
|
|
382
390
|
case 0:
|
|
391
|
+
if (this.isSaved) {
|
|
392
|
+
this.apply_changes();
|
|
393
|
+
srObject = this.getSaveResult(true);
|
|
394
|
+
if (srObject != null) {
|
|
395
|
+
//we may have some extra data in the save result.
|
|
396
|
+
//try to find the main data
|
|
397
|
+
if (Array.isArray(srObject)) {
|
|
398
|
+
actual_sr = srObject.find(function (s) {
|
|
399
|
+
return _classPrivateMethodGet(_this3, _isValidSR, _isValidSR2).call(_this3, s);
|
|
400
|
+
});
|
|
401
|
+
if (actual_sr) srObject = actual_sr;
|
|
402
|
+
}
|
|
403
|
+
if (_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
|
|
404
|
+
if (srObject.insertedId || srObject._id) {
|
|
405
|
+
this._id = srObject.insertedId || srObject._id;
|
|
406
|
+
}
|
|
407
|
+
if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
|
|
408
|
+
this._index_value = Number(srObject._index_value);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
383
413
|
for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
384
414
|
p[_key2] = _args7[_key2];
|
|
385
415
|
}
|
|
386
|
-
_context7.next =
|
|
416
|
+
_context7.next = 4;
|
|
387
417
|
return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onSave.apply(_this$manager2, p);
|
|
388
|
-
case 3:
|
|
389
|
-
return _context7.abrupt("return", _context7.sent);
|
|
390
418
|
case 4:
|
|
419
|
+
return _context7.abrupt("return", _context7.sent);
|
|
420
|
+
case 5:
|
|
391
421
|
case "end":
|
|
392
422
|
return _context7.stop();
|
|
393
423
|
}
|
|
@@ -590,6 +620,10 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
590
620
|
return WebObject;
|
|
591
621
|
}(_SimpleObject2["default"]);
|
|
592
622
|
exports.WebObject = WebObject;
|
|
623
|
+
function _isValidSR2(s) {
|
|
624
|
+
if (_typeof(s) !== "object" && s == null) return false;
|
|
625
|
+
return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
|
|
626
|
+
}
|
|
593
627
|
_defineProperty(WebObject, "__web_path", "");
|
|
594
628
|
_defineProperty(WebObject, "__web_type", "");
|
|
595
629
|
var _default = WebObject;
|
|
@@ -5,7 +5,6 @@ import WebObject from "./WebObject";
|
|
|
5
5
|
* This class manages the events of an Simple Object
|
|
6
6
|
*/
|
|
7
7
|
export declare class WebObjectManager<T extends WebObject> extends ObjectManager<T> {
|
|
8
|
-
#private;
|
|
9
8
|
static readonly __web_path: string;
|
|
10
9
|
static readonly __web_type: string;
|
|
11
10
|
/**
|
|
@@ -20,13 +20,9 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
20
20
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
21
|
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; } }
|
|
22
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
24
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
25
23
|
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; }
|
|
26
24
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
27
25
|
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); }
|
|
28
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
29
|
-
var _isValidSR = /*#__PURE__*/new WeakSet();
|
|
30
26
|
/**
|
|
31
27
|
* This class manages the events of an Simple Object
|
|
32
28
|
*/
|
|
@@ -34,18 +30,15 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
34
30
|
_inherits(WebObjectManager, _ObjectManager);
|
|
35
31
|
var _super = _createSuper(WebObjectManager);
|
|
36
32
|
function WebObjectManager() {
|
|
37
|
-
var _this;
|
|
38
33
|
_classCallCheck(this, WebObjectManager);
|
|
39
|
-
|
|
40
|
-
args[_key] = arguments[_key];
|
|
41
|
-
}
|
|
42
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
43
|
-
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _isValidSR);
|
|
44
|
-
return _this;
|
|
34
|
+
return _super.apply(this, arguments);
|
|
45
35
|
}
|
|
46
36
|
_createClass(WebObjectManager, [{
|
|
47
37
|
key: "setMetaValue",
|
|
48
|
-
value:
|
|
38
|
+
value:
|
|
39
|
+
//we use this as backup
|
|
40
|
+
|
|
41
|
+
/* -------------------------------------------------------------------------- */
|
|
49
42
|
/* -------------------------------------------------------------------------- */
|
|
50
43
|
/* Meta data */
|
|
51
44
|
/* -------------------------------------------------------------------------- */
|
|
@@ -252,55 +245,29 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
252
245
|
}
|
|
253
246
|
return onLoad;
|
|
254
247
|
}()
|
|
255
|
-
}, {
|
|
256
|
-
key: "onSave",
|
|
257
|
-
value:
|
|
258
248
|
/**
|
|
259
249
|
* Use this after succesful save to Database
|
|
260
250
|
* @param p
|
|
261
251
|
* @returns
|
|
262
252
|
*/
|
|
263
|
-
|
|
253
|
+
}, {
|
|
254
|
+
key: "onSave",
|
|
255
|
+
value: function () {
|
|
264
256
|
var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
265
|
-
var _this2 = this;
|
|
266
|
-
var srObject, actual_sr;
|
|
267
257
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
268
258
|
while (1) switch (_context6.prev = _context6.next) {
|
|
269
259
|
case 0:
|
|
270
|
-
|
|
271
|
-
this.apply_changes();
|
|
272
|
-
srObject = this.obj.getSaveResult(true);
|
|
273
|
-
if (srObject != null) {
|
|
274
|
-
//we may have some extra data in the save result.
|
|
275
|
-
//try to find the main data
|
|
276
|
-
if (Array.isArray(srObject)) {
|
|
277
|
-
actual_sr = srObject.find(function (s) {
|
|
278
|
-
return _classPrivateMethodGet(_this2, _isValidSR, _isValidSR2).call(_this2, s);
|
|
279
|
-
});
|
|
280
|
-
if (actual_sr) srObject = actual_sr;
|
|
281
|
-
}
|
|
282
|
-
if (_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
|
|
283
|
-
if (srObject.insertedId || srObject._id) {
|
|
284
|
-
this.obj._id = srObject.insertedId || srObject._id;
|
|
285
|
-
}
|
|
286
|
-
if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
|
|
287
|
-
this.obj._index_value = Number(srObject._index_value);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
//this.loadValues(srObject);
|
|
292
|
-
}
|
|
293
|
-
_context6.next = 3;
|
|
260
|
+
_context6.next = 2;
|
|
294
261
|
return this.event_run("on_save");
|
|
295
|
-
case
|
|
296
|
-
_context6.next =
|
|
262
|
+
case 2:
|
|
263
|
+
_context6.next = 4;
|
|
297
264
|
return this.event_run("on_change", true);
|
|
298
|
-
case
|
|
299
|
-
_context6.next =
|
|
265
|
+
case 4:
|
|
266
|
+
_context6.next = 6;
|
|
300
267
|
return Promise.resolve(true);
|
|
301
|
-
case
|
|
268
|
+
case 6:
|
|
302
269
|
return _context6.abrupt("return", _context6.sent);
|
|
303
|
-
case
|
|
270
|
+
case 7:
|
|
304
271
|
case "end":
|
|
305
272
|
return _context6.stop();
|
|
306
273
|
}
|
|
@@ -315,11 +282,6 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
315
282
|
return WebObjectManager;
|
|
316
283
|
}(_ObjectManager2["default"]);
|
|
317
284
|
exports.WebObjectManager = WebObjectManager;
|
|
318
|
-
function _isValidSR2(s) {
|
|
319
|
-
if (_typeof(s) !== "object" && s == null) return false;
|
|
320
|
-
return s.insertedId || s._id || s._index_value && !Number.isNaN(s._index_value);
|
|
321
|
-
}
|
|
322
|
-
//we use this as backup
|
|
323
285
|
_defineProperty(WebObjectManager, "__web_path", "");
|
|
324
286
|
_defineProperty(WebObjectManager, "__web_type", "");
|
|
325
287
|
var _default = WebObjectManager;
|