@azrico/webobject 1.4.87 → 1.4.89

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.
@@ -62,6 +62,7 @@ export declare class WebObject extends SimpleObject {
62
62
  }): Promise<boolean>;
63
63
  Save(): Promise<any>;
64
64
  Delete(): Promise<boolean>;
65
+ Archive(): Promise<boolean>;
65
66
  canSave(deltaObj?: any): true | string;
66
67
  canDelete(): boolean;
67
68
  canArchive(): boolean;
@@ -78,6 +79,7 @@ export declare class WebObject extends SimpleObject {
78
79
  get_webname(): string;
79
80
  static get_webname(): string;
80
81
  onDelete(...p: any): Promise<any>;
82
+ onArchive(...p: any): Promise<any>;
81
83
  onLoad(...p: any): Promise<any>;
82
84
  onSave(...p: any): Promise<any>;
83
85
  onAfterSave(...p: any): Promise<any>;
@@ -34,7 +34,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
34
34
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
35
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
36
36
  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); }
37
- var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Delete, _get_deltaObject, _onDelete, _onLoad, _onSave, _onAfterSave, _onNew, _saveList, _get_single, _get_list) {
37
+ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Delete, _Archive, _get_deltaObject, _onDelete, _onArchive, _onLoad, _onSave, _onAfterSave, _onNew, _saveList, _get_single, _get_list) {
38
38
  _inherits(WebObject, _SimpleObject);
39
39
  var _super = _createSuper(WebObject);
40
40
  function WebObject() {
@@ -237,6 +237,29 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
237
237
  }
238
238
  }, _callee3, this);
239
239
  }))).apply(this, arguments);
240
+ }
241
+ }, {
242
+ key: "Archive",
243
+ value: function Archive() {
244
+ return (_Archive = _Archive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
245
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
246
+ while (1) switch (_context4.prev = _context4.next) {
247
+ case 0:
248
+ if (!(this.__throw_errors !== false)) {
249
+ _context4.next = 2;
250
+ break;
251
+ }
252
+ throw new Error("Archive not implented");
253
+ case 2:
254
+ WebObject.addError(this, "Archive not implented", "NOSAVE", true);
255
+ this.setSaveResult(false, "canceled");
256
+ return _context4.abrupt("return", false);
257
+ case 5:
258
+ case "end":
259
+ return _context4.stop();
260
+ }
261
+ }, _callee4, this);
262
+ }))).apply(this, arguments);
240
263
  } /* -------------------------------------------------------------------------- */
