@azrico/webobject 1.4.86 → 1.4.88

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.
@@ -62,7 +62,10 @@ export declare class WebObject extends SimpleObject {
62
62
  }): Promise<boolean>;
63
63
  Save(): Promise<any>;
64
64
  Delete(): Promise<boolean>;
65
+ Archive(): Promise<boolean>;
65
66
  canSave(deltaObj?: any): true | string;
67
+ canDelete(): boolean;
68
+ canArchive(): boolean;
66
69
  deltaIsValid(d: any): true | string;
67
70
  /**
68
71
  * You will post this to the server for saving
@@ -76,6 +79,7 @@ export declare class WebObject extends SimpleObject {
76
79
  get_webname(): string;
77
80
  static get_webname(): string;
78
81
  onDelete(...p: any): Promise<any>;
82
+ onArchive(...p: any): Promise<any>;
79
83
  onLoad(...p: any): Promise<any>;
80
84
  onSave(...p: any): Promise<any>;
81
85
  onAfterSave(...p: any): Promise<any>;
@@ -34,7 +34,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
34
34
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
35
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
36
36
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
37
- var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Delete, _get_deltaObject, _onDelete, _onLoad, _onSave, _onAfterSave, _onNew, _saveList, _get_single, _get_list) {
37
+ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Delete, _Archive, _get_deltaObject, _onDelete, _onArchive, _onLoad, _onSave, _onAfterSave, _onNew, _saveList, _get_single, _get_list) {
38
38
  _inherits(WebObject, _SimpleObject);
39
39
  var _super = _createSuper(WebObject);
40
40
  function WebObject() {
@@ -237,6 +237,29 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
237
237
  }
238
238
  }, _callee3, this);
239
239
  }))).apply(this, arguments);
240
+ }
241
+ }, {
242
+ key: "Archive",
243
+ value: function Archive() {
244
+ return (_Archive = _Archive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
245
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
246
+ while (1) switch (_context4.prev = _context4.next) {
247
+ case 0:
248
+ if (!(this.__throw_errors !== false)) {
249
+ _context4.next = 2;
250
+ break;
251
+ }
252
+ throw new Error("Archive not implented");
253
+ case 2:
254
+ WebObject.addError(this, "Archive not implented", "NOSAVE", true);
255
+ this.setSaveResult(false, "canceled");
256
+ return _context4.abrupt("return", false);
257
+ case 5:
258
+ case "end":
259
+ return _context4.stop();
260
+ }
261
+ }, _callee4, this);
262
+ }))).apply(this, arguments);
240
263
  } /* -------------------------------------------------------------------------- */
241
264
  }, {
242
265
  key: "canSave",
@@ -245,6 +268,16 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
245
268
  if (deltaRes !== true) return deltaRes;
246
269
  return true;
247
270
  }
