@azrico/webobject 1.4.21 → 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
|
/**
|
|
@@ -419,6 +419,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
419
419
|
var _this$manager4;
|
|
420
420
|
var srObject,
|
|
421
421
|
_this$manager3,
|
|
422
|
+
srID,
|
|
422
423
|
_len3,
|
|
423
424
|
p,
|
|
424
425
|
_key3,
|
|
@@ -427,32 +428,40 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
427
428
|
while (1) switch (_context8.prev = _context8.next) {
|
|
428
429
|
case 0:
|
|
429
430
|
if (!this.isSaved) {
|
|
430
|
-
_context8.next =
|
|
431
|
+
_context8.next = 10;
|
|
431
432
|
break;
|
|
432
433
|
}
|
|
433
434
|
this.apply_changes();
|
|
434
435
|
srObject = this.getSaveResult(true);
|
|
435
436
|
if (!_classPrivateMethodGet(this, _isValidSR, _isValidSR2).call(this, srObject)) {
|
|
436
|
-
_context8.next =
|
|
437
|
+
_context8.next = 10;
|
|
437
438
|
break;
|
|
438
439
|
}
|
|
439
|
-
|
|
440
|
-
|
|
440
|
+
/* -------------------------------------------------------------------------- */
|
|
441
|
+
srID = srObject.insertedId || srObject._id;
|
|
442
|
+
if (srID) {
|
|
443
|
+
this._id = srID;
|
|
441
444
|
}
|
|
445
|
+
/* -------------------------------------------------------------------------- */
|
|
442
446
|
if (srObject._index_value && !Number.isNaN(srObject._index_value)) {
|
|
443
447
|
this._index_value = Number(srObject._index_value);
|
|
444
448
|
}
|
|
445
|
-
|
|
449
|
+
/* -------------------------------------------------------------------------- */
|
|
450
|
+
if (srObject._index_key) {
|
|
451
|
+
this._index_key = srObject._index_key;
|
|
452
|
+
}
|
|
453
|
+
_context8.next = 10;
|
|
446
454
|
return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
|
|
447
|
-
case
|
|
455
|
+
case 10:
|
|
448
456
|
for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
449
457
|
p[_key3] = _args8[_key3];
|
|
450
458
|
}
|
|
451
|
-
_context8.next =
|
|
459
|
+
_context8.next = 13;
|
|
452
460
|
return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
|
|
453
|
-
case
|
|
454
|
-
|
|
455
|
-
|
|
461
|
+
case 13:
|
|
462
|
+
_context8.next = 15;
|
|
463
|
+
return this.onAfterSave();
|
|
464
|
+
case 15:
|
|
456
465
|
case "end":
|
|
457
466
|
return _context8.stop();
|
|
458
467
|
}
|
|
@@ -463,6 +472,36 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
463
472
|
}
|
|
464
473
|
return onSave;
|
|
465
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
|
+
}()
|
|
466
505
|
}, {
|
|
467
506
|
key: "getSaveResult",
|
|
468
507
|
value: function getSaveResult() {
|
|
@@ -481,27 +520,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
481
520
|
}, {
|
|
482
521
|
key: "onNew",
|
|
483
522
|
value: function () {
|
|
484
|
-
var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
485
|
-
var _this$
|
|
486
|
-
var
|
|
523
|
+
var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
524
|
+
var _this$manager6;
|
|
525
|
+
var _len5,
|
|
487
526
|
p,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return _regeneratorRuntime().wrap(function
|
|
491
|
-
while (1) switch (
|
|
527
|
+
_key5,
|
|
528
|
+
_args10 = arguments;
|
|
529
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
530
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
492
531
|
case 0:
|
|
493
|
-
for (
|
|
494
|
-
p[
|
|
532
|
+
for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
533
|
+
p[_key5] = _args10[_key5];
|
|
495
534
|
}
|
|
496
|
-
|
|
497
|
-
return (_this$
|
|
535
|
+
_context10.next = 3;
|
|
536
|
+
return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
|
|
498
537
|
case 3:
|
|
499
|
-
return
|
|
538
|
+
return _context10.abrupt("return", _context10.sent);
|
|
500
539
|
case 4:
|
|
501
540
|
case "end":
|
|
502
|
-
return
|
|
541
|
+
return _context10.stop();
|
|
503
542
|
}
|
|
504
|
-
},
|
|
543
|
+
}, _callee10, this);
|
|
505
544
|
}));
|
|
506
545
|
function onNew() {
|
|
507
546
|
return _onNew.apply(this, arguments);
|
|
@@ -542,7 +581,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
542
581
|
}, {
|
|
543
582
|
key: "saveList",
|
|
544
583
|
value: function () {
|
|
545
|
-
var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
584
|
+
var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(itemList) {
|
|
546
585
|
var _extraOptions$chunksi;
|
|
547
586
|
var extraOptions,
|
|
548
587
|
chunks,
|
|
@@ -559,11 +598,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
559
598
|
_item,
|
|
560
599
|
_index2,
|
|
561
600
|
_item2,
|
|
562
|
-
|
|
563
|
-
return _regeneratorRuntime().wrap(function
|
|
564
|
-
while (1) switch (
|
|
601
|
+
_args11 = arguments;
|
|
602
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
603
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
565
604
|
case 0:
|
|
566
|
-
extraOptions =
|
|
605
|
+
extraOptions = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
567
606
|
if (!extraOptions) extraOptions = {};
|
|
568
607
|
chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
|
|
569
608
|
delete extraOptions.chunksize;
|
|
@@ -571,7 +610,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
571
610
|
index = 0;
|
|
572
611
|
case 6:
|
|
573
612
|
if (!(index < chunks.length)) {
|
|
574
|
-
|
|
613
|
+
_context11.next = 36;
|
|
575
614
|
break;
|
|
576
615
|
}
|
|
577
616
|
items_to_save = chunks[index];
|
|
@@ -579,81 +618,81 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
579
618
|
k = 0;
|
|
580
619
|
case 10:
|
|
581
620
|
if (!(k < items_to_save.length)) {
|
|
582
|
-
|
|
621
|
+
_context11.next = 19;
|
|
583
622
|
break;
|
|
584
623
|
}
|
|
585
624
|
item = items_to_save[k];
|
|
586
|
-
|
|
625
|
+
_context11.next = 14;
|
|
587
626
|
return item.get_deltaObject();
|
|
588
627
|
case 14:
|
|
589
|
-
dlt =
|
|
628
|
+
dlt = _context11.sent;
|
|
590
629
|
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
591
630
|
_id: item.getID()
|
|
592
631
|
}, dlt));
|
|
593
632
|
case 16:
|
|
594
633
|
k++;
|
|
595
|
-
|
|
634
|
+
_context11.next = 10;
|
|
596
635
|
break;
|
|
597
636
|
case 19:
|
|
598
|
-
|
|
637
|
+
_context11.next = 21;
|
|
599
638
|
return _global.gfunc.run_action("post", putAddress, _objectSpread({
|
|
600
639
|
__save_list: save_array
|
|
601
640
|
}, extraOptions));
|
|
602
641
|
case 21:
|
|
603
|
-
resultObject =
|
|
642
|
+
resultObject = _context11.sent;
|
|
604
643
|
if (!Array.isArray(resultObject)) {
|
|
605
|
-
|
|
644
|
+
_context11.next = 33;
|
|
606
645
|
break;
|
|
607
646
|
}
|
|
608
647
|
_index = 0;
|
|
609
648
|
case 24:
|
|
610
649
|
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
611
|
-
|
|
650
|
+
_context11.next = 33;
|
|
612
651
|
break;
|
|
613
652
|
}
|
|
614
653
|
res = resultObject[_index];
|
|
615
654
|
_item = items_to_save[_index];
|
|
616
655
|
_item.setSaveResult(res);
|
|
617
|
-
|
|
656
|
+
_context11.next = 30;
|
|
618
657
|
return _item.onSave();
|
|
619
658
|
case 30:
|
|
620
659
|
_index++;
|
|
621
|
-
|
|
660
|
+
_context11.next = 24;
|
|
622
661
|
break;
|
|
623
662
|
case 33:
|
|
624
663
|
index++;
|
|
625
|
-
|
|
664
|
+
_context11.next = 6;
|
|
626
665
|
break;
|
|
627
666
|
case 36:
|
|
628
667
|
_index2 = 0;
|
|
629
668
|
case 37:
|
|
630
669
|
if (!(_index2 < itemList.length)) {
|
|
631
|
-
|
|
670
|
+
_context11.next = 46;
|
|
632
671
|
break;
|
|
633
672
|
}
|
|
634
673
|
_item2 = itemList[_index2];
|
|
635
674
|
if (_item2.isSaved) {
|
|
636
|
-
|
|
675
|
+
_context11.next = 41;
|
|
637
676
|
break;
|
|
638
677
|
}
|
|
639
|
-
return
|
|
678
|
+
return _context11.abrupt("return", false);
|
|
640
679
|
case 41:
|
|
641
680
|
if (!(_item2.getSaveResultType() != "normal")) {
|
|
642
|
-
|
|
681
|
+
_context11.next = 43;
|
|
643
682
|
break;
|
|
644
683
|
}
|
|
645
|
-
return
|
|
684
|
+
return _context11.abrupt("return", false);
|
|
646
685
|
case 43:
|
|
647
686
|
_index2++;
|
|
648
|
-
|
|
687
|
+
_context11.next = 37;
|
|
649
688
|
break;
|
|
650
689
|
case 46:
|
|
651
|
-
return
|
|
690
|
+
return _context11.abrupt("return", true);
|
|
652
691
|
case 47:
|
|
653
692
|
case "end":
|
|
654
|
-
return
|
|
693
|
+
return _context11.stop();
|
|
655
694
|
}
|
|
656
|
-
},
|
|
695
|
+
}, _callee11, this);
|
|
657
696
|
}));
|
|
658
697
|
function saveList(_x4) {
|
|
659
698
|
return _saveList.apply(this, arguments);
|
|
@@ -677,64 +716,64 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
677
716
|
}, {
|
|
678
717
|
key: "get_single",
|
|
679
718
|
value: function () {
|
|
680
|
-
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
681
|
-
var
|
|
719
|
+
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
720
|
+
var _len6,
|
|
682
721
|
p,
|
|
683
|
-
|
|
722
|
+
_key6,
|
|
684
723
|
search,
|
|
685
724
|
readonly,
|
|
686
725
|
fetchID,
|
|
687
726
|
res,
|
|
688
727
|
params,
|
|
689
|
-
|
|
690
|
-
return _regeneratorRuntime().wrap(function
|
|
691
|
-
while (1) switch (
|
|
728
|
+
_args12 = arguments;
|
|
729
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
730
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
692
731
|
case 0:
|
|
693
|
-
for (
|
|
694
|
-
p[
|
|
732
|
+
for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
733
|
+
p[_key6] = _args12[_key6];
|
|
695
734
|
}
|
|
696
735
|
search = p.shift();
|
|
697
736
|
readonly = p.shift();
|
|
698
737
|
fetchID = p.shift();
|
|
699
738
|
if (!(0, _object.object_isEmpty)(search)) {
|
|
700
|
-
|
|
739
|
+
_context12.next = 6;
|
|
701
740
|
break;
|
|
702
741
|
}
|
|
703
|
-
return
|
|
742
|
+
return _context12.abrupt("return", undefined);
|
|
704
743
|
case 6:
|
|
705
744
|
params = {};
|
|
706
745
|
params.context = readonly ? "view" : "edit";
|
|
707
|
-
|
|
708
|
-
|
|
746
|
+
_context12.t0 = _typeof(search);
|
|
747
|
+
_context12.next = _context12.t0 === "string" ? 11 : _context12.t0 === "number" ? 11 : _context12.t0 === "object" ? 19 : 19;
|
|
709
748
|
break;
|
|
710
749
|
case 11:
|
|
711
750
|
search = String(search);
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
751
|
+
_context12.t1 = this;
|
|
752
|
+
_context12.t2 = this;
|
|
753
|
+
_context12.next = 16;
|
|
715
754
|
return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
|
|
716
755
|
fetchID: fetchID
|
|
717
756
|
});
|
|
718
757
|
case 16:
|
|
719
|
-
|
|
720
|
-
res =
|
|
721
|
-
return
|
|
758
|
+
_context12.t3 = _context12.sent;
|
|
759
|
+
res = _context12.t1.ensure.call(_context12.t1, _context12.t2, _context12.t3);
|
|
760
|
+
return _context12.abrupt("break", 25);
|
|
722
761
|
case 19:
|
|
723
|
-
|
|
724
|
-
|
|
762
|
+
_context12.t4 = _object.object_first;
|
|
763
|
+
_context12.next = 22;
|
|
725
764
|
return this.get_list(search, readonly, fetchID);
|
|
726
765
|
case 22:
|
|
727
|
-
|
|
728
|
-
res = (0,
|
|
729
|
-
return
|
|
766
|
+
_context12.t5 = _context12.sent;
|
|
767
|
+
res = (0, _context12.t4)(_context12.t5);
|
|
768
|
+
return _context12.abrupt("break", 25);
|
|
730
769
|
case 25:
|
|
731
770
|
WebObject.setReadonly(res, readonly);
|
|
732
|
-
return
|
|
771
|
+
return _context12.abrupt("return", res);
|
|
733
772
|
case 27:
|
|
734
773
|
case "end":
|
|
735
|
-
return
|
|
774
|
+
return _context12.stop();
|
|
736
775
|
}
|
|
737
|
-
},
|
|
776
|
+
}, _callee12, this);
|
|
738
777
|
}));
|
|
739
778
|
function get_single() {
|
|
740
779
|
return _get_single.apply(this, arguments);
|
|
@@ -748,42 +787,42 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
748
787
|
}, {
|
|
749
788
|
key: "get_list",
|
|
750
789
|
value: function () {
|
|
751
|
-
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
752
|
-
var
|
|
790
|
+
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
791
|
+
var _len7,
|
|
753
792
|
p,
|
|
754
|
-
|
|
793
|
+
_key7,
|
|
755
794
|
search,
|
|
756
795
|
readonly,
|
|
757
796
|
fetchID,
|
|
758
797
|
result_items,
|
|
759
798
|
selftype,
|
|
760
799
|
res,
|
|
761
|
-
|
|
762
|
-
return _regeneratorRuntime().wrap(function
|
|
763
|
-
while (1) switch (
|
|
800
|
+
_args13 = arguments;
|
|
801
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
802
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
764
803
|
case 0:
|
|
765
|
-
for (
|
|
766
|
-
p[
|
|
804
|
+
for (_len7 = _args13.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
805
|
+
p[_key7] = _args13[_key7];
|
|
767
806
|
}
|
|
768
807
|
search = p.shift();
|
|
769
808
|
readonly = p.shift();
|
|
770
809
|
fetchID = p.shift();
|
|
771
810
|
if (!search) search = {};
|
|
772
|
-
|
|
811
|
+
_context13.next = 7;
|
|
773
812
|
return _global.gfunc.run_action("get", this.__web_path, search, {
|
|
774
813
|
fetchID: fetchID
|
|
775
814
|
});
|
|
776
815
|
case 7:
|
|
777
|
-
result_items =
|
|
816
|
+
result_items = _context13.sent;
|
|
778
817
|
selftype = this.prototype;
|
|
779
818
|
res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
|
|
780
819
|
WebObject.setReadonly(res, readonly);
|
|
781
|
-
return
|
|
820
|
+
return _context13.abrupt("return", res);
|
|
782
821
|
case 12:
|
|
783
822
|
case "end":
|
|
784
|
-
return
|
|
823
|
+
return _context13.stop();
|
|
785
824
|
}
|
|
786
|
-
},
|
|
825
|
+
}, _callee13, this);
|
|
787
826
|
}));
|
|
788
827
|
function get_list() {
|
|
789
828
|
return _get_list.apply(this, arguments);
|
|
@@ -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
|
|
353
|
+
case 6:
|
|
360
354
|
return _context8.abrupt("return", _context8.sent);
|
|
361
|
-
case
|
|
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"]);
|