241
264
  }, {
242
265
  key: "canSave",
@@ -268,74 +291,74 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
268
291
  }, {
269
292
  key: "get_deltaObject",
270
293
  value: function get_deltaObject(_x3) {
271
- return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(p) {
294
+ return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(p) {
272
295
  var _this2 = this,
273
296
  _parseObj;
274
297
  var final_object, isChild, useDelta, allProperties, needId, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, parseObj, _iterator, _step, key, tempusers;
275
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
276
- while (1) switch (_context6.prev = _context6.next) {
298
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
299
+ while (1) switch (_context7.prev = _context7.next) {
277
300
  case 0:
278
301
  parseObj = function _parseObj2(_x4) {
279
- return (_parseObj = _parseObj || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(obj) {
302
+ return (_parseObj = _parseObj || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(obj) {
280
303
  var _ref;
281
304
  var newobj_dlt;
282
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
283
- while (1) switch (_context5.prev = _context5.next) {
305
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
306
+ while (1) switch (_context6.prev = _context6.next) {
284
307
  case 0:
285
308
  if (!(obj == null)) {
286
- _context5.next = 2;
309
+ _context6.next = 2;
287
310
  break;
288
311
  }
289
- return _context5.abrupt("return", undefined);
312
+ return _context6.abrupt("return", undefined);
290
313
  case 2:
291
314
  if (!Array.isArray(obj)) {
292
- _context5.next = 6;
315
+ _context6.next = 6;
293
316
  break;
294
317
  }
295
- _context5.next = 5;
318
+ _context6.next = 5;
296
319
  return Promise.all(obj.map(function (_x5) {
297
- return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(r) {
298
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
299
- while (1) switch (_context4.prev = _context4.next) {
320
+ return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(r) {
321
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
322
+ while (1) switch (_context5.prev = _context5.next) {
300
323
  case 0:
301
- _context4.next = 2;
324
+ _context5.next = 2;
302
325
  return parseObj(r);
303
326
  case 2:
304
- return _context4.abrupt("return", _context4.sent);
327
+ return _context5.abrupt("return", _context5.sent);
305
328
  case 3:
306
329
  case "end":
307
- return _context4.stop();
330
+ return _context5.stop();
308
331
  }
309
- }, _callee4);
332
+ }, _callee5);
310
333
  }))).apply(this, arguments);
311
334
  }));
312
335
  case 5:
313
- return _context5.abrupt("return", _context5.sent);
336
+ return _context6.abrupt("return", _context6.sent);
314
337
  case 6:
315
338
  if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
316
- _context5.next = 15;
339
+ _context6.next = 15;
317
340
  break;
318
341
  }
319
- _context5.next = 9;
342
+ _context6.next = 9;
320
343
  return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
321
344
  isChild: true
322
345
  }));
323
346
  case 9:
324
- newobj_dlt = _context5.sent;
347
+ newobj_dlt = _context6.sent;
325
348
  if ((0, _object.object_isEmpty)(newobj_dlt)) {
326
- _context5.next = 14;
349
+ _context6.next = 14;
327
350
  break;
328
351
  }
329
- return _context5.abrupt("return", newobj_dlt);
352
+ return _context6.abrupt("return", newobj_dlt);
330
353
  case 14:
331
- return _context5.abrupt("return", obj);
354
+ return _context6.abrupt("return", obj);
332
355
  case 15:
333
- return _context5.abrupt("return", obj);
356
+ return _context6.abrupt("return", obj);
334
357
  case 16:
335
358
  case "end":
336
- return _context5.stop();
359
+ return _context6.stop();
337
360
  }
338
- }, _callee5);
361
+ }, _callee6);
339
362
  }))).apply(this, arguments);
340
363
  };
341
364
  if (!p) p = {};
@@ -354,7 +377,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
354
377
  ignoreProtected: allProperties
355
378
  });
356
379
  }) : allkeys;
357
- _context6.next = 14;
380
+ _context7.next = 14;
358
381
  return _convert["default"].applyFormats({
359
382
  inputobject: dlt,
360
383
  formats: (0, _object.object_getStatic)(this, "__formatList"),
@@ -375,32 +398,32 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
375
398
  /* parse all changableKeys */
376
399
  /* -------------------------------------------------------------------------- */
377
400
  _iterator = _createForOfIteratorHelper(changableKeys);
378
- _context6.prev = 17;
401
+ _context7.prev = 17;
379
402
  _iterator.s();
380
403
  case 19:
381
404
  if ((_step = _iterator.n()).done) {
382
- _context6.next = 26;
405
+ _context7.next = 26;
383
406
  break;
384
407
  }
385
408
  key = _step.value;
386
- _context6.next = 23;
409
+ _context7.next = 23;
387
410
  return parseObj(dlt[key]);
388
411
  case 23:
389
- final_object[key] = _context6.sent;
412
+ final_object[key] = _context7.sent;
390
413
  case 24:
391
- _context6.next = 19;
414
+ _context7.next = 19;
392
415
  break;
393
416
  case 26:
394
- _context6.next = 31;
417
+ _context7.next = 31;
395
418
  break;
396
419
  case 28:
397
- _context6.prev = 28;
398
- _context6.t0 = _context6["catch"](17);
399
- _iterator.e(_context6.t0);
420
+ _context7.prev = 28;
421
+ _context7.t0 = _context7["catch"](17);
422
+ _iterator.e(_context7.t0);
400
423
  case 31:
401
- _context6.prev = 31;
424
+ _context7.prev = 31;
402
425
  _iterator.f();
403
- return _context6.finish(31);
426
+ return _context7.finish(31);
404
427
  case 34:
405
428
  /* -------------------------------------------------------------------------- */
406
429
  /* add id properties */
@@ -423,12 +446,12 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
423
446
  });
424
447
  final_object["_users"] = (0, _object.wrap_array)(tempusers);
425
448
  }
426
- return _context6.abrupt("return", final_object);
449
+ return _context7.abrupt("return", final_object);
427
450
  case 38:
428
451
  case "end":
429
- return _context6.stop();
452
+ return _context7.stop();
430
453
  }