271
+ }, {
272
+ key: "canDelete",
273
+ value: function canDelete() {
274
+ return true;
275
+ }
276
+ }, {
277
+ key: "canArchive",
278
+ value: function canArchive() {
279
+ return true;
280
+ }
248
281
  }, {
249
282
  key: "deltaIsValid",
250
283
  value: function deltaIsValid(d) {
@@ -258,74 +291,74 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
258
291
  }, {
259
292
  key: "get_deltaObject",
260
293
  value: function get_deltaObject(_x3) {
261
- return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(p) {
294
+ return (_get_deltaObject = _get_deltaObject || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(p) {
262
295
  var _this2 = this,
263
296
  _parseObj;
264
297
  var final_object, isChild, useDelta, allProperties, needId, chkChangables, useExtraProps, dlt, allkeys, changableKeys, functionProps, index, fp, parseObj, _iterator, _step, key, tempusers;
265
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
266
- while (1) switch (_context6.prev = _context6.next) {
298
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
299
+ while (1) switch (_context7.prev = _context7.next) {
267
300
  case 0:
268
301
  parseObj = function _parseObj2(_x4) {
269
- return (_parseObj = _parseObj || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(obj) {
302
+ return (_parseObj = _parseObj || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(obj) {
270
303
  var _ref;
271
304
  var newobj_dlt;
272
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
273
- while (1) switch (_context5.prev = _context5.next) {
305
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
306
+ while (1) switch (_context6.prev = _context6.next) {
274
307
  case 0:
275
308
  if (!(obj == null)) {
276
- _context5.next = 2;
309
+ _context6.next = 2;
277
310
  break;
278
311
  }
279
- return _context5.abrupt("return", undefined);
312
+ return _context6.abrupt("return", undefined);
280
313
  case 2:
281
314
  if (!Array.isArray(obj)) {
282
- _context5.next = 6;
315
+ _context6.next = 6;
283
316
  break;
284
317
  }
285
- _context5.next = 5;
318
+ _context6.next = 5;
286
319
  return Promise.all(obj.map(function (_x5) {
287
- return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(r) {
288
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
289
- while (1) switch (_context4.prev = _context4.next) {
320
+ return (_ref = _ref || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(r) {
321
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
322
+ while (1) switch (_context5.prev = _context5.next) {
290
323
  case 0:
291
- _context4.next = 2;
324
+ _context5.next = 2;
292
325
  return parseObj(r);
293
326
  case 2:
294
- return _context4.abrupt("return", _context4.sent);
327
+ return _context5.abrupt("return", _context5.sent);
295
328
  case 3:
296
329
  case "end":
297
- return _context4.stop();
330
+ return _context5.stop();
298
331
  }
299
- }, _callee4);
332
+ }, _callee5);
300
333
  }))).apply(this, arguments);
301
334
  }));
302
335
  case 5:
303
- return _context5.abrupt("return", _context5.sent);
336
+ return _context6.abrupt("return", _context6.sent);
304
337
  case 6:
305
338
  if (!(obj instanceof WebObject && typeof obj.get_deltaObject === "function")) {
306
- _context5.next = 15;
339
+ _context6.next = 15;
307
340
  break;
308
341
  }
309
- _context5.next = 9;
342
+ _context6.next = 9;
310
343
  return obj.get_deltaObject(_objectSpread(_objectSpread({}, p), {}, {
311
344
  isChild: true
312
345
  }));
313
346
  case 9:
314
- newobj_dlt = _context5.sent;
347
+ newobj_dlt = _context6.sent;
315
348
  if ((0, _object.object_isEmpty)(newobj_dlt)) {
316
- _context5.next = 14;
349
+ _context6.next = 14;
317
350
  break;
318
351
  }
319
- return _context5.abrupt("return", newobj_dlt);
352
+ return _context6.abrupt("return", newobj_dlt);
320
353
  case 14:
321
- return _context5.abrupt("return", obj);
354
+ return _context6.abrupt("return", obj);
322
355
  case 15:
323
- return _context5.abrupt("return", obj);
356
+ return _context6.abrupt("return", obj);
324
357
  case 16:
325
358
  case "end":
326
- return _context5.stop();
359
+ return _context6.stop();
327
360
  }
328
- }, _callee5);
361
+ }, _callee6);
329
362
  }))).apply(this, arguments);
330
363
  };
331
364
  if (!p) p = {};
@@ -344,7 +377,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
344
377
  ignoreProtected: allProperties
345
378
  });
346
379
  }) : allkeys;
347
- _context6.next = 14;
380
+ _context7.next = 14;
348
381
  return _convert["default"].applyFormats({
349
382
  inputobject: dlt,
350
383
  formats: (0, _object.object_getStatic)(this, "__formatList"),
@@ -365,32 +398,32 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
365
398
  /* parse all changableKeys */
366
399
  /* -------------------------------------------------------------------------- */
367
400
  _iterator = _createForOfIteratorHelper(changableKeys);
368
- _context6.prev = 17;
401
+ _context7.prev = 17;
369
402
  _iterator.s();
370
403
  case 19:
371
404
  if ((_step = _iterator.n()).done) {
372
- _context6.next = 26;
405
+ _context7.next = 26;
373
406
  break;
374
407
  }
375
408
  key = _step.value;
376
- _context6.next = 23;
409
+ _context7.next = 23;
377
410
  return parseObj(dlt[key]);
378
411
  case 23:
379
- final_object[key] = _context6.sent;
412
+ final_object[key] = _context7.sent;
380
413
  case 24:
381
- _context6.next = 19;
414
+ _context7.next = 19;
382
415
  break;
383
416
  case 26:
384
- _context6.next = 31;
417
+ _context7.next = 31;
385
418
  break;
386
419
  case 28:
387
- _context6.prev = 28;
388
- _context6.t0 = _context6["catch"](17);
389
- _iterator.e(_context6.t0);
420
+ _context7.prev = 28;
421
+ _context7.t0 = _context7["catch"](17);
422
+ _iterator.e(_context7.t0);
390
423
  case 31:
391
- _context6.prev = 31;
424
+ _context7.prev = 31;
392
425
  _iterator.f();
393
- return _context6.finish(31);
426
+ return _context7.finish(31);
394
427
  case 34:
395
428
  /* -------------------------------------------------------------------------- */
396
429
  /* add id properties */
@@ -413,12 +446,12 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
413
446
  });
