@azrico/webobject 1.4.3 → 1.4.4
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.
|
@@ -51,6 +51,7 @@ export declare class WebObject extends SimpleObject {
|
|
|
51
51
|
* @returns value or undefined
|
|
52
52
|
*/
|
|
53
53
|
static getMetaValue(o: WebObject | null | undefined, key: string): any;
|
|
54
|
+
static saveList(itemList: WebObject[]): Promise<boolean>;
|
|
54
55
|
Save(): Promise<boolean>;
|
|
55
56
|
Delete(): Promise<boolean>;
|
|
56
57
|
canSave(deltaObj?: any): true | string;
|
|
@@ -115,11 +115,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
115
115
|
*/
|
|
116
116
|
}, {
|
|
117
117
|
key: "Save",
|
|
118
|
-
value:
|
|
119
|
-
/* -------------------------------------------------------------------------- */
|
|
120
|
-
/* Save */
|
|
121
|
-
/* -------------------------------------------------------------------------- */
|
|
122
|
-
function () {
|
|
118
|
+
value: function () {
|
|
123
119
|
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
124
120
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
125
121
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -526,6 +522,111 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
526
522
|
var _WebObject$getMeta;
|
|
527
523
|
return (_WebObject$getMeta = WebObject.getMeta(o, key)) === null || _WebObject$getMeta === void 0 ? void 0 : _WebObject$getMeta.value;
|
|
528
524
|
}
|
|
525
|
+
/* -------------------------------------------------------------------------- */
|
|
526
|
+
/* Save */
|
|
527
|
+
/* -------------------------------------------------------------------------- */
|
|
528
|
+
}, {
|
|
529
|
+
key: "saveList",
|
|
530
|
+
value: function () {
|
|
531
|
+
var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(itemList) {
|
|
532
|
+
var chunks, putAddress, index, items_to_save, save_array, k, item, dlt, resultObject, _index, res, _item, _index2, _item2;
|
|
533
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
534
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
535
|
+
case 0:
|
|
536
|
+
chunks = (0, _object.array_chunks)(itemList, 30);
|
|
537
|
+
putAddress = this.get_webname();
|
|
538
|
+
index = 0;
|
|
539
|
+
case 3:
|
|
540
|
+
if (!(index < chunks.length)) {
|
|
541
|
+
_context10.next = 33;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
items_to_save = chunks[index];
|
|
545
|
+
save_array = [];
|
|
546
|
+
k = 0;
|
|
547
|
+
case 7:
|
|
548
|
+
if (!(k < items_to_save.length)) {
|
|
549
|
+
_context10.next = 16;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
item = items_to_save[k];
|
|
553
|
+
_context10.next = 11;
|
|
554
|
+
return item.get_deltaObject();
|
|
555
|
+
case 11:
|
|
556
|
+
dlt = _context10.sent;
|
|
557
|
+
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
558
|
+
_id: item.getID()
|
|
559
|
+
}, dlt));
|
|
560
|
+
case 13:
|
|
561
|
+
k++;
|
|
562
|
+
_context10.next = 7;
|
|
563
|
+
break;
|
|
564
|
+
case 16:
|
|
565
|
+
_context10.next = 18;
|
|
566
|
+
return _global.gfunc.run_action("post", putAddress, {
|
|
567
|
+
__save_list: save_array
|
|
568
|
+
});
|
|
569
|
+
case 18:
|
|
570
|
+
resultObject = _context10.sent;
|
|
571
|
+
if (!Array.isArray(resultObject)) {
|
|
572
|
+
_context10.next = 30;
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
_index = 0;
|
|
576
|
+
case 21:
|
|
577
|
+
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
578
|
+
_context10.next = 30;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
res = resultObject[_index];
|
|
582
|
+
_item = items_to_save[_index];
|
|
583
|
+
_item.setSaveResult(res);
|
|
584
|
+
_context10.next = 27;
|
|
585
|
+
return _item.onSave();
|
|
586
|
+
case 27:
|
|
587
|
+
_index++;
|
|
588
|
+
_context10.next = 21;
|
|
589
|
+
break;
|
|
590
|
+
case 30:
|
|
591
|
+
index++;
|
|
592
|
+
_context10.next = 3;
|
|
593
|
+
break;
|
|
594
|
+
case 33:
|
|
595
|
+
_index2 = 0;
|
|
596
|
+
case 34:
|
|
597
|
+
if (!(_index2 < itemList.length)) {
|
|
598
|
+
_context10.next = 43;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
_item2 = itemList[_index2];
|
|
602
|
+
if (_item2.isSaved) {
|
|
603
|
+
_context10.next = 38;
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
return _context10.abrupt("return", false);
|
|
607
|
+
case 38:
|
|
608
|
+
if (!(_item2.getSaveResultType() != "normal")) {
|
|
609
|
+
_context10.next = 40;
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
return _context10.abrupt("return", false);
|
|
613
|
+
case 40:
|
|
614
|
+
_index2++;
|
|
615
|
+
_context10.next = 34;
|
|
616
|
+
break;
|
|
617
|
+
case 43:
|
|
618
|
+
return _context10.abrupt("return", true);
|
|
619
|
+
case 44:
|
|
620
|
+
case "end":
|
|
621
|
+
return _context10.stop();
|
|
622
|
+
}
|
|
623
|
+
}, _callee10, this);
|
|
624
|
+
}));
|
|
625
|
+
function saveList(_x4) {
|
|
626
|
+
return _saveList.apply(this, arguments);
|
|
627
|
+
}
|
|
628
|
+
return saveList;
|
|
629
|
+
}()
|
|
529
630
|
}, {
|
|
530
631
|
key: "isResultValid",
|
|
531
632
|
value: function isResultValid(result_object) {
|
|
@@ -543,7 +644,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
543
644
|
}, {
|
|
544
645
|
key: "get_single",
|
|
545
646
|
value: function () {
|
|
546
|
-
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
647
|
+
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
547
648
|
var _len5,
|
|
548
649
|
p,
|
|
549
650
|
_key5,
|
|
@@ -552,55 +653,55 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
552
653
|
fetchID,
|
|
553
654
|
res,
|
|
554
655
|
params,
|
|
555
|
-
|
|
556
|
-
return _regeneratorRuntime().wrap(function
|
|
557
|
-
while (1) switch (
|
|
656
|
+
_args11 = arguments;
|
|
657
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
658
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
558
659
|
case 0:
|
|
559
|
-
for (_len5 =
|
|
560
|
-
p[_key5] =
|
|
660
|
+
for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
661
|
+
p[_key5] = _args11[_key5];
|
|
561
662
|
}
|
|
562
663
|
search = p.shift();
|
|
563
664
|
readonly = p.shift();
|
|
564
665
|
fetchID = p.shift();
|
|
565
666
|
if (!(0, _object.object_isEmpty)(search)) {
|
|
566
|
-
|
|
667
|
+
_context11.next = 6;
|
|
567
668
|
break;
|
|
568
669
|
}
|
|
569
|
-
return
|
|
670
|
+
return _context11.abrupt("return", undefined);
|
|
570
671
|
case 6:
|
|
571
672
|
params = {};
|
|
572
673
|
params.context = readonly ? "view" : "edit";
|
|
573
|
-
|
|
574
|
-
|
|
674
|
+
_context11.t0 = _typeof(search);
|
|
675
|
+
_context11.next = _context11.t0 === "string" ? 11 : _context11.t0 === "number" ? 11 : _context11.t0 === "object" ? 19 : 19;
|
|
575
676
|
break;
|
|
576
677
|
case 11:
|
|
577
678
|
search = String(search);
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
679
|
+
_context11.t1 = this;
|
|
680
|
+
_context11.t2 = this;
|
|
681
|
+
_context11.next = 16;
|
|
581
682
|
return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
|
|
582
683
|
fetchID: fetchID
|
|
583
684
|
});
|
|
584
685
|
case 16:
|
|
585
|
-
|
|
586
|
-
res =
|
|
587
|
-
return
|
|
686
|
+
_context11.t3 = _context11.sent;
|
|
687
|
+
res = _context11.t1.ensure.call(_context11.t1, _context11.t2, _context11.t3);
|
|
688
|
+
return _context11.abrupt("break", 25);
|
|
588
689
|
case 19:
|
|
589
|
-
|
|
590
|
-
|
|
690
|
+
_context11.t4 = _object.object_first;
|
|
691
|
+
_context11.next = 22;
|
|
591
692
|
return this.get_list(search, readonly, fetchID);
|
|
592
693
|
case 22:
|
|
593
|
-
|
|
594
|
-
res = (0,
|
|
595
|
-
return
|
|
694
|
+
_context11.t5 = _context11.sent;
|
|
695
|
+
res = (0, _context11.t4)(_context11.t5);
|
|
696
|
+
return _context11.abrupt("break", 25);
|
|
596
697
|
case 25:
|
|
597
698
|
WebObject.setReadonly(res, readonly);
|
|
598
|
-
return
|
|
699
|
+
return _context11.abrupt("return", res);
|
|
599
700
|
case 27:
|
|
600
701
|
case "end":
|
|
601
|
-
return
|
|
702
|
+
return _context11.stop();
|
|
602
703
|
}
|
|
603
|
-
},
|
|
704
|
+
}, _callee11, this);
|
|
604
705
|
}));
|
|
605
706
|
function get_single() {
|
|
606
707
|
return _get_single.apply(this, arguments);
|
|
@@ -614,7 +715,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
614
715
|
}, {
|
|
615
716
|
key: "get_list",
|
|
616
717
|
value: function () {
|
|
617
|
-
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
718
|
+
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
618
719
|
var _len6,
|
|
619
720
|
p,
|
|
620
721
|
_key6,
|
|
@@ -624,32 +725,32 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
624
725
|
result_items,
|
|
625
726
|
selftype,
|
|
626
727
|
res,
|
|
627
|
-
|
|
628
|
-
return _regeneratorRuntime().wrap(function
|
|
629
|
-
while (1) switch (
|
|
728
|
+
_args12 = arguments;
|
|
729
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
730
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
630
731
|
case 0:
|
|
631
|
-
for (_len6 =
|
|
632
|
-
p[_key6] =
|
|
732
|
+
for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
733
|
+
p[_key6] = _args12[_key6];
|
|
633
734
|
}
|
|
634
735
|
search = p.shift();
|
|
635
736
|
readonly = p.shift();
|
|
636
737
|
fetchID = p.shift();
|
|
637
738
|
if (!search) search = {};
|
|
638
|
-
|
|
739
|
+
_context12.next = 7;
|
|
639
740
|
return _global.gfunc.run_action("get", this.__web_path, search, {
|
|
640
741
|
fetchID: fetchID
|
|
641
742
|
});
|
|
642
743
|
case 7:
|
|
643
|
-
result_items =
|
|
744
|
+
result_items = _context12.sent;
|
|
644
745
|
selftype = this.prototype;
|
|
645
746
|
res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
|
|
646
747
|
WebObject.setReadonly(res, readonly);
|
|
647
|
-
return
|
|
748
|
+
return _context12.abrupt("return", res);
|
|
648
749
|
case 12:
|
|
649
750
|
case "end":
|
|
650
|
-
return
|
|
751
|
+
return _context12.stop();
|
|
651
752
|
}
|
|
652
|
-
},
|
|
753
|
+
}, _callee12, this);
|
|
653
754
|
}));
|
|
654
755
|
function get_list() {
|
|
655
756
|
return _get_list.apply(this, arguments);
|