@azrico/webobject 1.4.18 → 1.4.20

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.
@@ -52,7 +52,9 @@ export declare class WebObject extends SimpleObject {
52
52
  * @returns value or undefined
53
53
  */
54
54
  static getMetaValue(o: WebObject | null | undefined, key: string): any;
55
- static saveList(itemList: WebObject[], extraOptions?: {}): Promise<boolean>;
55
+ static saveList(itemList: WebObject[], extraOptions?: {
56
+ [key: string]: any;
57
+ }): Promise<boolean>;
56
58
  Save(): Promise<boolean>;
57
59
  Delete(): Promise<boolean>;
58
60
  canSave(deltaObj?: any): true | string;
@@ -536,6 +536,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
536
536
  key: "saveList",
537
537
  value: function () {
538
538
  var _saveList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(itemList) {
539
+ var _extraOptions$chunksi;
539
540
  var extraOptions,
540
541
  chunks,
541
542
  putAddress,
@@ -556,90 +557,92 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
556
557
  while (1) switch (_context10.prev = _context10.next) {
557
558
  case 0:
558
559
  extraOptions = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
559
- chunks = (0, _object.array_chunks)(itemList, 30);
560
+ if (!extraOptions) extraOptions = {};
561
+ chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
562
+ delete extraOptions.chunksize;
560
563
  putAddress = this.get_webname();
561
564
  index = 0;
562
- case 4:
565
+ case 6:
563
566
  if (!(index < chunks.length)) {
564
- _context10.next = 34;
567
+ _context10.next = 36;
565
568
  break;
566
569
  }
567
570
  items_to_save = chunks[index];
568
571
  save_array = [];
569
572
  k = 0;
570
- case 8:
573
+ case 10:
571
574
  if (!(k < items_to_save.length)) {
572
- _context10.next = 17;
575
+ _context10.next = 19;
573
576
  break;
574
577
  }
575
578
  item = items_to_save[k];
576
- _context10.next = 12;
579
+ _context10.next = 14;
577
580
  return item.get_deltaObject();
578
- case 12:
581
+ case 14:
579
582
  dlt = _context10.sent;
580
583
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
581
584
  _id: item.getID()
582
585
  }, dlt));
583
- case 14:
586
+ case 16:
584
587
  k++;
585
- _context10.next = 8;
588
+ _context10.next = 10;
586
589
  break;
587
- case 17:
588
- _context10.next = 19;
590
+ case 19:
591
+ _context10.next = 21;
589
592
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
590
593
  __save_list: save_array
591
594
  }, extraOptions));
592
- case 19:
595
+ case 21:
593
596
  resultObject = _context10.sent;
594
597
  if (!Array.isArray(resultObject)) {
595
- _context10.next = 31;
598
+ _context10.next = 33;
596
599
  break;
597
600
  }
598
601
  _index = 0;
599
- case 22:
602
+ case 24:
600
603
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
601
- _context10.next = 31;
604
+ _context10.next = 33;
602
605
  break;
603
606
  }
604
607
  res = resultObject[_index];
605
608
  _item = items_to_save[_index];
606
609
  _item.setSaveResult(res);
607
- _context10.next = 28;
610
+ _context10.next = 30;
608
611
  return _item.onSave();
609
- case 28:
612
+ case 30:
610
613
  _index++;
611
- _context10.next = 22;
614
+ _context10.next = 24;
612
615
  break;
613
- case 31:
616
+ case 33:
614
617
  index++;
615
- _context10.next = 4;
618
+ _context10.next = 6;
616
619
  break;
617
- case 34:
620
+ case 36:
618
621
  _index2 = 0;
619
- case 35:
622
+ case 37:
620
623
  if (!(_index2 < itemList.length)) {
621
- _context10.next = 44;
624
+ _context10.next = 46;
622
625
  break;
623
626
  }
624
627
  _item2 = itemList[_index2];
625
628
  if (_item2.isSaved) {
626
- _context10.next = 39;
629
+ _context10.next = 41;
627
630
  break;
628
631
  }
629
632
  return _context10.abrupt("return", false);
630
- case 39:
633
+ case 41:
631
634
  if (!(_item2.getSaveResultType() != "normal")) {
632
- _context10.next = 41;
635
+ _context10.next = 43;
633
636
  break;
634
637
  }
635
638
  return _context10.abrupt("return", false);
636
- case 41:
639
+ case 43:
637
640
  _index2++;
638
- _context10.next = 35;
641
+ _context10.next = 37;
639
642
  break;
640
- case 44:
643
+ case 46:
641
644
  return _context10.abrupt("return", true);
642
- case 45:
645
+ case 47:
643
646
  case "end":
644
647
  return _context10.stop();
645
648
  }
@@ -10,6 +10,7 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
10
10
  __sendEvents: boolean;
11
11
  __currentObject?: ObjType | null;
12
12
  __options?: object;
13
+ __object_nullable: boolean;
13
14
  notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[] | undefined>;
14
15
  get obj(): ObjType | undefined;
15
16
  /**
@@ -31,6 +31,7 @@ var ObjectManager = /*#__PURE__*/function () {
31
31
  _defineProperty(this, "__sendEvents", true);
32
32
  _defineProperty(this, "__currentObject", void 0);
33
33
  _defineProperty(this, "__options", void 0);
34
+ _defineProperty(this, "__object_nullable", false);
34
35
  _defineProperty(this, "get", this.getValue);
35
36
  }
36
37
  _createClass(ObjectManager, [{
@@ -92,7 +93,7 @@ var ObjectManager = /*#__PURE__*/function () {
92
93
  if (this.__currentObject) {
93
94
  this.__currentObject.set_managerClass(this);
94
95
  }
95
- if (toObj == null) {
96
+ if (toObj == null && !this.__object_nullable) {
96
97
  console.warn("setObject was used to set null. try to use empty objects instead of null");
97
98
  }
98
99
  return true;
@@ -169,7 +170,7 @@ var ObjectManager = /*#__PURE__*/function () {
169
170
  var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
170
171
  var thisobj = this.obj;
171
172
  if (thisobj == null || typeof thisobj.getValue != "function") {
172
- console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
173
+ if (!this.__object_nullable) console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
173
174
  return null;
174
175
  }
175
176
  return thisobj.getValue(key, original);
@@ -194,7 +195,7 @@ var ObjectManager = /*#__PURE__*/function () {
194
195
  _context2.next = 4;
195
196
  break;
196
197
  }
197
- console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
198
+ if (!this.__object_nullable) console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
198
199
  return _context2.abrupt("return", false);
199
200
  case 4:
200
201
  _context2.next = 6;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",