414
447
  final_object["_users"] = (0, _object.wrap_array)(tempusers);
415
448
  }
416
- return _context6.abrupt("return", final_object);
449
+ return _context7.abrupt("return", final_object);
417
450
  case 38:
418
451
  case "end":
419
- return _context6.stop();
452
+ return _context7.stop();
420
453
  }
421
- }, _callee6, this, [[17, 28, 31, 34]]);
454
+ }, _callee7, this, [[17, 28, 31, 34]]);
422
455
  }))).apply(this, arguments);
423
456
  } /* --------------------------------- Getters -------------------------------- */
424
457
  }, {
@@ -444,127 +477,154 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
444
477
  }, {
445
478
  key: "onDelete",
446
479
  value: /* -------------------------------------------------------------------------- */function onDelete() {
447
- return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
480
+ return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
448
481
  var _this$manager;
449
482
  var _len,
450
483
  p,
451
484
  _key,
452
- _args7 = arguments;
453
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
454
- while (1) switch (_context7.prev = _context7.next) {
485
+ _args8 = arguments;
486
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
487
+ while (1) switch (_context8.prev = _context8.next) {
455
488
  case 0:
456
489
  this.isDeleted = true;
457
- for (_len = _args7.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
458
- p[_key] = _args7[_key];
490
+ for (_len = _args8.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
491
+ p[_key] = _args8[_key];
459
492
  }
460
- _context7.next = 4;
493
+ _context8.next = 4;
461
494
  return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
462
495
  case 4:
463
- return _context7.abrupt("return", _context7.sent);
496
+ return _context8.abrupt("return", _context8.sent);
464
497
  case 5:
465
498
  case "end":
466
- return _context7.stop();
499
+ return _context8.stop();
467
500
  }
468
- }, _callee7, this);
501
+ }, _callee8, this);
469
502
  }))).apply(this, arguments);
470
503
  }
471
504
  }, {
472
- key: "onLoad",
473
- value: function onLoad() {
474
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
505
+ key: "onArchive",
506
+ value: function onArchive() {
507
+ return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
475
508
  var _this$manager2;
476
509
  var _len2,
477
510
  p,
478
511
  _key2,
479
- _args8 = arguments;
480
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
481
- while (1) switch (_context8.prev = _context8.next) {
512
+ _args9 = arguments;
513
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
514
+ while (1) switch (_context9.prev = _context9.next) {
515
+ case 0:
516
+ this.isArchived = true;
517
+ for (_len2 = _args9.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
518
+ p[_key2] = _args9[_key2];
519
+ }
520
+ _context9.next = 4;
521
+ return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onArchive.apply(_this$manager2, p);
522
+ case 4:
523
+ return _context9.abrupt("return", _context9.sent);
524
+ case 5:
525
+ case "end":
526
+ return _context9.stop();
527
+ }
528
+ }, _callee9, this);
529
+ }))).apply(this, arguments);
530
+ }
531
+ }, {
532
+ key: "onLoad",
533
+ value: function onLoad() {
534
+ return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
535
+ var _this$manager3;
536
+ var _len3,
537
+ p,
538
+ _key3,
539
+ _args10 = arguments;
540
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
541
+ while (1) switch (_context10.prev = _context10.next) {
482
542
  case 0:
483
543
  this.isDeleted = false;
484
- for (_len2 = _args8.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
485
- p[_key2] = _args8[_key2];
544
+ for (_len3 = _args10.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
545
+ p[_key3] = _args10[_key3];
486
546
  }
487
- _context8.next = 4;
488
- return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
547
+ _context10.next = 4;
548
+ return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onLoad.apply(_this$manager3, p);
489
549
  case 4:
490
- return _context8.abrupt("return", _context8.sent);
550
+ return _context10.abrupt("return", _context10.sent);
491
551
  case 5:
492
552
  case "end":
493
- return _context8.stop();
553
+ return _context10.stop();
494
554
  }
495
- }, _callee8, this);
555
+ }, _callee10, this);
496
556
  }))).apply(this, arguments);
