@azrico/webobject 1.3.6 → 1.3.8

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.
@@ -69,6 +69,7 @@ export declare class WebObject extends SimpleObject {
69
69
  static get_webname(): string | undefined;
70
70
  get manager(): WebObjectManager<any> | null;
71
71
  get_managerClass: () => WebObjectManager<any> | null;
72
+ onDelete(...p: any): Promise<any>;
72
73
  onLoad(...p: any): Promise<any>;
73
74
  onSave(...p: any): Promise<any>;
74
75
  onNew(...p: any): Promise<any>;
@@ -344,9 +344,9 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
344
344
  return this.get_managerClass();
345
345
  }
346
346
  }, {
347
- key: "onLoad",
347
+ key: "onDelete",
348
348
  value: /* -------------------------------------------------------------------------- */function () {
349
- var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
349
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
350
350
  var _this$manager;
351
351
  var _len,
352
352
  p,
@@ -355,19 +355,51 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
355
355
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
356
356
  while (1) switch (_context6.prev = _context6.next) {
357
357
  case 0:
358
+ this.isDeleted = true;
358
359
  for (_len = _args6.length, p = new Array(_len), _key = 0; _key < _len; _key++) {
359
360
  p[_key] = _args6[_key];
360
361
  }
361
- _context6.next = 3;
362
- return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onLoad.apply(_this$manager, p);
363
- case 3:
364
- return _context6.abrupt("return", _context6.sent);
362
+ _context6.next = 4;
363
+ return (_this$manager = this.manager) === null || _this$manager === void 0 ? void 0 : _this$manager.onDelete.apply(_this$manager, p);
365
364
  case 4:
365
+ return _context6.abrupt("return", _context6.sent);
366
+ case 5:
366
367
  case "end":
367
368
  return _context6.stop();
368
369
  }
369
370
  }, _callee6, this);
370
371
  }));
372
+ function onDelete() {
373
+ return _onDelete.apply(this, arguments);
374
+ }
375
+ return onDelete;
376
+ }()
377
+ }, {
378
+ key: "onLoad",
379
+ value: function () {
380
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
381
+ var _this$manager2;
382
+ var _len2,
383
+ p,
384
+ _key2,
385
+ _args7 = arguments;
386
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
387
+ while (1) switch (_context7.prev = _context7.next) {
388
+ case 0:
389
+ this.isDeleted = false;
390
+ for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
391
+ p[_key2] = _args7[_key2];
392
+ }
393
+ _context7.next = 4;
394
+ return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onLoad.apply(_this$manager2, p);
395
+ case 4:
396
+ return _context7.abrupt("return", _context7.sent);
397
+ case 5:
398
+ case "end":
399
+ return _context7.stop();
400
+ }
401
+ }, _callee7, this);
402
+ }));
371
403
  function onLoad() {
372
404
  return _onLoad.apply(this, arguments);
373
405
  }
@@ -376,17 +408,17 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
376
408
  }, {
377
409
  key: "onSave",
378
410
  value: function () {
379
- var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
411
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
380
412
  var _this3 = this,
381
- _this$manager2;
413
+ _this$manager3;
382
414
  var srObject,
383
415
  actual_sr,
384
- _len2,
416
+ _len3,
385
417
  p,
386
- _key2,
387
- _args7 = arguments;
388
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
389
- while (1) switch (_context7.prev = _context7.next) {
418
+ _key3,
419
+ _args8 = arguments;
420
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
421
+ while (1) switch (_context8.prev = _context8.next) {
390
422
  case 0:
391
423
  if (this.isSaved) {
392
424
  this.apply_changes();
@@ -410,18 +442,18 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
410
442
  }
411
443
  }
412
444
  }
413
- for (_len2 = _args7.length, p = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
414
- p[_key2] = _args7[_key2];
445
+ for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
446
+ p[_key3] = _args8[_key3];
415
447
  }
416
- _context7.next = 4;
417
- return (_this$manager2 = this.manager) === null || _this$manager2 === void 0 ? void 0 : _this$manager2.onSave.apply(_this$manager2, p);
448
+ _context8.next = 4;
449
+ return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onSave.apply(_this$manager3, p);
418
450
  case 4:
419
- return _context7.abrupt("return", _context7.sent);
451
+ return _context8.abrupt("return", _context8.sent);
420
452
  case 5:
421
453
  case "end":
422
- return _context7.stop();
454
+ return _context8.stop();
423
455
  }
424
- }, _callee7, this);
456
+ }, _callee8, this);
425
457
  }));