431
- }, _callee6, this, [[17, 28, 31, 34]]);
454
+ }, _callee7, this, [[17, 28, 31, 34]]);
432
455
  }))).apply(this, arguments);
433
456
  } /* --------------------------------- Getters -------------------------------- */
434
457
  }, {
@@ -454,127 +477,154 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
454
477
  }, {
455
478
  key: "onDelete",
456
479
  value: /* -------------------------------------------------------------------------- */function onDelete() {
457
- return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
480
+ return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
458
481
  var _this$manager;
459
482
  var _len,
460
483
  p,
461
484
  _key,
462
- _args7 = arguments;
463
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
464
- while (1) switch (_context7.prev = _context7.next) {
485
+ _args8 = arguments;
486
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
487
+ while (1) switch (_context8.prev = _context8.next) {
465
488
  case 0:
466
489
  this.isDeleted = true;
467
- for (_len = _args7.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
468
- p[_key] = _args7[_key];
490
+ for (_len = _args8.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
491
+ p[_key] = _args8[_key];
469
492
  }
470
- _context7.next = 4;
493
+ _context8.next = 4;
471
494
  return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
472
495
  case 4:
473
- return _context7.abrupt("return", _context7.sent);
496
+ return _context8.abrupt("return", _context8.sent);
474
497
  case 5:
475
498
  case "end":
476
- return _context7.stop();
499
+ return _context8.stop();
477
500
  }
478
- }, _callee7, this);
501
+ }, _callee8, this);
479
502
  }))).apply(this, arguments);
480
503
  }
481
504
  }, {
482
- key: "onLoad",
483
- value: function onLoad() {
484
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
505
+ key: "onArchive",
506
+ value: function onArchive() {
507
+ return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
485
508
  var _this$manager2;
486
509
  var _len2,
487
510
  p,
488
511
  _key2,
489
- _args8 = arguments;
490
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
491
- while (1) switch (_context8.prev = _context8.next) {
512
+ _args9 = arguments;
513
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
514
+ while (1) switch (_context9.prev = _context9.next) {
515
+ case 0:
516
+ this.isArchived = true;
517
+ for (_len2 = _args9.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
518
+ p[_key2] = _args9[_key2];
519
+ }
520
+ _context9.next = 4;
521
+ return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onArchive.apply(_this$manager2, p);
522
+ case 4:
523
+ return _context9.abrupt("return", _context9.sent);
524
+ case 5:
525
+ case "end":
526
+ return _context9.stop();
527
+ }
528
+ }, _callee9, this);
529
+ }))).apply(this, arguments);
530
+ }
531
+ }, {
532
+ key: "onLoad",
533
+ value: function onLoad() {
534
+ return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
535
+ var _this$manager3;
536
+ var _len3,
537
+ p,
538
+ _key3,
539
+ _args10 = arguments;
540
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
541
+ while (1) switch (_context10.prev = _context10.next) {
492
542
  case 0:
493
543
  this.isDeleted = false;
494
- for (_len2 = _args8.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
495
- p[_key2] = _args8[_key2];
544
+ for (_len3 = _args10.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
545
+ p[_key3] = _args10[_key3];
496
546
  }
497
- _context8.next = 4;
498
- return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
547
+ _context10.next = 4;
548
+ return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onLoad.apply(_this$manager3, p);
499
549
  case 4:
500
- return _context8.abrupt("return", _context8.sent);
550
+ return _context10.abrupt("return", _context10.sent);
501
551
  case 5:
502
552
  case "end":
503
- return _context8.stop();
553
+ return _context10.stop();
504
554
  }
505
- }, _callee8, this);
555
+ }, _callee10, this);
506
556
  }))).apply(this, arguments);
507
557
  }
