@azrico/webobject 1.3.15 → 1.3.17

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.
@@ -410,9 +410,10 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
410
410
  value: function () {
411
411
  var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
412
412
  var _this3 = this,
413
- _this$manager3;
413
+ _this$manager4;
414
414
  var srObject,
415
415
  actual_sr,
416
+ _this$manager3,
416
417
  _len3,
417
418
  p,
418
419
  _key3,
@@ -420,36 +421,45 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
420
421
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
421
422
  while (1) switch (_context8.prev = _context8.next) {
422
423
  case 0:
423
- if (this.isSaved) {
424
- this.apply_changes();
425
- srObject = this.getSaveResult(true);
426
- if (srObject != null) {
427
- //we may have some extra data in the save result.
428
- //try to find the main data
429
- if (Array.isArray(srObject)) {
430
- actual_sr = srObject.find(function (s) {
431
- return _classPrivateMethodGet(_this3, _isValidSR, _isValidSR2).call(_this3, s);
432
- });
433
- if (actual_sr) srObject = actual_sr;
434
- }
435
- if (_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
436
- if (srObject.insertedId || srObject._id) {
437
- this._id = srObject.insertedId || srObject._id;
438
- }
439
- if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
440
- this._index_value = Number(srObject._index_value);
441
- }
442
- }
443
- }
424
+ if (!this.isSaved) {
425
+ _context8.next = 10;
426
+ break;
427
+ }
428
+ this.apply_changes();
429
+ srObject = this.getSaveResult(true);
430
+ if (!(srObject != null)) {
431
+ _context8.next = 10;
432
+ break;
433
+ }
434
+ //we may have some extra data in the save result.
435
+ //try to find the main data
436
+ if (Array.isArray(srObject)) {
437
+ actual_sr = srObject.find(function (s) {
438
+ return _classPrivateMethodGet(_this3, _isValidSR, _isValidSR2).call(_this3, s);
439
+ });
440
+ if (actual_sr) srObject = actual_sr;
444
441
  }
442
+ if (!_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
443
+ _context8.next = 10;
444
+ break;
445
+ }
446
+ if (srObject.insertedId || srObject._id) {
447
+ this._id = srObject.insertedId || srObject._id;
448
+ }
449
+ if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
450
+ this._index_value = Number(srObject._index_value);
451
+ }
452
+ _context8.next = 10;
453
+ return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
454
+ case 10:
445
455
  for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
446
456
  p[_key3] = _args8[_key3];
447
457
  }
448
- _context8.next = 4;
449
- return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onSave.apply(_this$manager3, p);
450
- case 4:
458
+ _context8.next = 13;
459
+ return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
460
+ case 13:
451
461
  return _context8.abrupt("return", _context8.sent);
452
- case 5:
462
+ case 14:
453
463
  case "end":
454
464
  return _context8.stop();
455
465
  }
@@ -464,7 +474,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
464
474
  key: "onNew",
465
475
  value: function () {
466
476
  var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
467
- var _this$manager4;
477
+ var _this$manager5;
468
478
  var _len4,
469
479
  p,
470
480
  _key4,
@@ -476,7 +486,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
476
486
  p[_key4] = _args9[_key4];
477
487
  }
478
488
  _context9.next = 3;
479
- return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onNew.apply(_this$manager4, p);
489
+ return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onNew.apply(_this$manager5, p);
480
490
  case 3:
481
491
  return _context9.abrupt("return", _context9.sent);
482
492
  case 4:
@@ -315,10 +315,13 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
315
315
  return this.event_run("on_after_load");
316
316
  case 7:
317
317
  _context7.next = 9;
318
- return Promise.resolve(true);
318
+ return this.event_run("on_load_finished");
319
319
  case 9:
320
+ _context7.next = 11;
321
+ return Promise.resolve(true);
322
+ case 11:
320
323
  return _context7.abrupt("return", _context7.sent);
321
- case 10:
324
+ case 12:
322
325
  case "end":
323
326
  return _context7.stop();
324
327
  }
@@ -351,10 +354,13 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
351
354
  return this.event_run("on_after_save");
352
355
  case 6:
353
356
  _context8.next = 8;
354
- return Promise.resolve(true);
357
+ return this.event_run("on_save_finished");
355
358
  case 8:
359
+ _context8.next = 10;
360
+ return Promise.resolve(true);
361
+ case 10:
356
362
  return _context8.abrupt("return", _context8.sent);
357
- case 9:
363
+ case 11:
358
364
  case "end":
359
365
  return _context8.stop();
360
366
  }
@@ -168,7 +168,10 @@ var ObjectManager = /*#__PURE__*/function () {
168
168
  value: function getValue(key) {
169
169
  var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
170
170
  var thisobj = this.obj;
171
- if (thisobj == null || typeof thisobj.getValue != "function") return null;
171
+ if (thisobj == null || typeof thisobj.getValue != "function") {
172
+ console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
173
+ return null;
174
+ }
172
175
  return thisobj.getValue(key, original);
173
176
  }
174
177
  }, {
@@ -188,23 +191,24 @@ var ObjectManager = /*#__PURE__*/function () {
188
191
  case 0:
189
192
  thisobj = this.obj;
190
193
  if (!(thisobj == null || typeof thisobj.setValue != "function")) {
191
- _context2.next = 3;
194
+ _context2.next = 4;
192
195
  break;
193
196
  }
197
+ console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
194
198
  return _context2.abrupt("return", false);
195
- case 3:
196
- _context2.next = 5;
199
+ case 4:
200
+ _context2.next = 6;
197
201
  return thisobj.setValue(key, value);
198
- case 5:
202
+ case 6:
199
203
  _context2.t0 = _context2.sent;
200
204
  if (_context2.t0) {
201
- _context2.next = 8;
205
+ _context2.next = 9;
202
206
  break;
203
207
  }
204
208
  _context2.t0 = false;
205
- case 8:
206
- return _context2.abrupt("return", _context2.t0);
207
209
  case 9:
210
+ return _context2.abrupt("return", _context2.t0);
211
+ case 10:
208
212
  case "end":
209
213
  return _context2.stop();
210
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.3.15",
3
+ "version": "1.3.17",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",