497
557
  }
498
558
  }, {
499
559
  key: "onSave",
500
560
  value: function onSave() {
501
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
502
- var _this$manager4;
561
+ return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
562
+ var _this$manager5;
503
563
  var srObject,
504
- _this$manager3,
505
- _len3,
564
+ _this$manager4,
565
+ _len4,
506
566
  p,
507
- _key3,
508
- _args9 = arguments;
509
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
510
- while (1) switch (_context9.prev = _context9.next) {
567
+ _key4,
568
+ _args11 = arguments;
569
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
570
+ while (1) switch (_context11.prev = _context11.next) {
511
571
  case 0:
512
572
  if (!this.isSaved) {
513
- _context9.next = 7;
573
+ _context11.next = 7;
514
574
  break;
515
575
  }
516
576
  this.apply_changes();
517
577
  srObject = this.getSaveResult(true);
518
578
  if (!this.saveResultHasID(srObject)) {
519
- _context9.next = 7;
579
+ _context11.next = 7;
520
580
  break;
521
581
  }
522
582
  /* -------------------------------------------------------------------------- */
523
583
  WebObject.LoadIdsFromSaveResult(this, srObject);
524
- _context9.next = 7;
525
- return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.event_run("on_id_change");
584
+ _context11.next = 7;
585
+ return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.event_run("on_id_change");
526
586
  case 7:
527
- for (_len3 = _args9.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
528
- p[_key3] = _args9[_key3];
587
+ for (_len4 = _args11.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
588
+ p[_key4] = _args11[_key4];
529
589
  }
530
- _context9.next = 10;
531
- return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onSave.apply(_this$manager4, p);
590
+ _context11.next = 10;
591
+ return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onSave.apply(_this$manager5, p);
532
592
  case 10:
533
- _context9.next = 12;
593
+ _context11.next = 12;
534
594
  return this.onAfterSave();
535
595
  case 12:
536
- return _context9.abrupt("return", true);
596
+ return _context11.abrupt("return", true);
537
597
  case 13:
538
598
  case "end":
539
- return _context9.stop();
599
+ return _context11.stop();
540
600
  }
541
- }, _callee9, this);
601
+ }, _callee11, this);
542
602
  }))).apply(this, arguments);
543
603
  }
544
604
  }, {
545
605
  key: "onAfterSave",
546
606
  value: function onAfterSave() {
547
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
548
- var _this$manager5;
549
- var _len4,
607
+ return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
608
+ var _this$manager6;
609
+ var _len5,
550
610
  p,
551
- _key4,
552
- _args10 = arguments;
553
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
554
- while (1) switch (_context10.prev = _context10.next) {
611
+ _key5,
612
+ _args12 = arguments;
613
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
614
+ while (1) switch (_context12.prev = _context12.next) {
555
615
  case 0:
556
- for (_len4 = _args10.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
557
- p[_key4] = _args10[_key4];
616
+ for (_len5 = _args12.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
617
+ p[_key5] = _args12[_key5];
558
618
  }
559
- _context10.next = 3;
560
- return (_this$manager5 = this.manager) === null || _this$manager5 === void 0 ? void 0 : _this$manager5.onAfterSave.apply(_this$manager5, p);
619
+ _context12.next = 3;
620
+ return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onAfterSave.apply(_this$manager6, p);
561
621
  case 3:
562
- return _context10.abrupt("return", true);
622
+ return _context12.abrupt("return", true);
563
623
  case 4:
564
624
  case "end":
565
- return _context10.stop();
625
+ return _context12.stop();
566
626
  }
567
- }, _callee10, this);
627
+ }, _callee12, this);
568
628
  }))).apply(this, arguments);
569
629
  }