508
558
  }, {
509
559
  key: "onSave",
510
560
  value: function onSave() {
511
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
512
- var _this$manager4;
561
+ return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
562
+ var _this$manager5;
513
563
  var srObject,
514
- _this$manager3,
515
- _len3,
564
+ _this$manager4,
565
+ _len4,
516
566
  p,
517
- _key3,
518
- _args9 = arguments;
519
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
520
- while (1) switch (_context9.prev = _context9.next) {
567
+ _key4,
568
+ _args11 = arguments;
569
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
570
+ while (1) switch (_context11.prev = _context11.next) {
521
571
  case 0:
522
572
  if (!this.isSaved) {
523
- _context9.next = 7;
573
+ _context11.next = 7;
524
574
  break;
525
575
  }
526
576
  this.apply_changes();
527
577
  srObject = this.getSaveResult(true);
528
578
  if (!this.saveResultHasID(srObject)) {
529
- _context9.next = 7;
579
+ _context11.next = 7;
530
580
  break;
531
581
  }
532
582
  /* -------------------------------------------------------------------------- */
533
583
  WebObject.LoadIdsFromSaveResult(this, srObject);
534
- _context9.next = 7;
535
- return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
584
+ _context11.next = 7;
585
+ return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.event_run("on_id_change");
536
586
  case 7:
537
- for (_len3 = _args9.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
538
- p[_key3] = _args9[_key3];
587
+ for (_len4 = _args11.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
588
+ p[_key4] = _args11[_key4];
539
589
  }
540
- _context9.next = 10;
541
- return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
590
+ _context11.next = 10;
591
+ return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onSave.apply(_this$manager5, p);
542
592
  case 10:
543
- _context9.next = 12;
593
+ _context11.next = 12;
544
594
  return this.onAfterSave();
545
595
  case 12:
546
- return _context9.abrupt("return", true);
596
+ return _context11.abrupt("return", true);
547
597
  case 13:
548
598
  case "end":
549
- return _context9.stop();
599
+ return _context11.stop();
550
600
  }
551
- }, _callee9, this);
601
+ }, _callee11, this);
552
602
  }))).apply(this, arguments);
553
603
  }
554
604
  }, {
555
605
  key: "onAfterSave",
556
606
  value: function onAfterSave() {
557
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
558
- var _this$manager5;
559
- var _len4,
607
+ return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
608
+ var _this$manager6;
609
+ var _len5,
560
610
  p,
561
- _key4,
562
- _args10 = arguments;
563
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
564
- while (1) switch (_context10.prev = _context10.next) {
611
+ _key5,
612
+ _args12 = arguments;
613
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
614
+ while (1) switch (_context12.prev = _context12.next) {
565
615
  case 0:
566
- for (_len4 = _args10.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
567
- p[_key4] = _args10[_key4];
616
+ for (_len5 = _args12.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
617
+ p[_key5] = _args12[_key5];
568
618
  }
569
- _context10.next = 3;
570
- return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onAfterSave.apply(_this$manager5, p);
619
+ _context12.next = 3;
620
+ return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onAfterSave.apply(_this$manager6, p);
571
621
  case 3:
572
- return _context10.abrupt("return", true);
622
+ return _context12.abrupt("return", true);
573
623
  case 4:
574
624
  case "end":
575
- return _context10.stop();
625
+ return _context12.stop();
576
626
  }
577
- }, _callee10, this);
627
+ }, _callee12, this);
578
628
  }))).apply(this, arguments);
579
629
  }
580
630
  }, {
@@ -595,27 +645,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
595
645
  }, {
596
646
  key: "onNew",
597
647
  value: function onNew() {
598
- return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
599
- var _this$manager6;
600
- var _len5,
648
+ return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
649
+ var _this$manager7;
650
+ var _len6,
601
651
  p,
602
- _key5,
603
- _args11 = arguments;
604
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
605
- while (1) switch (_context11.prev = _context11.next) {
652
+ _key6,
653
+ _args13 = arguments;
654
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
655
+ while (1) switch (_context13.prev = _context13.next) {
606
656
  case 0:
607
- for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
608
- p[_key5] = _args11[_key5];
657
+ for (_len6 = _args13.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
658
+ p[_key6] = _args13[_key6];
609
659
  }
610
- _context11.next = 3;
611
- return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
660
+ _context13.next = 3;
661
+ return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.onNew.apply(_this$manager7, p);
612
662
  case 3:
613
- return _context11.abrupt("return", _context11.sent);
663
+ return _context13.abrupt("return", _context13.sent);
614
664
  case 4:
615
665
  case "end":
616
- return _context11.stop();
666
+ return _context13.stop();
617
667
  }
618
- }, _callee11, this);
668
+ }, _callee13, this);
619
669
  }))).apply(this, arguments);
620
670
  } /* -------------------------------------------------------------------------- */