426
458
  function onSave() {
427
459
  return _onSave.apply(this, arguments);
@@ -431,27 +463,27 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
431
463
  }, {
432
464
  key: "onNew",
433
465
  value: function () {
434
- var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
435
- var _this$manager3;
436
- var _len3,
466
+ var _onNew = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
467
+ var _this$manager4;
468
+ var _len4,
437
469
  p,
438
- _key3,
439
- _args8 = arguments;
440
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
441
- while (1) switch (_context8.prev = _context8.next) {
470
+ _key4,
471
+ _args9 = arguments;
472
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
473
+ while (1) switch (_context9.prev = _context9.next) {
442
474
  case 0:
443
- for (_len3 = _args8.length, p = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
444
- p[_key3] = _args8[_key3];
475
+ for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
476
+ p[_key4] = _args9[_key4];
445
477
  }
446
- _context8.next = 3;
447
- return (_this$manager3 = this.manager) === null || _this$manager3 === void 0 ? void 0 : _this$manager3.onNew.apply(_this$manager3, p);
478
+ _context9.next = 3;
479
+ return (_this$manager4 = this.manager) === null || _this$manager4 === void 0 ? void 0 : _this$manager4.onNew.apply(_this$manager4, p);
448
480
  case 3:
449
- return _context8.abrupt("return", _context8.sent);
481
+ return _context9.abrupt("return", _context9.sent);
450
482
  case 4:
451
483
  case "end":
452
- return _context8.stop();
484
+ return _context9.stop();
453
485
  }
454
- }, _callee8, this);
486
+ }, _callee9, this);
455
487
  }));
456
488
  function onNew() {
457
489
  return _onNew.apply(this, arguments);
@@ -503,64 +535,64 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
503
535
  }, {
504
536
  key: "get_single",
505
537
  value: function () {
506
- var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
507
- var _len4,
538
+ var _get_single = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
539
+ var _len5,
508
540
  p,
509
- _key4,
541
+ _key5,
510
542
  search,
511
543
  readonly,
512
544
  fetchID,
513
545
  res,
514
546
  params,
515
- _args9 = arguments;
516
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
517
- while (1) switch (_context9.prev = _context9.next) {
547
+ _args10 = arguments;
548
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
549
+ while (1) switch (_context10.prev = _context10.next) {
518
550
  case 0:
519
- for (_len4 = _args9.length, p = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
520
- p[_key4] = _args9[_key4];
551
+ for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
552
+ p[_key5] = _args10[_key5];
521
553
  }
522
554
  search = p.shift();
523
555
  readonly = p.shift();
524
556
  fetchID = p.shift();
525
557
  if (!(0, _object.object_isEmpty)(search)) {
526
- _context9.next = 6;
558
+ _context10.next = 6;
527
559
  break;
528
560
  }
529
- return _context9.abrupt("return", undefined);
561
+ return _context10.abrupt("return", undefined);
530
562
  case 6:
531
563
  params = {};
532
564
  params.context = readonly ? "view" : "edit";
533
- _context9.t0 = _typeof(search);
534
- _context9.next = _context9.t0 === "string" ? 11 : _context9.t0 === "number" ? 11 : _context9.t0 === "object" ? 19 : 19;
565
+ _context10.t0 = _typeof(search);
566
+ _context10.next = _context10.t0 === "string" ? 11 : _context10.t0 === "number" ? 11 : _context10.t0 === "object" ? 19 : 19;
535
567
  break;
536
568
  case 11:
537
569
  search = String(search);
538
- _context9.t1 = this;
539
- _context9.t2 = this;
540
- _context9.next = 16;
570
+ _context10.t1 = this;
571
+ _context10.t2 = this;
572
+ _context10.next = 16;
541
573
  return _global.gfunc.run_action("get", this.__web_path + "/" + search, params, {
542
574
  fetchID: fetchID
543
575
  });
544
576
  case 16:
545
- _context9.t3 = _context9.sent;
546
- res = _context9.t1.ensure.call(_context9.t1, _context9.t2, _context9.t3);
547
- return _context9.abrupt("break", 25);
577
+ _context10.t3 = _context10.sent;
578
+ res = _context10.t1.ensure.call(_context10.t1, _context10.t2, _context10.t3);
579
+ return _context10.abrupt("break", 25);
548
580
  case 19:
549
- _context9.t4 = _object.object_first;
550
- _context9.next = 22;
581
+ _context10.t4 = _object.object_first;
582
+ _context10.next = 22;
551
583
  return this.get_list(search, readonly, fetchID);
552
584
  case 22:
553
- _context9.t5 = _context9.sent;
554
- res = (0, _context9.t4)(_context9.t5);
555
- return _context9.abrupt("break", 25);
585
+ _context10.t5 = _context10.sent;
586
+ res = (0, _context10.t4)(_context10.t5);
587
+ return _context10.abrupt("break", 25);
556
588
  case 25:
557
589
  WebObject.setReadonly(res, readonly);
558
- return _context9.abrupt("return", res);
590
+ return _context10.abrupt("return", res);
559
591
  case 27:
560
592
  case "end":
561
- return _context9.stop();
593
+ return _context10.stop();
562
594
  }
563
- }, _callee9, this);
595
+ }, _callee10, this);
564
596
  }));