570
630
  }, {
@@ -585,27 +645,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
585
645
  }, {
586
646
  key: "onNew",
587
647
  value: function onNew() {
588
- return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
589
- var _this$manager6;
590
- var _len5,
648
+ return (_onNew = _onNew || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
649
+ var _this$manager7;
650
+ var _len6,
591
651
  p,
592
- _key5,
593
- _args11 = arguments;
594
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
595
- while (1) switch (_context11.prev = _context11.next) {
652
+ _key6,
653
+ _args13 = arguments;
654
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
655
+ while (1) switch (_context13.prev = _context13.next) {
596
656
  case 0:
597
- for (_len5 = _args11.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
598
- p[_key5] = _args11[_key5];
657
+ for (_len6 = _args13.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
658
+ p[_key6] = _args13[_key6];
599
659
  }
600
- _context11.next = 3;
601
- return (_this$manager6 = this.manager) === null || _this$manager6 === void 0 ? void 0 : _this$manager6.onNew.apply(_this$manager6, p);
660
+ _context13.next = 3;
661
+ return (_this$manager7 = this.manager) === null || _this$manager7 === void 0 ? void 0 : _this$manager7.onNew.apply(_this$manager7, p);
602
662
  case 3:
603
- return _context11.abrupt("return", _context11.sent);
663
+ return _context13.abrupt("return", _context13.sent);
604
664
  case 4:
605
665
  case "end":
606
- return _context11.stop();
666
+ return _context13.stop();
607
667
  }
608
- }, _callee11, this);
668
+ }, _callee13, this);
609
669
  }))).apply(this, arguments);
610
670
  } /* -------------------------------------------------------------------------- */
611
671
  }, {
@@ -652,7 +712,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
652
712
  }, {
653
713
  key: "saveList",
654
714
  value: function saveList(_x6) {
655
- return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(itemList) {
715
+ return (_saveList = _saveList || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(itemList) {
656
716
  var _extraOptions$chunksi;
657
717
  var extraOptions,
658
718
  chunks,
@@ -669,11 +729,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
669
729
  _item,
670
730
  _index2,
671
731
  _item2,
672
- _args12 = arguments;
673
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
674
- while (1) switch (_context12.prev = _context12.next) {
732
+ _args14 = arguments;
733
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
734
+ while (1) switch (_context14.prev = _context14.next) {
675
735
  case 0:
676
- extraOptions = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
736
+ extraOptions = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
677
737
  if (!extraOptions) extraOptions = {};
678
738
  chunks = (0, _object.array_chunks)(itemList, (_extraOptions$chunksi = extraOptions.chunksize) !== null && _extraOptions$chunksi !== void 0 ? _extraOptions$chunksi : 50);
679
739
  delete extraOptions.chunksize;
@@ -681,7 +741,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
681
741
  index = 0;
682
742
  case 6:
683
743
  if (!(index < chunks.length)) {
684
- _context12.next = 36;
744
+ _context14.next = 36;
685
745
  break;
686
746
  }
687
747
  items_to_save = chunks[index];
@@ -689,81 +749,81 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
689
749
  k = 0;
690
750
  case 10:
691
751
  if (!(k < items_to_save.length)) {
692
- _context12.next = 19;
752
+ _context14.next = 19;
693
753
  break;
694
754
  }
695
755
  item = items_to_save[k];
696
- _context12.next = 14;
756
+ _context14.next = 14;
697
757
  return item.get_deltaObject();
698
758
  case 14:
699
- dlt = _context12.sent;
759
+ dlt = _context14.sent;
700
760
  save_array.push(item.isNew ? _objectSpread({}, dlt) : _objectSpread({
701
761
  _id: item.getID()
702
762
  }, dlt));
703
763
  case 16:
704
764
  k++;
705
- _context12.next = 10;
765
+ _context14.next = 10;
706
766
  break;
707
767
  case 19:
708
- _context12.next = 21;
768
+ _context14.next = 21;
709
769
  return _global.gfunc.run_action("post", putAddress, _objectSpread({
710
770
  __save_list: WebObject.zipSaveList(save_array)
711
771
  }, extraOptions));
712
772
  case 21:
713
- resultObject = _context12.sent;
773
+ resultObject = _context14.sent;
714
774
  if (!Array.isArray(resultObject)) {
715
- _context12.next = 33;
775
+ _context14.next = 33;
716
776
  break;
717
777
  }
718
778
  _index = 0;
719
779
  case 24:
720
780
  if (!(_index < Math.min(resultObject.length, items_to_save.length))) {
721
- _context12.next = 33;
781
+ _context14.next = 33;
722
782
  break;
723
783
  }
724
784
  res = resultObject[_index];
725
785
  _item = items_to_save[_index];
726
786
  _item.setSaveResult(res);
727
- _context12.next = 30;
787
+ _context14.next = 30;
728
788
  return _item.onSave();
729
789
  case 30:
730
790
  _index++;
731
- _context12.next = 24;
791
+ _context14.next = 24;
732
792
  break;
733
793
  case 33:
734
794
  index++;
735
- _context12.next = 6;
795
+ _context14.next = 6;
736
796
  break;
737
797
  case 36:
738
798
  _index2 = 0;
739
799
  case 37:
740
800
  if (!(_index2 < itemList.length)) {
741
- _context12.next = 46;
801
+ _context14.next = 46;
742
802
  break;
743
803
  }
744
804
  _item2 = itemList[_index2];
745
805
  if (_item2.isSaved) {
746
- _context12.next = 41;
806
+ _context14.next = 41;
747
807
  break;
748
808
  }
749
- return _context12.abrupt("return", false);
809
+ return _context14.abrupt("return", false);
750
810
  case 41:
751
811
  if (!(_item2.getSaveResultType() != "normal")) {
752
- _context12.next = 43;
812
+ _context14.next = 43;
753
813
  break;
754
814
  }
755
- return _context12.abrupt("return", false);
815
+ return _context14.abrupt("return", false);
756
816
  case 43:
757
817
  _index2++;
758
- _context12.next = 37;
818
+ _context14.next = 37;
759
819
  break;
760
820
  case 46:
761
- return _context12.abrupt("return", true);
821
+ return _context14.abrupt("return", true);
762
822
  case 47:
763
823
  case "end":
764
- return _context12.stop();
824
+ return _context14.stop();
765
825
  }
766
- }, _callee12, this);
826
+ }, _callee14, this);
767
827
  }))).apply(this, arguments);
