@azrico/webobject 1.4.90 → 1.4.91

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