@azrico/webobject 1.4.22 → 1.4.24

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.
@@ -75,6 +75,7 @@ export declare class WebObject extends SimpleObject {
75
75
  onDelete(...p: any): Promise<any>;
76
76
  onLoad(...p: any): Promise<any>;
77
77
  onSave(...p: any): Promise<any>;
78
+ onAfterSave(...p: any): Promise<any>;
78
79
  getSaveResult(original?: boolean): any;
79
80
  onNew(...p: any): Promise<any>;
80
81
  /**
@@ -459,8 +459,9 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
459
459
  _context8.next = 13;
460
460
  return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
461
461
  case 13:
462
- return _context8.abrupt("return", _context8.sent);
463
- case 14:
462
+ _context8.next = 15;
463
+ return this.onAfterSave();
464
+ case 15:
464
465
  case "end":
465
466
  return _context8.stop();
466
467
  }
@@ -471,6 +472,36 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
471
472
  }
472
473
  return onSave;
473
474
  }()
475
+ }, {
476
+ key: "onAfterSave",
477
+ value: function () {
478
+ var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
479
+ var _this$manager5;
480
+ var _len4,
481
+ p,
482
+ _key4,
483
+ _args9 = arguments;
484
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
485
+ while (1) switch (_context9.prev = _context9.next) {
486
+ case 0:
487
+ for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
488
+ p[_key4] = _args9[_key4];
489
+ }
490
+ _context9.next = 3;
491
+ return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onAfterSave.apply(_this$manager5, p);
492
+ case 3:
493
+ return _context9.abrupt("return", _context9.sent);
494
+ case 4:
495
+ case "end":
496
+ return _context9.stop();
497
+ }
498
+ }, _callee9, this);
499
+ }));
500
+ function onAfterSave() {
501
+ return _onAfterSave.apply(this, arguments);
502
+ }
503
+ return onAfterSave;
504
+ }()
474
505
  }, {
475
506
  key: "getSaveResult",
476
507
  value: function getSaveResult() {
@@ -489,27 +520,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
489
520
  }, {
490
521
  key: "onNew",
491
522
  value: function () {
492
- var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
493
- var _this$manager5;
494
- var _len4,
523
+ var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
524
+ var _this$manager6;
525
+ var _len5,
495
526
  p,
496
- _key4,
497
- _args9 = arguments;
498
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
499
- while (1) switch (_context9.prev = _context9.next) {
527
+ _key5,
528
+ _args10 = arguments;
529
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
530
+ while (1) switch (_context10.prev = _context10.next) {
500
531
  case 0:
501
- for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
502
- p[_key4] = _args9[_key4];
532
+ for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
533
+ p[_key5] = _args10[_key5];
503
534
  }
504
- _context9.next = 3;
505
- return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onNew.apply(_this$manager5, p);
535
+ _context10.next = 3;
536
+ return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
506
537
  case 3:
507
- return _context9.abrupt("return", _context9.sent);
538
+ return _context10.abrupt("return", _context10.sent);
508
539
  case 4:
509
540
  case "end":
510
- return _context9.stop();
541
+ return _context10.stop();
511
542
  }
512
- }, _callee9, this);
543
+ }, _callee10, this);
513
544
  }));
514
545
  function onNew() {
515
546
  return _onNew.apply(this, arguments);
@@ -550,7 +581,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
550
581
  }, {
551
582
  key: "saveList",
552
583
  value: function () {
553
- var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(itemList) {
584
+ var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(itemList) {
554
585
  var _extraOptions$chunksi;
555
586
  var extraOptions,
556
587
  chunks,
@@ -567,11 +598,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
567
598
  _item,
568
599
  _index2,
569
600
  _item2,
570
- _args10 = arguments;
571
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
572
- while (1) switch (_context10.prev = _context10.next) {
601
+ _args11 = arguments;
602
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
603
+ while (1) switch (_context11.prev = _context11.next) {
573
604
  case 0:
574
- extraOptions = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
605
+ extraOptions = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
575
606
  if (!extraOptions) extraOptions = {};
576
607
  chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
577
608
  delete extraOptions.chunksize;
@@ -579,7 +610,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
579
610
  index = 0;
580
611
  case 6:
581
612
  if (!(index < chunks.length)) {
582
- _context10.next = 36;
613
+ _context11.next = 36;
583
614
  break;
584
615
  }
585
616
  items_to_save = chunks[index];
@@ -587,81 +618,81 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
587
618
  k = 0;
588
619
  case 10:
589
620
  if (!(k < items_to_save.length)) {
590
- _context10.next = 19;
621
+ _context11.next = 19;
591
622
  break;
592
623
  }
593
624
  item = items_to_save[k];
594
- _context10.next = 14;
625
+ _context11.next = 14;
595
626
  return item.get_deltaObject();
596
627
  case 14:
597
- dlt = _context10.sent;
628
+ dlt = _context11.sent;
598
629
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
599
630
  _id: item.getID()
600
631
  }, dlt));
601
632
  case 16:
602
633
  k++;
603
- _context10.next = 10;
634
+ _context11.next = 10;
604
635
  break;
605
636
  case 19:
606
- _context10.next = 21;
637
+ _context11.next = 21;
607
638
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
608
639
  __save_list: save_array
609
640
  }, extraOptions));
610
641
  case 21:
611
- resultObject = _context10.sent;
642
+ resultObject = _context11.sent;
612
643
  if (!Array.isArray(resultObject)) {
613
- _context10.next = 33;
644
+ _context11.next = 33;
614
645
  break;
615
646
  }
616
647
  _index = 0;
617
648
  case 24:
618
649
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
619
- _context10.next = 33;
650
+ _context11.next = 33;
620
651
  break;
621
652
  }
622
653
  res = resultObject[_index];
623
654
  _item = items_to_save[_index];
624
655
  _item.setSaveResult(res);
625
- _context10.next = 30;
656
+ _context11.next = 30;
626
657
  return _item.onSave();
627
658
  case 30:
628
659
  _index++;
629
- _context10.next = 24;
660
+ _context11.next = 24;
630
661
  break;
631
662
  case 33:
632
663
  index++;
633
- _context10.next = 6;
664
+ _context11.next = 6;
634
665
  break;
635
666
  case 36:
636
667
  _index2 = 0;
637
668
  case 37:
638
669
  if (!(_index2 < itemList.length)) {
639
- _context10.next = 46;
670
+ _context11.next = 46;
640
671
  break;
641
672
  }
642
673
  _item2 = itemList[_index2];
643
674
  if (_item2.isSaved) {
644
- _context10.next = 41;
675
+ _context11.next = 41;
645
676
  break;
646
677
  }
647
- return _context10.abrupt("return", false);
678
+ return _context11.abrupt("return", false);
648
679
  case 41:
649
680
  if (!(_item2.getSaveResultType() != "normal")) {
650
- _context10.next = 43;
681
+ _context11.next = 43;
651
682
  break;
652
683
  }
653
- return _context10.abrupt("return", false);
684
+ return _context11.abrupt("return", false);
654
685
  case 43:
655
686
  _index2++;
656
- _context10.next = 37;
687
+ _context11.next = 37;
657
688
  break;
658
689
  case 46:
659
- return _context10.abrupt("return", true);
690
+ return _context11.abrupt("return", true);
660
691
  case 47:
661
692
  case "end":
662
- return _context10.stop();
693
+ return _context11.stop();
663
694
  }
664
- }, _callee10, this);
695
+ }, _callee11, this);
665
696
  }));
666
697
  function saveList(_x4) {
667
698
  return _saveList.apply(this, arguments);
@@ -685,64 +716,64 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
685
716
  }, {
686
717
  key: "get_single",
687
718
  value: function () {
688
- var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
689
- var _len5,
719
+ var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
720
+ var _len6,
690
721
  p,
691
- _key5,
722
+ _key6,
692
723
  search,
693
724
  readonly,
694
725
  fetchID,
695
726
  res,
696
727
  params,
697
- _args11 = arguments;
698
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
699
- while (1) switch (_context11.prev = _context11.next) {
728
+ _args12 = arguments;
729
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
730
+ while (1) switch (_context12.prev = _context12.next) {
700
731
  case 0:
701
- for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
702
- p[_key5] = _args11[_key5];
732
+ for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
733
+ p[_key6] = _args12[_key6];
703
734
  }
704
735
  search = p.shift();
705
736
  readonly = p.shift();
706
737
  fetchID = p.shift();
707
738
  if (!(0, _object.object_isEmpty)(search)) {
708
- _context11.next = 6;
739
+ _context12.next = 6;
709
740
  break;
710
741
  }
711
- return _context11.abrupt("return", undefined);
742
+ return _context12.abrupt("return", undefined);
712
743
  case 6:
713
744
  params = {};
714
745
  params.context = readonly ? "view" : "edit";
715
- _context11.t0 = _typeof(search);
716
- _context11.next = _context11.t0 === "string" ? 11 : _context11.t0 === "number" ? 11 : _context11.t0 === "object" ? 19 : 19;
746
+ _context12.t0 = _typeof(search);
747
+ _context12.next = _context12.t0 === "string" ? 11 : _context12.t0 === "number" ? 11 : _context12.t0 === "object" ? 19 : 19;
717
748
  break;
718
749
  case 11:
719
750
  search = String(search);
720
- _context11.t1 = this;
721
- _context11.t2 = this;
722
- _context11.next = 16;
751
+ _context12.t1 = this;
752
+ _context12.t2 = this;
753
+ _context12.next = 16;
723
754
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
724
755
  fetchID: fetchID
725
756
  });
726
757
  case 16:
727
- _context11.t3 = _context11.sent;
728
- res = _context11.t1.ensure.call(_context11.t1, _context11.t2, _context11.t3);
729
- return _context11.abrupt("break", 25);
758
+ _context12.t3 = _context12.sent;
759
+ res = _context12.t1.ensure.call(_context12.t1, _context12.t2, _context12.t3);
760
+ return _context12.abrupt("break", 25);
730
761
  case 19:
731
- _context11.t4 = _object.object_first;
732
- _context11.next = 22;
762
+ _context12.t4 = _object.object_first;
763
+ _context12.next = 22;
733
764
  return this.get_list(search, readonly, fetchID);
734
765
  case 22:
735
- _context11.t5 = _context11.sent;
736
- res = (0, _context11.t4)(_context11.t5);
737
- return _context11.abrupt("break", 25);
766
+ _context12.t5 = _context12.sent;
767
+ res = (0, _context12.t4)(_context12.t5);
768
+ return _context12.abrupt("break", 25);
738
769
  case 25:
739
770
  WebObject.setReadonly(res, readonly);
740
- return _context11.abrupt("return", res);
771
+ return _context12.abrupt("return", res);
741
772
  case 27:
742
773
  case "end":
743
- return _context11.stop();
774
+ return _context12.stop();
744
775
  }
745
- }, _callee11, this);
776
+ }, _callee12, this);
746
777
  }));
747
778
  function get_single() {
748
779
  return _get_single.apply(this, arguments);
@@ -756,42 +787,42 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
756
787
  }, {
757
788
  key: "get_list",
758
789
  value: function () {
759
- var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
760
- var _len6,
790
+ var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
791
+ var _len7,
761
792
  p,
762
- _key6,
793
+ _key7,
763
794
  search,
764
795
  readonly,
765
796
  fetchID,
766
797
  result_items,
767
798
  selftype,
768
799
  res,
769
- _args12 = arguments;
770
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
771
- while (1) switch (_context12.prev = _context12.next) {
800
+ _args13 = arguments;
801
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
802
+ while (1) switch (_context13.prev = _context13.next) {
772
803
  case 0:
773
- for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
774
- p[_key6] = _args12[_key6];
804
+ for (_len7 = _args13.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
805
+ p[_key7] = _args13[_key7];
775
806
  }
776
807
  search = p.shift();
777
808
  readonly = p.shift();
778
809
  fetchID = p.shift();
779
810
  if (!search) search = {};
780
- _context12.next = 7;
811
+ _context13.next = 7;
781
812
  return _global.gfunc.run_action("get", this.__web_path, search, {
782
813
  fetchID: fetchID
783
814
  });
784
815
  case 7:
785
- result_items = _context12.sent;
816
+ result_items = _context13.sent;
786
817
  selftype = this.prototype;
787
818
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
788
819
  WebObject.setReadonly(res, readonly);
789
- return _context12.abrupt("return", res);
820
+ return _context13.abrupt("return", res);
790
821
  case 12:
791
822
  case "end":
792
- return _context12.stop();
823
+ return _context13.stop();
793
824
  }
794
- }, _callee12, this);
825
+ }, _callee13, this);
795
826
  }));
796
827
  function get_list() {
797
828
  return _get_list.apply(this, arguments);
@@ -50,5 +50,6 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
50
50
  * @returns
51
51
  */
52
52
  onSave(...p: any): Promise<any>;
53
+ onAfterSave(...p: any): Promise<any>;
53
54
  }