768
828
  }
769
829
  }, {
@@ -809,64 +869,64 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
809
869
  }, {
810
870
  key: "get_single",
811
871
  value: function get_single() {
812
- return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
813
- var _len6,
872
+ return (_get_single = _get_single || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
873
+ var _len7,
814
874
  p,
815
- _key6,
875
+ _key7,
816
876
  search,
817
877
  readonly,
818
878
  fetchID,
819
879
  res,
820
880
  params,
821
- _args13 = arguments;
822
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
823
- while (1) switch (_context13.prev = _context13.next) {
881
+ _args15 = arguments;
882
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
883
+ while (1) switch (_context15.prev = _context15.next) {
824
884
  case 0:
825
- for (_len6 = _args13.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
826
- p[_key6] = _args13[_key6];
885
+ for (_len7 = _args15.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
886
+ p[_key7] = _args15[_key7];
827
887
  }
828
888
  search = p.shift();
829
889
  readonly = p.shift();
830
890
  fetchID = p.shift();
831
891
  if (!(0, _object.object_isEmpty)(search)) {
832
- _context13.next = 6;
892
+ _context15.next = 6;
833
893
  break;
834
894
  }
835
- return _context13.abrupt("return", undefined);
895
+ return _context15.abrupt("return", undefined);
836
896
  case 6:
837
897
  params = {};
838
898
  params.context = readonly ? "view" : "edit";
839
- _context13.t0 = _typeof(search);
840
- _context13.next = _context13.t0 === "string" ? 11 : _context13.t0 === "number" ? 11 : _context13.t0 === "object" ? 19 : 19;
899
+ _context15.t0 = _typeof(search);
900
+ _context15.next = _context15.t0 === "string" ? 11 : _context15.t0 === "number" ? 11 : _context15.t0 === "object" ? 19 : 19;
841
901
  break;
842
902
  case 11:
843
903
  search = String(search);
844
- _context13.t1 = this;
845
- _context13.t2 = this;
846
- _context13.next = 16;
904
+ _context15.t1 = this;
905
+ _context15.t2 = this;
906
+ _context15.next = 16;
847
907
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
848
908
  fetchID: fetchID
849
909
  });
850
910
  case 16:
851
- _context13.t3 = _context13.sent;
852
- res = _context13.t1.ensure.call(_context13.t1, _context13.t2, _context13.t3);
853
- return _context13.abrupt("break", 25);
911
+ _context15.t3 = _context15.sent;
912
+ res = _context15.t1.ensure.call(_context15.t1, _context15.t2, _context15.t3);
913
+ return _context15.abrupt("break", 25);
854
914
  case 19:
855
- _context13.t4 = _object.object_first;
856
- _context13.next = 22;
915
+ _context15.t4 = _object.object_first;
916
+ _context15.next = 22;
857
917
  return this.get_list(search, readonly, fetchID);
858
918
  case 22:
859
- _context13.t5 = _context13.sent;
860
- res = (0, _context13.t4)(_context13.t5);
861
- return _context13.abrupt("break", 25);
919
+ _context15.t5 = _context15.sent;
920
+ res = (0, _context15.t4)(_context15.t5);
921
+ return _context15.abrupt("break", 25);
862
922
  case 25:
863
923
  WebObject.setReadonly(res, readonly);
864
- return _context13.abrupt("return", res);
924
+ return _context15.abrupt("return", res);
865
925
  case 27:
866
926
  case "end":
867
- return _context13.stop();
927
+ return _context15.stop();
868
928
  }
869
- }, _callee13, this);
929
+ }, _callee15, this);
870
930
  }))).apply(this, arguments);