621
671
  }, {
@@ -662,7 +712,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
662
712
  }, {
663
713
  key: "saveList",
664
714
  value: function saveList(_x6) {
665
- return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(itemList) {
715
+ return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(itemList) {
666
716
  var _extraOptions$chunksi;
667
717
  var extraOptions,
668
718
  chunks,
@@ -679,11 +729,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
679
729
  _item,
680
730
  _index2,
681
731
  _item2,
682
- _args12 = arguments;
683
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
684
- while (1) switch (_context12.prev = _context12.next) {
732
+ _args14 = arguments;
733
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
734
+ while (1) switch (_context14.prev = _context14.next) {
685
735
  case 0:
686
- extraOptions = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
736
+ extraOptions = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
687
737
  if (!extraOptions) extraOptions = {};
688
738
  chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
689
739
  delete extraOptions.chunksize;
@@ -691,7 +741,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
691
741
  index = 0;
692
742
  case 6:
693
743
  if (!(index < chunks.length)) {
694
- _context12.next = 36;
744
+ _context14.next = 36;
695
745
  break;
696
746
  }
697
747
  items_to_save = chunks[index];
@@ -699,81 +749,81 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
699
749
  k = 0;
700
750
  case 10:
701
751
  if (!(k < items_to_save.length)) {
702
- _context12.next = 19;
752
+ _context14.next = 19;
703
753
  break;
704
754
  }
705
755
  item = items_to_save[k];
706
- _context12.next = 14;
756
+ _context14.next = 14;
707
757
  return item.get_deltaObject();
708
758
  case 14:
709
- dlt = _context12.sent;
759
+ dlt = _context14.sent;
710
760
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
711
761
  _id: item.getID()
712
762
  }, dlt));
713
763
  case 16:
714
764
  k++;
715
- _context12.next = 10;
765
+ _context14.next = 10;
716
766
  break;
717
767
  case 19:
718
- _context12.next = 21;
768
+ _context14.next = 21;
719
769
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
720
770
  __save_list: WebObject.zipSaveList(save_array)
721
771
  }, extraOptions));
722
772
  case 21:
723
- resultObject = _context12.sent;
773
+ resultObject = _context14.sent;
724
774
  if (!Array.isArray(resultObject)) {
725
- _context12.next = 33;
775
+ _context14.next = 33;
726
776
  break;
727
777
  }
728
778
  _index = 0;
729
779
  case 24:
730
780
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
731
- _context12.next = 33;
781
+ _context14.next = 33;
732
782
  break;
733
783
  }
734
784
  res = resultObject[_index];
735
785
  _item = items_to_save[_index];
736
786
  _item.setSaveResult(res);
737
- _context12.next = 30;
787
+ _context14.next = 30;
738
788
  return _item.onSave();
739
789
  case 30:
740
790
  _index++;
741
- _context12.next = 24;
791
+ _context14.next = 24;
742
792
  break;
743
793
  case 33:
744
794
  index++;
745
- _context12.next = 6;
795
+ _context14.next = 6;
746
796
  break;
747
797
  case 36:
748
798
  _index2 = 0;
749
799
  case 37:
750
800
  if (!(_index2 < itemList.length)) {
751
- _context12.next = 46;
801
+ _context14.next = 46;
752
802
  break;
753
803
  }
754
804
  _item2 = itemList[_index2];
755
805
  if (_item2.isSaved) {
756
- _context12.next = 41;
806
+ _context14.next = 41;
757
807
  break;
758
808
  }
759
- return _context12.abrupt("return", false);
809
+ return _context14.abrupt("return", false);
760
810
  case 41:
761
811
  if (!(_item2.getSaveResultType() != "normal")) {
762
- _context12.next = 43;
812
+ _context14.next = 43;
763
813
  break;
764
814
  }
765
- return _context12.abrupt("return", false);
815
+ return _context14.abrupt("return", false);
766
816
  case 43:
767
817
  _index2++;
768
- _context12.next = 37;
818
+ _context14.next = 37;
769
819
  break;
770
820
  case 46:
771
- return _context12.abrupt("return", true);
821
+ return _context14.abrupt("return", true);
772
822
  case 47:
773
823
  case "end":
774
- return _context12.stop();
824
+ return _context14.stop();
775
825
  }
776
- }, _callee12, this);
826
+ }, _callee14, this);
777
827
  }))).apply(this, arguments);
778
828
  }
