@azrico/webobject 1.4.90 → 1.4.92

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;
@@ -80,6 +81,7 @@ export declare class WebObject extends SimpleObject {
80
81
  static get_webname(): string;
81
82
  onDelete(...p: any): Promise<any>;
82
83
  onArchive(...p: any): Promise<any>;
84
+ onUnArchive(...p: any): Promise<any>;
83
85
  onLoad(...p: any): Promise<any>;
84
86
  onSave(...p: any): Promise<any>;
85
87
  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, _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, _onUnArchive, _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,181 @@ 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
- this.isArchived = true;
517
- for (_len2 = _args9.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
518
- p[_key2] = _args9[_key2];
539
+ if (this.isSaved) this.isArchived = true;
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
- key: "onLoad",
533
- value: function onLoad() {
534
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
555
+ key: "onUnArchive",
556
+ value: function onUnArchive() {
557
+ return (_onUnArchive = _onUnArchive || _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) {
565
+ case 0:
566
+ if (this.isSaved) this.isArchived = false;
567
+ for (_len3 = _args11.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
568
+ p[_key3] = _args11[_key3];
569
+ }
570
+ _context11.next = 4;
571
+ return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onUnArchive.apply(_this$manager3, p);
572
+ case 4:
573
+ return _context11.abrupt("return", _context11.sent);
574
+ case 5:
575
+ case "end":
576
+ return _context11.stop();
577
+ }
578
+ }, _callee11, this);
579
+ }))).apply(this, arguments);
580
+ }
581
+ }, {
582
+ key: "onLoad",
583
+ value: function onLoad() {
584
+ return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
585
+ var _this$manager4;
586
+ var _len4,
587
+ p,
588
+ _key4,
589
+ _args12 = arguments;
590
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
591
+ while (1) switch (_context12.prev = _context12.next) {
542
592
  case 0:
543
593
  this.isDeleted = false;
544
- for (_len3 = _args10.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
545
- p[_key3] = _args10[_key3];
594
+ for (_len4 = _args12.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
595
+ p[_key4] = _args12[_key4];
546
596
  }
547
- _context10.next = 4;
548
- return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onLoad.apply(_this$manager3, p);
597
+ _context12.next = 4;
598
+ return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onLoad.apply(_this$manager4, p);
549
599
  case 4:
550
- return _context10.abrupt("return", _context10.sent);
600
+ return _context12.abrupt("return", _context12.sent);
551
601
  case 5:
552
602
  case "end":
553
- return _context10.stop();
603
+ return _context12.stop();
554
604
  }
555
- }, _callee10, this);
605
+ }, _callee12, this);
556
606
  }))).apply(this, arguments);
557
607
  }
558
608
  }, {
559
609
  key: "onSave",
560
610
  value: function onSave() {
561
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
562
- var _this$manager5;
611
+ return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
612
+ var _this$manager6;
563
613
  var srObject,
564
- _this$manager4,
565
- _len4,
614
+ _this$manager5,
615
+ _len5,
566
616
  p,
567
- _key4,
568
- _args11 = arguments;
569
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
570
- while (1) switch (_context11.prev = _context11.next) {
617
+ _key5,
618
+ _args13 = arguments;
619
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
620
+ while (1) switch (_context13.prev = _context13.next) {
571
621
  case 0:
572
622
  if (!this.isSaved) {
573
- _context11.next = 7;
623
+ _context13.next = 7;
574
624
  break;
575
625
  }
576
626
  this.apply_changes();
577
627
  srObject = this.getSaveResult(true);
578
628
  if (!this.saveResultHasID(srObject)) {
579
- _context11.next = 7;
629
+ _context13.next = 7;
580
630
  break;
581
631
  }
582
632
  /* -------------------------------------------------------------------------- */
583
633
  WebObject.LoadIdsFromSaveResult(this, srObject);
584
- _context11.next = 7;
585
- return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.event_run("on_id_change");
634
+ _context13.next = 7;
635
+ return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.event_run("on_id_change");
586
636
  case 7:
587
- for (_len4 = _args11.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
588
- p[_key4] = _args11[_key4];
637
+ for (_len5 = _args13.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
638
+ p[_key5] = _args13[_key5];
589
639
  }
590
- _context11.next = 10;
591
- return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onSave.apply(_this$manager5, p);
640
+ _context13.next = 10;
641
+ return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onSave.apply(_this$manager6, p);
592
642
  case 10:
593
- _context11.next = 12;
643
+ _context13.next = 12;
594
644
  return this.onAfterSave();
595
645
  case 12:
596
- return _context11.abrupt("return", true);
646
+ return _context13.abrupt("return", true);
597
647
  case 13:
598
648
  case "end":
599
- return _context11.stop();
649
+ return _context13.stop();
600
650
  }
601
- }, _callee11, this);
651
+ }, _callee13, this);
602
652
  }))).apply(this, arguments);