54
55
  export default WebObjectManager;
@@ -349,16 +349,10 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
349
349
  return this.event_run("on_change", true);
350
350
  case 4:
351
351
  _context8.next = 6;
352
- return this.event_run("on_after_save");
353
- case 6:
354
- _context8.next = 8;
355
- return this.event_run("on_save_finished");
356
- case 8:
357
- _context8.next = 10;
358
352
  return Promise.resolve(true);
359
- case 10:
353
+ case 6:
360
354
  return _context8.abrupt("return", _context8.sent);
361
- case 11:
355
+ case 7:
362
356
  case "end":
363
357
  return _context8.stop();
364
358
  }
@@ -369,6 +363,34 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
369
363
  }
370
364
  return onSave;
371
365
  }()
366
+ }, {
367
+ key: "onAfterSave",
368
+ value: function () {
369
+ var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
370
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
371
+ while (1) switch (_context9.prev = _context9.next) {
372
+ case 0:
373
+ _context9.next = 2;
374
+ return this.event_run("on_after_save");
375
+ case 2:
376
+ _context9.next = 4;
377
+ return this.event_run("on_save_finished");
378
+ case 4:
379
+ _context9.next = 6;
380
+ return Promise.resolve(true);
381
+ case 6:
382
+ return _context9.abrupt("return", _context9.sent);
383
+ case 7:
384
+ case "end":
385
+ return _context9.stop();
386
+ }
387
+ }, _callee9, this);
388
+ }));
389
+ function onAfterSave() {
390
+ return _onAfterSave.apply(this, arguments);
391
+ }
392
+ return onAfterSave;
393
+ }()
372
394
  }]);
373
395
  return WebObjectManager;
374
396
  }(_ObjectManager2["default"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.22",
3
+ "version": "1.4.24",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",