779
829
  }, {
@@ -819,64 +869,64 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
819
869
  }, {
820
870
  key: "get_single",
821
871
  value: function get_single() {
822
- return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
823
- var _len6,
872
+ return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
873
+ var _len7,
824
874
  p,
825
- _key6,
875
+ _key7,
826
876
  search,
827
877
  readonly,
828
878
  fetchID,
829
879
  res,
830
880
  params,
831
- _args13 = arguments;
832
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
833
- while (1) switch (_context13.prev = _context13.next) {
881
+ _args15 = arguments;
882
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
883
+ while (1) switch (_context15.prev = _context15.next) {
834
884
  case 0:
835
- for (_len6 = _args13.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
836
- p[_key6] = _args13[_key6];
885
+ for (_len7 = _args15.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
886
+ p[_key7] = _args15[_key7];
837
887
  }
838
888
  search = p.shift();
839
889
  readonly = p.shift();
840
890
  fetchID = p.shift();
841
891
  if (!(0, _object.object_isEmpty)(search)) {
842
- _context13.next = 6;
892
+ _context15.next = 6;
843
893
  break;
844
894
  }
845
- return _context13.abrupt("return", undefined);
895
+ return _context15.abrupt("return", undefined);
846
896
  case 6:
847
897
  params = {};
848
898
  params.context = readonly ? "view" : "edit";
849
- _context13.t0 = _typeof(search);
850
- _context13.next = _context13.t0 === "string" ? 11 : _context13.t0 === "number" ? 11 : _context13.t0 === "object" ? 19 : 19;
899
+ _context15.t0 = _typeof(search);
900
+ _context15.next = _context15.t0 === "string" ? 11 : _context15.t0 === "number" ? 11 : _context15.t0 === "object" ? 19 : 19;
851
901
  break;
852
902
  case 11:
853
903
  search = String(search);
854
- _context13.t1 = this;
855
- _context13.t2 = this;
856
- _context13.next = 16;
904
+ _context15.t1 = this;
905
+ _context15.t2 = this;
906
+ _context15.next = 16;
857
907
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
858
908
  fetchID: fetchID
859
909
  });
860
910
  case 16:
861
- _context13.t3 = _context13.sent;
862
- res = _context13.t1.ensure.call(_context13.t1, _context13.t2, _context13.t3);
863
- return _context13.abrupt("break", 25);
911
+ _context15.t3 = _context15.sent;
912
+ res = _context15.t1.ensure.call(_context15.t1, _context15.t2, _context15.t3);
913
+ return _context15.abrupt("break", 25);
864
914
  case 19:
865
- _context13.t4 = _object.object_first;
866
- _context13.next = 22;
915
+ _context15.t4 = _object.object_first;
916
+ _context15.next = 22;
867
917
  return this.get_list(search, readonly, fetchID);
868
918
  case 22:
869
- _context13.t5 = _context13.sent;
870
- res = (0, _context13.t4)(_context13.t5);
871
- return _context13.abrupt("break", 25);
919
+ _context15.t5 = _context15.sent;
920
+ res = (0, _context15.t4)(_context15.t5);
921
+ return _context15.abrupt("break", 25);
872
922
  case 25:
873
923
  WebObject.setReadonly(res, readonly);
874
- return _context13.abrupt("return", res);
924
+ return _context15.abrupt("return", res);
875
925
  case 27:
876
926
  case "end":
877
- return _context13.stop();
927
+ return _context15.stop();
878
928
  }
879
- }, _callee13, this);
929
+ }, _callee15, this);
880
930
  }))).apply(this, arguments);
881
931
  }