603
653
  }
604
654
  }, {
605
655
  key: "onAfterSave",
606
656
  value: function onAfterSave() {
607
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
608
- var _this$manager6;
609
- var _len5,
657
+ return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
658
+ var _this$manager7;
659
+ var _len6,
610
660
  p,
611
- _key5,
612
- _args12 = arguments;
613
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
614
- while (1) switch (_context12.prev = _context12.next) {
661
+ _key6,
662
+ _args14 = arguments;
663
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
664
+ while (1) switch (_context14.prev = _context14.next) {
615
665
  case 0:
616
- for (_len5 = _args12.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
617
- p[_key5] = _args12[_key5];
666
+ for (_len6 = _args14.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
667
+ p[_key6] = _args14[_key6];
618
668
  }
619
- _context12.next = 3;
620
- return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onAfterSave.apply(_this$manager6, p);
669
+ _context14.next = 3;
670
+ return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.onAfterSave.apply(_this$manager7, p);
621
671
  case 3:
622
- return _context12.abrupt("return", true);
672
+ return _context14.abrupt("return", true);
623
673
  case 4:
624
674
  case "end":
625
- return _context12.stop();
675
+ return _context14.stop();
626
676
  }
627
- }, _callee12, this);
677
+ }, _callee14, this);
628
678
  }))).apply(this, arguments);
629
679
  }
630
680
  }, {
@@ -645,27 +695,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
645
695
  }, {
646
696
  key: "onNew",
647
697
  value: function onNew() {
648
- return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
649
- var _this$manager7;
650
- var _len6,
698
+ return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
699
+ var _this$manager8;
700
+ var _len7,
651
701
  p,
652
- _key6,
653
- _args13 = arguments;
654
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
655
- while (1) switch (_context13.prev = _context13.next) {
702
+ _key7,
703
+ _args15 = arguments;
704
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
705
+ while (1) switch (_context15.prev = _context15.next) {
656
706
  case 0:
657
- for (_len6 = _args13.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
658
- p[_key6] = _args13[_key6];
707
+ for (_len7 = _args15.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
708
+ p[_key7] = _args15[_key7];
659
709
  }
660
- _context13.next = 3;
661
- return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.onNew.apply(_this$manager7, p);
710
+ _context15.next = 3;
711
+ return (_this$manager8 = this.manager) === null || _this$manager8 === void 0 ? void 0 : _this$manager8.onNew.apply(_this$manager8, p);
662
712
  case 3:
663
- return _context13.abrupt("return", _context13.sent);
713
+ return _context15.abrupt("return", _context15.sent);
664
714
  case 4:
665
715
  case "end":
666
- return _context13.stop();
716
+ return _context15.stop();
667
717
  }
668
- }, _callee13, this);
718
+ }, _callee15, this);
669
719
  }))).apply(this, arguments);
670
720
  } /* -------------------------------------------------------------------------- */