565
597
  function get_single() {
566
598
  return _get_single.apply(this, arguments);
@@ -574,42 +606,42 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
574
606
  }, {
575
607
  key: "get_list",
576
608
  value: function () {
577
- var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
578
- var _len5,
609
+ var _get_list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
610
+ var _len6,
579
611
  p,
580
- _key5,
612
+ _key6,
581
613
  search,
582
614
  readonly,
583
615
  fetchID,
584
616
  result_items,
585
617
  selftype,
586
618
  res,
587
- _args10 = arguments;
588
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
589
- while (1) switch (_context10.prev = _context10.next) {
619
+ _args11 = arguments;
620
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
621
+ while (1) switch (_context11.prev = _context11.next) {
590
622
  case 0:
591
- for (_len5 = _args10.length, p = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
592
- p[_key5] = _args10[_key5];
623
+ for (_len6 = _args11.length, p = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
624
+ p[_key6] = _args11[_key6];
593
625
  }
594
626
  search = p.shift();
595
627
  readonly = p.shift();
596
628
  fetchID = p.shift();
597
629
  if (!search) search = {};
598
- _context10.next = 7;
630
+ _context11.next = 7;
599
631
  return _global.gfunc.run_action("get", this.__web_path, search, {
600
632
  fetchID: fetchID
601
633
  });
602
634
  case 7:
603
- result_items = _context10.sent;
635
+ result_items = _context11.sent;
604
636
  selftype = this.prototype;
605
637
  res = WebObject.map_rowindex(WebObject.mapto(selftype, result_items, readonly));
606
638
  WebObject.setReadonly(res, readonly);
607
- return _context10.abrupt("return", res);
639
+ return _context11.abrupt("return", res);
608
640
  case 12:
609
641
  case "end":
610
- return _context10.stop();
642
+ return _context11.stop();
611
643
  }
612
- }, _callee10, this);
644
+ }, _callee11, this);
613
645
  }));
614
646
  function get_list() {
615
647
  return _get_list.apply(this, arguments);
@@ -32,6 +32,12 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
32
32
  * @returns
33
33
  */
34
34
  onNew(...p: any): Promise<any>;
35
+ /**
36
+ * Use this when you delete Object
37
+ * @param p
38
+ * @returns
39
+ */
40
+ onDelete(...p: any): Promise<any>;
35
41
  /**
36
42
  * Use this when you load data to the object
37
43
  * @param p
@@ -254,39 +254,75 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
254
254
  return onNew;
255
255
  }()
256
256
  /**
257
- * Use this when you load data to the object
257
+ * Use this when you delete Object
258
258
  * @param p
259
259
  * @returns
260
260
  */
261
261
  }, {
262
- key: "onLoad",
262
+ key: "onDelete",
263
263
  value: function () {
264
- var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
265
- var _this$obj9;
264
+ var _onDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
266
265
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
267
266
  while (1) switch (_context6.prev = _context6.next) {
268
267
  case 0:
269
- if (this.canModify) {
270
- (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.setOriginal();
268
+ if (this.obj) {
269
+ this.obj.isDeleted = true;
271
270
  }
272
271
  _context6.next = 3;
273
- return this.event_run("on_load");
272
+ return this.event_run("on_delete");
274
273
  case 3:
275
274
  _context6.next = 5;
276
- return this.event_run("on_change", true);
275
+ return this.event_run("on_after_delete");
277
276
  case 5:
278
277
  _context6.next = 7;
278
+ return Promise.resolve(true);
279
+ case 7:
280
+ return _context6.abrupt("return", _context6.sent);
281
+ case 8:
282
+ case "end":
283
+ return _context6.stop();
284
+ }
285
+ }, _callee6, this);
286
+ }));
287
+ function onDelete() {
288
+ return _onDelete.apply(this, arguments);
289
+ }
290
+ return onDelete;
291
+ }()
292
+ /**
293
+ * Use this when you load data to the object
294
+ * @param p
295
+ * @returns
296
+ */
297
+ }, {
298
+ key: "onLoad",
299
+ value: function () {
300
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
301
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
302
+ while (1) switch (_context7.prev = _context7.next) {
303
+ case 0:
304
+ if (this.canModify && this.obj) {
305
+ this.obj.isDeleted = false;
306
+ this.obj.setOriginal();
307
+ }
308
+ _context7.next = 3;
309
+ return this.event_run("on_load");
310
+ case 3:
311
+ _context7.next = 5;
312
+ return this.event_run("on_change", true);
313
+ case 5:
314
+ _context7.next = 7;
279
315
  return this.event_run("on_after_load");
280
316
  case 7:
281
- _context6.next = 9;
317
+ _context7.next = 9;
282
318
  return Promise.resolve(true);
283
319
  case 9:
284
- return _context6.abrupt("return", _context6.sent);
320
+ return _context7.abrupt("return", _context7.sent);
285
321
  case 10:
286
322
  case "end":
287
- return _context6.stop();
323
+ return _context7.stop();
288
324
  }
289
- }, _callee6, this);
325
+ }, _callee7, this);
290
326
  }));