882
932
  /**
@@ -886,42 +936,42 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
886
936
  }, {
887
937
  key: "get_list",
888
938
  value: function get_list() {
889
- return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
890
- var _len7,
939
+ return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
940
+ var _len8,
891
941
  p,
892
- _key7,
942
+ _key8,
893
943
  search,
894
944
  readonly,
895
945
  fetchID,
896
946
  result_items,
897
947
  selftype,
898
948
  res,
899
- _args14 = arguments;
900
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
901
- while (1) switch (_context14.prev = _context14.next) {
949
+ _args16 = arguments;
950
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
951
+ while (1) switch (_context16.prev = _context16.next) {
902
952
  case 0:
903
- for (_len7 = _args14.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
904
- p[_key7] = _args14[_key7];
953
+ for (_len8 = _args16.length, p = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
954
+ p[_key8] = _args16[_key8];
905
955
  }
906
956
  search = p.shift();
907
957
  readonly = p.shift();
908
958
  fetchID = p.shift();
909
959
  if (!search) search = {};
910
- _context14.next = 7;
960
+ _context16.next = 7;
911
961
  return _global.gfunc.run_action("get", this.__web_path, search, {
912
962
  fetchID: fetchID
913
963
  });
914
964
  case 7:
915
- result_items = _context14.sent;
965
+ result_items = _context16.sent;
916
966
  selftype = this.prototype;
917
967
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
918
968
  WebObject.setReadonly(res, readonly);
919
- return _context14.abrupt("return", res);
969
+ return _context16.abrupt("return", res);
920
970
  case 12:
921
971
  case "end":
922
- return _context14.stop();
972
+ return _context16.stop();
923
973
  }
924
- }, _callee14, this);
974
+ }, _callee16, this);
925
975
  }))).apply(this, arguments);
926
976
  }
927
977
  }]);
@@ -39,6 +39,7 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
39
39
  * @returns
40
40
  */
41
41
  onDelete(...p: any): Promise<any>;
42
+ onArchive(...p: any): Promise<any>;
42
43
  /**
43
44
  * Use this when you load data to the object
44
45
  * @param p
@@ -30,7 +30,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
30
30
  /**
31
31
  * This class manages the events of an Simple Object
32
32
  */
33
- var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _get_deltaObject, _Save, _Load, _onNew, _onDelete, _onLoad, _onSave, _onAfterSave) {
33
+ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _get_deltaObject, _Save, _Load, _onNew, _onDelete, _onArchive, _onLoad, _onSave, _onAfterSave) {
34
34
  _inherits(WebObjectManager, _ObjectManager);
35
35
  var _super = _createSuper(WebObjectManager);
36
36
  /* -------------------------------------------------------------------------- */
@@ -282,17 +282,38 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
282
282
  _context7.next = 5;
283
283
  return this.event_run("on_after_delete");
284
284
  case 5:
285
- _context7.next = 7;
286
- return Promise.resolve(true);
287
- case 7:
288
- return _context7.abrupt("return", _context7.sent);
289
- case 8:
285
+ return _context7.abrupt("return", true);
286
+ case 6:
290
287
  case "end":
291
288
  return _context7.stop();
292
289
  }
293
290
  }, _callee7, this);
294
291
  }))).apply(this, arguments);
295
292
  }