671
721
  }, {
@@ -712,7 +762,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
712
762
  }, {
713
763
  key: "saveList",
714
764
  value: function saveList(_x6) {
715
- return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(itemList) {
765
+ return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(itemList) {
716
766
  var _extraOptions$chunksi;
717
767
  var extraOptions,
718
768
  chunks,
@@ -729,11 +779,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
729
779
  _item,
730
780
  _index2,
731
781
  _item2,
732
- _args14 = arguments;
733
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
734
- while (1) switch (_context14.prev = _context14.next) {
782
+ _args16 = arguments;
783
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
784
+ while (1) switch (_context16.prev = _context16.next) {
735
785
  case 0:
736
- extraOptions = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
786
+ extraOptions = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
737
787
  if (!extraOptions) extraOptions = {};
738
788
  chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
739
789
  delete extraOptions.chunksize;
@@ -741,7 +791,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
741
791
  index = 0;
742
792
  case 6:
743
793
  if (!(index < chunks.length)) {
744
- _context14.next = 36;
794
+ _context16.next = 36;
745
795
  break;
746
796
  }
747
797
  items_to_save = chunks[index];
@@ -749,81 +799,81 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
749
799
  k = 0;
750
800
  case 10:
751
801
  if (!(k < items_to_save.length)) {
752
- _context14.next = 19;
802
+ _context16.next = 19;
753
803
  break;
754
804
  }
755
805
  item = items_to_save[k];
756
- _context14.next = 14;
806
+ _context16.next = 14;
757
807
  return item.get_deltaObject();
758
808
  case 14:
759
- dlt = _context14.sent;
809
+ dlt = _context16.sent;
760
810
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
761
811
  _id: item.getID()
762
812
  }, dlt));
763
813
  case 16:
764
814
  k++;
765
- _context14.next = 10;
815
+ _context16.next = 10;
766
816
  break;
767
817
  case 19:
768
- _context14.next = 21;
818
+ _context16.next = 21;
769
819
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
770
820
  __save_list: WebObject.zipSaveList(save_array)
771
821
  }, extraOptions));
772
822
  case 21:
773
- resultObject = _context14.sent;
823
+ resultObject = _context16.sent;
774
824
  if (!Array.isArray(resultObject)) {
775
- _context14.next = 33;
825
+ _context16.next = 33;
776
826
  break;
777
827
  }
778
828
  _index = 0;
779
829
  case 24:
780
830
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
781
- _context14.next = 33;
831
+ _context16.next = 33;
782
832
  break;
783
833
  }
784
834
  res = resultObject[_index];
785
835
  _item = items_to_save[_index];
786
836
  _item.setSaveResult(res);
787
- _context14.next = 30;
837
+ _context16.next = 30;
788
838
  return _item.onSave();
789
839
  case 30:
790
840
  _index++;
791
- _context14.next = 24;
841
+ _context16.next = 24;
792
842
  break;
793
843
  case 33:
794
844
  index++;
795
- _context14.next = 6;
845
+ _context16.next = 6;
796
846
  break;
797
847
  case 36:
798
848
  _index2 = 0;
799
849
  case 37:
800
850
  if (!(_index2 < itemList.length)) {
801
- _context14.next = 46;
851
+ _context16.next = 46;
802
852
  break;
803
853
  }
804
854
  _item2 = itemList[_index2];
805
855
  if (_item2.isSaved) {
806
- _context14.next = 41;
856
+ _context16.next = 41;
807
857
  break;
808
858
  }
809
- return _context14.abrupt("return", false);
859
+ return _context16.abrupt("return", false);
810
860
  case 41:
811
861
  if (!(_item2.getSaveResultType() != "normal")) {
812
- _context14.next = 43;
862
+ _context16.next = 43;
813
863
  break;
814
864
  }
815
- return _context14.abrupt("return", false);
865
+ return _context16.abrupt("return", false);
816
866
  case 43:
817
867
  _index2++;
818
- _context14.next = 37;
868
+ _context16.next = 37;
819
869
  break;
820
870
  case 46:
821
- return _context14.abrupt("return", true);
871
+ return _context16.abrupt("return", true);
822
872
  case 47:
823
873
  case "end":
824
- return _context14.stop();
874
+ return _context16.stop();
825
875
  }
826
- }, _callee14, this);
876
+ }, _callee16, this);
827
877
  }))).apply(this, arguments);
828
878
  }