871
931
  }
872
932
  /**
@@ -876,42 +936,42 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
876
936
  }, {
877
937
  key: "get_list",
878
938
  value: function get_list() {
879
- return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
880
- var _len7,
939
+ return (_get_list = _get_list || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
940
+ var _len8,
881
941
  p,
882
- _key7,
942
+ _key8,
883
943
  search,
884
944
  readonly,
885
945
  fetchID,
886
946
  result_items,
887
947
  selftype,
888
948
  res,
889
- _args14 = arguments;
890
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
891
- while (1) switch (_context14.prev = _context14.next) {
949
+ _args16 = arguments;
950
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
951
+ while (1) switch (_context16.prev = _context16.next) {
892
952
  case 0:
893
- for (_len7 = _args14.length, p = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
894
- p[_key7] = _args14[_key7];
953
+ for (_len8 = _args16.length, p = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
954
+ p[_key8] = _args16[_key8];
895
955
  }
896
956
  search = p.shift();
897
957
  readonly = p.shift();
898
958
  fetchID = p.shift();
899
959
  if (!search) search = {};
900
- _context14.next = 7;
960
+ _context16.next = 7;
901
961
  return _global.gfunc.run_action("get", this.__web_path, search, {
902
962
  fetchID: fetchID
903
963
  });
904
964
  case 7:
905
- result_items = _context14.sent;
965
+ result_items = _context16.sent;
906
966
  selftype = this.prototype;
907
967
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
908
968
  WebObject.setReadonly(res, readonly);
909
- return _context14.abrupt("return", res);
969
+ return _context16.abrupt("return", res);
910
970
  case 12:
911
971
  case "end":
912
- return _context14.stop();
972
+ return _context16.stop();
913
973
  }
914
- }, _callee14, this);
974
+ }, _callee16, this);
915
975
  }))).apply(this, arguments);
916
976
  }
917
977
  }]);
@@ -39,6 +39,7 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
39
39
  * @returns
40
40
  */
41
41
  onDelete(...p: any): Promise<any>;
42
+ onArchive(...p: any): Promise<any>;
42
43
  /**
43
44
  * Use this when you load data to the object
44
45
  * @param p
@@ -30,7 +30,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
30
30
  /**
31
31
  * This class manages the events of an Simple Object
32
32
  */
33
- var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _get_deltaObject, _Save, _Load, _onNew, _onDelete, _onLoad, _onSave, _onAfterSave) {
33
+ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _get_deltaObject, _Save, _Load, _onNew, _onDelete, _onArchive, _onLoad, _onSave, _onAfterSave) {
34
34
  _inherits(WebObjectManager, _ObjectManager);
35
35
  var _super = _createSuper(WebObjectManager);
36
36
  /* -------------------------------------------------------------------------- */
@@ -282,17 +282,38 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
282
282
  _context7.next = 5;
283
283
  return this.event_run("on_after_delete");
284
284
  case 5:
285
- _context7.next = 7;
286
- return Promise.resolve(true);
287
- case 7:
288
- return _context7.abrupt("return", _context7.sent);
289
- case 8:
285
+ return _context7.abrupt("return", true);
286
+ case 6:
290
287
  case "end":
291
288
  return _context7.stop();
292
289
  }
293
290
  }, _callee7, this);
294
291
  }))).apply(this, arguments);
295
292
  }