293
+ }, {
294
+ key: "onArchive",
295
+ value: function onArchive() {
296
+ return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
297
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
298
+ while (1) switch (_context8.prev = _context8.next) {
299
+ case 0:
300
+ if (this.obj) {
301
+ this.obj.isDeleted = true;
302
+ }
303
+ _context8.next = 3;
304
+ return this.event_run("on_archive");
305
+ case 3:
306
+ _context8.next = 5;
307
+ return this.event_run("on_after_archive");
308
+ case 5:
309
+ return _context8.abrupt("return", true);
310
+ case 6:
311
+ case "end":
312
+ return _context8.stop();
313
+ }
314
+ }, _callee8, this);
315
+ }))).apply(this, arguments);
316
+ }
296
317
  /**
297
318
  * Use this when you load data to the object
298
319
  * @param p
@@ -301,35 +322,32 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
301
322
  }, {
302
323
  key: "onLoad",
303
324
  value: function onLoad() {
304
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
305
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
306
- while (1) switch (_context8.prev = _context8.next) {
325
+ return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
326
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
327
+ while (1) switch (_context9.prev = _context9.next) {
307
328
  case 0:
308
329
  if (this.canModify && this.obj) {
309
330
  this.obj.isDeleted = false;
310
331
  this.obj.setOriginal();
311
332
  }
312
- _context8.next = 3;
333
+ _context9.next = 3;
313
334
  return this.event_run("on_load");
314
335
  case 3:
315
- _context8.next = 5;
336
+ _context9.next = 5;
316
337
  return this.event_run("on_change", true);
317
338
  case 5:
318
- _context8.next = 7;
339
+ _context9.next = 7;
319
340
  return this.event_run("on_after_load");
320
341
  case 7:
321
- _context8.next = 9;
342
+ _context9.next = 9;
322
343
  return this.event_run("on_load_finished");
323
344
  case 9:
324
- _context8.next = 11;
325
- return Promise.resolve(true);
326
- case 11:
327
- return _context8.abrupt("return", _context8.sent);
328
- case 12:
345
+ return _context9.abrupt("return", true);
346
+ case 10:
329
347
  case "end":
330
- return _context8.stop();
348
+ return _context9.stop();
331
349
  }
332
- }, _callee8, this);
350
+ }, _callee9, this);
333
351
  }))).apply(this, arguments);
334
352
  }
335
353
  /**
@@ -340,49 +358,49 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
340
358
  }, {
341
359
  key: "onSave",
342
360
  value: function onSave() {
343
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
344
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
345
- while (1) switch (_context9.prev = _context9.next) {
361
+ return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
362
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
363
+ while (1) switch (_context10.prev = _context10.next) {
346
364
  case 0:
347
- _context9.next = 2;
365
+ _context10.next = 2;
348
366
  return this.event_run("on_save");
349
367
  case 2:
350
- _context9.next = 4;
368
+ _context10.next = 4;
351
369
  return this.event_run("on_change", true);
352
370
  case 4:
353
- _context9.next = 6;
371
+ _context10.next = 6;
354
372
  return Promise.resolve(true);
355
373
  case 6:
356
- return _context9.abrupt("return", _context9.sent);
374
+ return _context10.abrupt("return", _context10.sent);
357
375
  case 7:
358
376
  case "end":
359
- return _context9.stop();
377
+ return _context10.stop();
360
378
  }
361
- }, _callee9, this);
379
+ }, _callee10, this);
362
380
  }))).apply(this, arguments);
363
381
  }
364
382
  }, {
365
383
  key: "onAfterSave",
366
384
  value: function onAfterSave() {
367
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
368
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
369
- while (1) switch (_context10.prev = _context10.next) {
385
+ return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
386
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
387
+ while (1) switch (_context11.prev = _context11.next) {
370
388
  case 0:
371
- _context10.next = 2;
389
+ _context11.next = 2;
372
390
  return this.event_run("on_after_save");
373
391
  case 2:
374
- _context10.next = 4;
392
+ _context11.next = 4;
375
393
  return this.event_run("on_save_finished");
376
394
  case 4:
377
- _context10.next = 6;
395
+ _context11.next = 6;
378
396
  return Promise.resolve(true);
379
397
  case 6:
380
- return _context10.abrupt("return", _context10.sent);
398
+ return _context11.abrupt("return", _context11.sent);
381
399
  case 7:
382
400
  case "end":
383
- return _context10.stop();
401
+ return _context11.stop();
384
402
  }
385
- }, _callee10, this);
403
+ }, _callee11, this);
386
404
  }))).apply(this, arguments);
387
405
  }
388
406
  }]);
@@ -191,7 +191,7 @@ export declare class SimpleObject extends MapableObject {
191
191
  * and its type
192
192
  * @param toObj
193
193
  */
194
- setSaveResult(toObj: any, type?: saveResultType | "auto"): void;
194
+ setSaveResult(toObj: any, type?: saveResultType | "auto", registerErrors?: boolean): void;
195
195
  getSaveResult(original?: boolean): any;
196
196
  getSaveResultType(): saveResultType;
197
197
  static setTemp(obj: SimpleObject | any, key: string, value: any, sendChanges?: sendChangesType): Promise<void>;
@@ -865,12 +865,17 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
865
865
  */
866
866
  function setSaveResult(toObj) {
867
867
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "auto";
868
+ var registerErrors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
868
869
  _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
869
870
  //check if the given object is a valid save result
870
871
  if (type === "error") this.__saveResultIsSuccess = false;else this.__saveResultIsSuccess = Boolean(type === "nothing" || this.constructor["isResultValid"](toObj));
871
872
  if (type === "auto") {
872
873
  type = this.__saveResultIsSuccess ? "normal" : "error";
873
874
  }
875
+ if (registerErrors && !this.__saveResultIsSuccess) {
876
+ console.error("bad save result : ", this.__saveResultObject);
877
+ SimpleObject.addError(this, "save result is not valid", "the response from server was not valid", true);
878
+ }
874
879
  this.__saveResultType = type;
875
880
  }
876
881
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.87",
3
+ "version": "1.4.89",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",