829
879
  }, {
@@ -869,64 +919,64 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
869
919
  }, {
870
920
  key: "get_single",
871
921
  value: function get_single() {
872
- return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
873
- var _len7,
922
+ return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
923
+ var _len8,
874
924
  p,
875
- _key7,
925
+ _key8,
876
926
  search,
877
927
  readonly,
878
928
  fetchID,
879
929
  res,
880
930
  params,
881
- _args15 = arguments;
882
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
883
- while (1) switch (_context15.prev = _context15.next) {
931
+ _args17 = arguments;
932
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
933
+ while (1) switch (_context17.prev = _context17.next) {
884
934
  case 0:
885
- for (_len7 = _args15.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
886
- p[_key7] = _args15[_key7];
935
+ for (_len8 = _args17.length, p = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
936
+ p[_key8] = _args17[_key8];
887
937
  }
888
938
  search = p.shift();
889
939
  readonly = p.shift();
890
940
  fetchID = p.shift();
891
941
  if (!(0, _object.object_isEmpty)(search)) {
892
- _context15.next = 6;
942
+ _context17.next = 6;
893
943
  break;
894
944
  }
895
- return _context15.abrupt("return", undefined);
945
+ return _context17.abrupt("return", undefined);
896
946
  case 6:
897
947
  params = {};
898
948
  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;
949
+ _context17.t0 = _typeof(search);
950
+ _context17.next = _context17.t0 === "string" ? 11 : _context17.t0 === "number" ? 11 : _context17.t0 === "object" ? 19 : 19;
901
951
  break;
902
952
  case 11:
903
953
  search = String(search);
904
- _context15.t1 = this;
905
- _context15.t2 = this;
906
- _context15.next = 16;
954
+ _context17.t1 = this;
955
+ _context17.t2 = this;
956
+ _context17.next = 16;
907
957
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
908
958
  fetchID: fetchID
909
959
  });
910
960
  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);
961
+ _context17.t3 = _context17.sent;
962
+ res = _context17.t1.ensure.call(_context17.t1, _context17.t2, _context17.t3);
963
+ return _context17.abrupt("break", 25);
914
964
  case 19:
915
- _context15.t4 = _object.object_first;
916
- _context15.next = 22;
965
+ _context17.t4 = _object.object_first;
966
+ _context17.next = 22;
917
967
  return this.get_list(search, readonly, fetchID);
918
968
  case 22:
919
- _context15.t5 = _context15.sent;
920
- res = (0, _context15.t4)(_context15.t5);
921
- return _context15.abrupt("break", 25);
969
+ _context17.t5 = _context17.sent;
970
+ res = (0, _context17.t4)(_context17.t5);
971
+ return _context17.abrupt("break", 25);
922
972
  case 25:
923
973
  WebObject.setReadonly(res, readonly);
924
- return _context15.abrupt("return", res);
974
+ return _context17.abrupt("return", res);
925
975
  case 27:
926
976
  case "end":
927
- return _context15.stop();
977
+ return _context17.stop();
928
978
  }
929
- }, _callee15, this);
979
+ }, _callee17, this);
930
980
  }))).apply(this, arguments);
931
981
  }
932
982
  /**
@@ -936,42 +986,42 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
936
986
  }, {
937
987
  key: "get_list",
938
988
  value: function get_list() {
939
- return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
940
- var _len8,
989
+ return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
990
+ var _len9,
941
991
  p,
942
- _key8,
992
+ _key9,
943
993
  search,
944
994
  readonly,
945
995
  fetchID,
946
996
  result_items,
947
997
  selftype,
948
998
  res,
949
- _args16 = arguments;
950
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
951
- while (1) switch (_context16.prev = _context16.next) {
999
+ _args18 = arguments;
1000
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1001
+ while (1) switch (_context18.prev = _context18.next) {
952
1002
  case 0:
953
- for (_len8 = _args16.length, p = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
954
- p[_key8] = _args16[_key8];
1003
+ for (_len9 = _args18.length, p = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
1004
+ p[_key9] = _args18[_key9];
955
1005
  }
956
1006
  search = p.shift();
957
1007
  readonly = p.shift();
958
1008
  fetchID = p.shift();
959
1009
  if (!search) search = {};
960
- _context16.next = 7;
1010
+ _context18.next = 7;
961
1011
  return _global.gfunc.run_action("get", this.__web_path, search, {
962
1012
  fetchID: fetchID
963
1013
  });
964
1014
  case 7:
965
- result_items = _context16.sent;
1015
+ result_items = _context18.sent;
966
1016
  selftype = this.prototype;
967
1017
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
968
1018
  WebObject.setReadonly(res, readonly);
969
- return _context16.abrupt("return", res);
1019
+ return _context18.abrupt("return", res);
970
1020
  case 12:
971
1021
  case "end":
972
- return _context16.stop();
1022
+ return _context18.stop();
973
1023
  }
974
- }, _callee16, this);
1024
+ }, _callee18, this);
975
1025
  }))).apply(this, arguments);
976
1026
  }
977
1027
  }]);
@@ -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:
@@ -355,8 +355,8 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
355
355
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
356
356
  while (1) switch (_context10.prev = _context10.next) {
357
357
  case 0:
358
- if (this.obj) {
359
- this.obj.isDeleted = true;
358
+ if (this.obj && this.isSaved) {
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 && this.isSaved) {
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.92",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",