@azrico/webobject 1.4.3 → 1.4.6
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.
|
@@ -14,6 +14,7 @@ export declare class WebObject extends SimpleObject {
|
|
|
14
14
|
static readonly __web_type: string;
|
|
15
15
|
meta_data: MetaObject[];
|
|
16
16
|
_id: string;
|
|
17
|
+
_creator?: string;
|
|
17
18
|
_created_date: string;
|
|
18
19
|
constructor(is_readonly?: boolean);
|
|
19
20
|
/**
|
|
@@ -51,6 +52,7 @@ export declare class WebObject extends SimpleObject {
|
|
|
51
52
|
* @returns value or undefined
|
|
52
53
|
*/
|
|
53
54
|
static getMetaValue(o: WebObject | null | undefined, key: string): any;
|
|
55
|
+
static saveList(itemList: WebObject[]): Promise<boolean>;
|
|
54
56
|
Save(): Promise<boolean>;
|
|
55
57
|
Delete(): Promise<boolean>;
|
|
56
58
|
canSave(deltaObj?: any): true | string;
|
|
@@ -45,6 +45,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
45
45
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _isValidSR);
|
|
46
46
|
_defineProperty(_assertThisInitialized(_this), "meta_data", void 0);
|
|
47
47
|
_defineProperty(_assertThisInitialized(_this), "_id", "");
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "_creator", void 0);
|
|
48
49
|
_defineProperty(_assertThisInitialized(_this), "_created_date", "");
|
|
49
50
|
_defineProperty(_assertThisInitialized(_this), "get_webtype", function () {
|
|
50
51
|
return _this.__web_type || _this.get_webpath();
|
|
@@ -115,11 +116,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
115
116
|
*/
|
|
116
117
|
}, {
|
|
117
118
|
key: "Save",
|
|
118
|
-
value:
|
|
119
|
-
/* -------------------------------------------------------------------------- */
|
|
120
|
-
/* Save */
|
|
121
|
-
/* -------------------------------------------------------------------------- */
|
|
122
|
-
function () {
|
|
119
|
+
value: function () {
|
|
123
120
|
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
124
121
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
125
122
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -526,6 +523,111 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
526
523
|
var _WebObject$getMeta;
|
|
527
524
|
return (_WebObject$getMeta = WebObject.getMeta(o, key)) === null || _WebObject$getMeta === void 0 ? void 0 : _WebObject$getMeta.value;
|
|
528
525
|
}
|
|
526
|
+
/* -------------------------------------------------------------------------- */
|
|
527
|
+
/* Save */
|
|
528
|
+
/* -------------------------------------------------------------------------- */
|
|
529
|
+
}, {
|
|
530
|
+
key: "saveList",
|
|
531
|
+
value: function () {
|
|
532
|
+
var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(itemList) {
|
|
533
|
+
var chunks, putAddress, index, items_to_save, save_array, k, item, dlt, resultObject, _index, res, _item, _index2, _item2;
|
|
534
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
535
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
536
|
+
case 0:
|
|
537
|
+
chunks = (0, _object.array_chunks)(itemList, 30);
|
|
538
|
+
putAddress = this.get_webname();
|
|
539
|
+
index = 0;
|
|
540
|
+
case 3:
|
|
541
|
+
if (!(index < chunks.length)) {
|
|
542
|
+
_context10.next = 33;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
items_to_save = chunks[index];
|
|
546
|
+
save_array = [];
|
|
547
|
+
k = 0;
|
|
548
|
+
case 7:
|
|
549
|
+
if (!(k < items_to_save.length)) {
|
|
550
|
+
_context10.next = 16;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
item = items_to_save[k];
|
|
554
|
+
_context10.next = 11;
|
|
555
|
+
return item.get_deltaObject();
|
|
556
|
+
case 11:
|
|
557
|
+
dlt = _context10.sent;
|
|
558
|
+
save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
|
|
559
|
+
_id: item.getID()
|
|
560
|
+
}, dlt));
|
|
561
|
+
case 13:
|
|
562
|
+
k++;
|
|
563
|
+
_context10.next = 7;
|
|
564
|
+
break;
|
|
565
|
+
case 16:
|
|
566
|
+
_context10.next = 18;
|
|
567
|
+
return _global.gfunc.run_action("post", putAddress, {
|
|
568
|
+
__save_list: save_array
|
|
569
|
+
});
|
|
570
|
+
case 18:
|
|
571
|
+
resultObject = _context10.sent;
|
|
572
|
+
if (!Array.isArray(resultObject)) {
|
|
573
|
+
_context10.next = 30;
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
_index = 0;
|
|
577
|
+
case 21:
|
|
578
|
+
if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
|
|
579
|
+
_context10.next = 30;
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
res = resultObject[_index];
|
|
583
|
+
_item = items_to_save[_index];
|
|
584
|
+
_item.setSaveResult(res);
|
|
585
|
+
_context10.next = 27;
|
|
586
|
+
return _item.onSave();
|
|
587
|
+
case 27:
|
|
588
|
+
_index++;
|
|
589
|
+
_context10.next = 21;
|
|
590
|
+
break;
|
|
591
|
+
case 30:
|
|
592
|
+
index++;
|
|
593
|
+
_context10.next = 3;
|
|
594
|
+
break;
|
|
595
|
+
case 33:
|
|
596
|
+
_index2 = 0;
|
|
597
|
+
case 34:
|
|
598
|
+
if (!(_index2 < itemList.length)) {
|
|
599
|
+
_context10.next = 43;
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
_item2 = itemList[_index2];
|
|
603
|
+
if (_item2.isSaved) {
|
|
604
|
+
_context10.next = 38;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
return _context10.abrupt("return", false);
|
|
608
|
+
case 38:
|
|
609
|
+
if (!(_item2.getSaveResultType() != "normal")) {
|
|
610
|
+
_context10.next = 40;
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
return _context10.abrupt("return", false);
|
|
614
|
+
case 40:
|
|
615
|
+
_index2++;
|
|
616
|
+
_context10.next = 34;
|
|
617
|
+
break;
|
|
618
|
+
case 43:
|
|
619
|
+
return _context10.abrupt("return", true);
|
|
620
|
+
case 44:
|
|
621
|
+
case "end":
|
|
622
|
+
return _context10.stop();
|
|
623
|
+
}
|
|
624
|
+
}, _callee10, this);
|
|
625
|
+
}));
|
|
626
|
+
function saveList(_x4) {
|
|
627
|
+
return _saveList.apply(this, arguments);
|
|
628
|
+
}
|
|
629
|
+
return saveList;
|
|
630
|
+
}()
|
|
529
631
|
}, {
|
|
530
632
|
key: "isResultValid",
|
|
531
633
|
value: function isResultValid(result_object) {
|
|
@@ -543,7 +645,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
543
645
|
}, {
|
|
544
646
|
key: "get_single",
|
|
545
647
|
value: function () {
|
|
546
|
-
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
648
|
+
var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
547
649
|
var _len5,
|
|
548
650
|
p,
|
|
549
651
|
_key5,
|
|
@@ -552,55 +654,55 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
552
654
|
fetchID,
|
|
553
655
|
res,
|
|
554
656
|
params,
|
|
555
|
-
|
|
556
|
-
return _regeneratorRuntime().wrap(function
|
|
557
|
-
while (1) switch (
|
|
657
|
+
_args11 = arguments;
|
|
658
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
659
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
558
660
|
case 0:
|
|
559
|
-
for (_len5 =
|
|
560
|
-
p[_key5] =
|
|
661
|
+
for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
662
|
+
p[_key5] = _args11[_key5];
|
|
561
663
|
}
|
|
562
664
|
search = p.shift();
|
|
563
665
|
readonly = p.shift();
|
|
564
666
|
fetchID = p.shift();
|
|
565
667
|
if (!(0, _object.object_isEmpty)(search)) {
|
|
566
|
-
|
|
668
|
+
_context11.next = 6;
|
|
567
669
|
break;
|
|
568
670
|
}
|
|
569
|
-
return
|
|
671
|
+
return _context11.abrupt("return", undefined);
|
|
570
672
|
case 6:
|
|
571
673
|
params = {};
|
|
572
674
|
params.context = readonly ? "view" : "edit";
|
|
573
|
-
|
|
574
|
-
|
|
675
|
+
_context11.t0 = _typeof(search);
|
|
676
|
+
_context11.next = _context11.t0 === "string" ? 11 : _context11.t0 === "number" ? 11 : _context11.t0 === "object" ? 19 : 19;
|
|
575
677
|
break;
|
|
576
678
|
case 11:
|
|
577
679
|
search = String(search);
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
680
|
+
_context11.t1 = this;
|
|
681
|
+
_context11.t2 = this;
|
|
682
|
+
_context11.next = 16;
|
|
581
683
|
return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
|
|
582
684
|
fetchID: fetchID
|
|
583
685
|
});
|
|
584
686
|
case 16:
|
|
585
|
-
|
|
586
|
-
res =
|
|
587
|
-
return
|
|
687
|
+
_context11.t3 = _context11.sent;
|
|
688
|
+
res = _context11.t1.ensure.call(_context11.t1, _context11.t2, _context11.t3);
|
|
689
|
+
return _context11.abrupt("break", 25);
|
|
588
690
|
case 19:
|
|
589
|
-
|
|
590
|
-
|
|
691
|
+
_context11.t4 = _object.object_first;
|
|
692
|
+
_context11.next = 22;
|
|
591
693
|
return this.get_list(search, readonly, fetchID);
|
|
592
694
|
case 22:
|
|
593
|
-
|
|
594
|
-
res = (0,
|
|
595
|
-
return
|
|
695
|
+
_context11.t5 = _context11.sent;
|
|
696
|
+
res = (0, _context11.t4)(_context11.t5);
|
|
697
|
+
return _context11.abrupt("break", 25);
|
|
596
698
|
case 25:
|
|
597
699
|
WebObject.setReadonly(res, readonly);
|
|
598
|
-
return
|
|
700
|
+
return _context11.abrupt("return", res);
|
|
599
701
|
case 27:
|
|
600
702
|
case "end":
|
|
601
|
-
return
|
|
703
|
+
return _context11.stop();
|
|
602
704
|
}
|
|
603
|
-
},
|
|
705
|
+
}, _callee11, this);
|
|
604
706
|
}));
|
|
605
707
|
function get_single() {
|
|
606
708
|
return _get_single.apply(this, arguments);
|
|
@@ -614,7 +716,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
614
716
|
}, {
|
|
615
717
|
key: "get_list",
|
|
616
718
|
value: function () {
|
|
617
|
-
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
719
|
+
var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
618
720
|
var _len6,
|
|
619
721
|
p,
|
|
620
722
|
_key6,
|
|
@@ -624,32 +726,32 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
624
726
|
result_items,
|
|
625
727
|
selftype,
|
|
626
728
|
res,
|
|
627
|
-
|
|
628
|
-
return _regeneratorRuntime().wrap(function
|
|
629
|
-
while (1) switch (
|
|
729
|
+
_args12 = arguments;
|
|
730
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
731
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
630
732
|
case 0:
|
|
631
|
-
for (_len6 =
|
|
632
|
-
p[_key6] =
|
|
733
|
+
for (_len6 = _args12.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
734
|
+
p[_key6] = _args12[_key6];
|
|
633
735
|
}
|
|
634
736
|
search = p.shift();
|
|
635
737
|
readonly = p.shift();
|
|
636
738
|
fetchID = p.shift();
|
|
637
739
|
if (!search) search = {};
|
|
638
|
-
|
|
740
|
+
_context12.next = 7;
|
|
639
741
|
return _global.gfunc.run_action("get", this.__web_path, search, {
|
|
640
742
|
fetchID: fetchID
|
|
641
743
|
});
|
|
642
744
|
case 7:
|
|
643
|
-
result_items =
|
|
745
|
+
result_items = _context12.sent;
|
|
644
746
|
selftype = this.prototype;
|
|
645
747
|
res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
|
|
646
748
|
WebObject.setReadonly(res, readonly);
|
|
647
|
-
return
|
|
749
|
+
return _context12.abrupt("return", res);
|
|
648
750
|
case 12:
|
|
649
751
|
case "end":
|
|
650
|
-
return
|
|
752
|
+
return _context12.stop();
|
|
651
753
|
}
|
|
652
|
-
},
|
|
754
|
+
}, _callee12, this);
|
|
653
755
|
}));
|
|
654
756
|
function get_list() {
|
|
655
757
|
return _get_list.apply(this, arguments);
|
|
@@ -11,6 +11,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
11
11
|
static readonly __cache_name?: string;
|
|
12
12
|
static readonly __unchangeables?: string[];
|
|
13
13
|
static readonly __changeables?: string[];
|
|
14
|
+
static readonly __protectedProperties?: string[];
|
|
14
15
|
static readonly __extraProperties?: string[];
|
|
15
16
|
static readonly __use_delta: boolean;
|
|
16
17
|
_static(): Function;
|
|
@@ -94,7 +95,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
94
95
|
* @param useExtraProps
|
|
95
96
|
* @returns
|
|
96
97
|
*/
|
|
97
|
-
static canChangeKey(object: SimpleObject, key: string, useExtraProps: boolean):
|
|
98
|
+
static canChangeKey(object: SimpleObject, key: string, useExtraProps: boolean): any;
|
|
98
99
|
/**
|
|
99
100
|
* Apply the changes and empty the delta object
|
|
100
101
|
*/
|
|
@@ -845,10 +845,19 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
845
845
|
var __extraProperties = object.constructor["__extraProperties"];
|
|
846
846
|
if (__extraProperties != null && __extraProperties.includes(key)) return true;
|
|
847
847
|
}
|
|
848
|
+
/* -------------------------------------------------------------------------- */
|
|
848
849
|
var __changeables = object.constructor["__changeables"];
|
|
849
850
|
var __unchangeables = object.constructor["__unchangeables"];
|
|
851
|
+
var __protectedProperties = object.constructor["__protectedProperties"];
|
|
852
|
+
/* -------------------------------------------------------------------------- */
|
|
850
853
|
if (__changeables != null && !__changeables.includes(key)) return false;
|
|
851
854
|
if (__unchangeables != null && __unchangeables.includes(key)) return false;
|
|
855
|
+
//protected keys can only be changed by the creator of this object
|
|
856
|
+
if (__protectedProperties != null && __protectedProperties.includes(key)) {
|
|
857
|
+
if (object.isNew) return true;
|
|
858
|
+
var creatorOfObject = object.get("_creator");
|
|
859
|
+
return _global.gfunc.run_action_sync("is_current_user", creatorOfObject);
|
|
860
|
+
}
|
|
852
861
|
return true;
|
|
853
862
|
}
|
|
854
863
|
}, {
|
|
@@ -1099,6 +1108,8 @@ _defineProperty(SimpleObject, "__cache_name", void 0);
|
|
|
1099
1108
|
_defineProperty(SimpleObject, "__unchangeables", void 0);
|
|
1100
1109
|
//these properties can be directly changed and are included in deltaObject
|
|
1101
1110
|
_defineProperty(SimpleObject, "__changeables", void 0);
|
|
1111
|
+
//these properties can only be changed by the _creator
|
|
1112
|
+
_defineProperty(SimpleObject, "__protectedProperties", void 0);
|
|
1102
1113
|
//these properties usually are not directly changed and sometimes are included in deltaObject
|
|
1103
1114
|
_defineProperty(SimpleObject, "__extraProperties", void 0);
|
|
1104
1115
|
_defineProperty(SimpleObject, "__use_delta", true);
|