293
+ }, {
294
+ key: "onArchive",
295
+ value: function onArchive() {
296
+ return (_onArchive = _onArchive || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
297
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
298
+ while (1) switch (_context8.prev = _context8.next) {
299
+ case 0:
300
+ if (this.obj) {
301
+ this.obj.isDeleted = true;
302
+ }
303
+ _context8.next = 3;
304
+ return this.event_run("on_archive");
305
+ case 3:
306
+ _context8.next = 5;
307
+ return this.event_run("on_after_archive");
308
+ case 5:
309
+ return _context8.abrupt("return", true);
310
+ case 6:
311
+ case "end":
312
+ return _context8.stop();
313
+ }
314
+ }, _callee8, this);
315
+ }))).apply(this, arguments);
316
+ }
296
317
  /**
297
318
  * Use this when you load data to the object
298
319
  * @param p
@@ -301,35 +322,32 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
301
322
  }, {
302
323
  key: "onLoad",
303
324
  value: function onLoad() {
304
- return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
305
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
306
- while (1) switch (_context8.prev = _context8.next) {
325
+ return (_onLoad = _onLoad || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
326
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
327
+ while (1) switch (_context9.prev = _context9.next) {
307
328
  case 0:
308
329
  if (this.canModify && this.obj) {
309
330
  this.obj.isDeleted = false;
310
331
  this.obj.setOriginal();
311
332
  }
312
- _context8.next = 3;
333
+ _context9.next = 3;
313
334
  return this.event_run("on_load");
314
335
  case 3:
315
- _context8.next = 5;
336
+ _context9.next = 5;
316
337
  return this.event_run("on_change", true);
317
338
  case 5:
318
- _context8.next = 7;
339
+ _context9.next = 7;
319
340
  return this.event_run("on_after_load");
320
341
  case 7:
321
- _context8.next = 9;
342
+ _context9.next = 9;
322
343
  return this.event_run("on_load_finished");
323
344
  case 9:
324
- _context8.next = 11;
325
- return Promise.resolve(true);
326
- case 11:
327
- return _context8.abrupt("return", _context8.sent);
328
- case 12:
345
+ return _context9.abrupt("return", true);
346
+ case 10:
329
347
  case "end":
330
- return _context8.stop();
348
+ return _context9.stop();
331
349
  }
332
- }, _callee8, this);
350
+ }, _callee9, this);
333
351
  }))).apply(this, arguments);
334
352
  }
335
353
  /**
@@ -340,49 +358,49 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
340
358
  }, {
341
359
  key: "onSave",
342
360
  value: function onSave() {
343
- return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
344
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
345
- while (1) switch (_context9.prev = _context9.next) {
361
+ return (_onSave = _onSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
362
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
363
+ while (1) switch (_context10.prev = _context10.next) {
346
364
  case 0:
347
- _context9.next = 2;
365
+ _context10.next = 2;
348
366
  return this.event_run("on_save");
349
367
  case 2:
350
- _context9.next = 4;
368
+ _context10.next = 4;
351
369
  return this.event_run("on_change", true);
352
370
  case 4:
353
- _context9.next = 6;
371
+ _context10.next = 6;
354
372
  return Promise.resolve(true);
355
373
  case 6:
356
- return _context9.abrupt("return", _context9.sent);
374
+ return _context10.abrupt("return", _context10.sent);
357
375
  case 7:
358
376
  case "end":
359
- return _context9.stop();
377
+ return _context10.stop();
360
378
  }
361
- }, _callee9, this);
379
+ }, _callee10, this);
362
380
  }))).apply(this, arguments);
363
381
  }
364
382
  }, {
365
383
  key: "onAfterSave",
366
384
  value: function onAfterSave() {
367
- return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
368
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
369
- while (1) switch (_context10.prev = _context10.next) {
385
+ return (_onAfterSave = _onAfterSave || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
386
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
387
+ while (1) switch (_context11.prev = _context11.next) {
370
388
  case 0:
371
- _context10.next = 2;
389
+ _context11.next = 2;
372
390
  return this.event_run("on_after_save");
373
391
  case 2:
374
- _context10.next = 4;
392
+ _context11.next = 4;
375
393
  return this.event_run("on_save_finished");
376
394
  case 4:
377
- _context10.next = 6;
395
+ _context11.next = 6;
378
396
  return Promise.resolve(true);
379
397
  case 6:
380
- return _context10.abrupt("return", _context10.sent);
398
+ return _context11.abrupt("return", _context11.sent);
381
399
  case 7:
382
400
  case "end":
383
- return _context10.stop();
401
+ return _context11.stop();
384
402
  }
385
- }, _callee10, this);
403
+ }, _callee11, this);
386
404
  }))).apply(this, arguments);
387
405
  }
388
406
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.86",
3
+ "version": "1.4.88",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",