291
327
  function onLoad() {
292
328
  return _onLoad.apply(this, arguments);
@@ -301,28 +337,28 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
301
337
  }, {
302
338
  key: "onSave",
303
339
  value: function () {
304
- var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
305
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
306
- while (1) switch (_context7.prev = _context7.next) {
340
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
341
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
342
+ while (1) switch (_context8.prev = _context8.next) {
307
343
  case 0:
308
- _context7.next = 2;
344
+ _context8.next = 2;
309
345
  return this.event_run("on_save");
310
346
  case 2:
311
- _context7.next = 4;
347
+ _context8.next = 4;
312
348
  return this.event_run("on_change", true);
313
349
  case 4:
314
- _context7.next = 6;
350
+ _context8.next = 6;
315
351
  return this.event_run("on_after_save");
316
352
  case 6:
317
- _context7.next = 8;
353
+ _context8.next = 8;
318
354
  return Promise.resolve(true);
319
355
  case 8:
320
- return _context7.abrupt("return", _context7.sent);
356
+ return _context8.abrupt("return", _context8.sent);
321
357
  case 9:
322
358
  case "end":
323
- return _context7.stop();
359
+ return _context8.stop();
324
360
  }
325
- }, _callee7, this);
361
+ }, _callee8, this);
326
362
  }));
327
363
  function onSave() {
328
364
  return _onSave.apply(this, arguments);
@@ -21,6 +21,7 @@ export declare class SimpleObject extends MapableObject {
21
21
  __lastChanged: string;
22
22
  __is_readonly: boolean;
23
23
  __throw_errors: boolean;
24
+ __deleted: boolean;
24
25
  __errors?: any[];
25
26
  __showErrors?: boolean;
26
27
  __saveResultObject?: any;
@@ -73,6 +74,7 @@ export declare class SimpleObject extends MapableObject {
73
74
  static setThrowErrors(objs?: SimpleObject[] | SimpleObject, throwErr?: boolean): void;
74
75
  get isChanged(): boolean;
75
76
  get isDeleted(): boolean;
77
+ set isDeleted(v: boolean);
76
78
  get d(): Partial<this>;
77
79
  get allproperties(): this & Partial<this>;
78
80
  get canModify(): boolean;
@@ -68,6 +68,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
68
68
  _defineProperty(_assertThisInitialized(_this), "__lastChanged", "");
69
69
  _defineProperty(_assertThisInitialized(_this), "__is_readonly", void 0);
70
70
  _defineProperty(_assertThisInitialized(_this), "__throw_errors", void 0);
71
+ _defineProperty(_assertThisInitialized(_this), "__deleted", void 0);
71
72
  //errors
72
73
  _defineProperty(_assertThisInitialized(_this), "__errors", void 0);
73
74
  _defineProperty(_assertThisInitialized(_this), "__showErrors", void 0);
@@ -88,6 +89,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
88
89
  _defineProperty(_assertThisInitialized(_this), "get_managerClass", function () {
89
90
  return null;
90
91
  });
92
+ _this.__deleted = false;
91
93
  _this.__delta = {};
92
94
  _this.__temp = {};
93
95
  _this.__is_readonly = is_readonly;
@@ -435,7 +437,10 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
435
437
  }, {
436
438
  key: "isDeleted",
437
439
  get: function get() {
438
- return false;
440
+ return this.__deleted || false;
441
+ },
442
+ set: function set(v) {
443
+ this.__deleted = v;
439
444
  }
440
445
  }, {
441
446
  key: "d",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",