@azrico/webobject 1.4.132 → 1.4.135

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.
@@ -41,6 +41,8 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
41
41
  onDelete(...p: any): Promise<any>;
42
42
  onArchive(...p: any): Promise<any>;
43
43
  onUnArchive(...p: any): Promise<any>;
44
+ onLock(...p: any): Promise<any>;
45
+ onUnLock(...p: any): Promise<any>;
44
46
  /**
45
47
  * Use this when you load data to the object
46
48
  * @param p
@@ -474,6 +474,60 @@ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_Object
474
474
  }
475
475
  return onUnArchive;
476
476
  }()
477
+ }, {
478
+ key: "onLock",
479
+ value: function () {
480
+ var _onLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
481
+ var srt;
482
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
483
+ while (1) switch (_context13.prev = _context13.next) {
484
+ case 0:
485
+ srt = this.getSaveResultType();
486
+ _context13.next = 3;
487
+ return this.event_run("on_lock", srt);
488
+ case 3:
489
+ _context13.next = 5;
490
+ return this.event_run("on_after_lock", srt);
491
+ case 5:
492
+ return _context13.abrupt("return", true);
493
+ case 6:
494
+ case "end":
495
+ return _context13.stop();
496
+ }
497
+ }, _callee13, this);
498
+ }));
499
+ function onLock() {
500
+ return _onLock.apply(this, arguments);
501
+ }
502
+ return onLock;
503
+ }()
504
+ }, {
505
+ key: "onUnLock",
506
+ value: function () {
507
+ var _onUnLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
508
+ var srt;
509
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
510
+ while (1) switch (_context14.prev = _context14.next) {
511
+ case 0:
512
+ srt = this.getSaveResultType();
513
+ _context14.next = 3;
514
+ return this.event_run("on_unlock", srt);
515
+ case 3:
516
+ _context14.next = 5;
517
+ return this.event_run("on_after_unlock", srt);
518
+ case 5:
519
+ return _context14.abrupt("return", true);
520
+ case 6:
521
+ case "end":
522
+ return _context14.stop();
523
+ }
524
+ }, _callee14, this);
525
+ }));
526
+ function onUnLock() {
527
+ return _onUnLock.apply(this, arguments);
528
+ }
529
+ return onUnLock;
530
+ }()
477
531
  /**
478
532
  * Use this when you load data to the object
479
533
  * @param p
@@ -482,32 +536,32 @@ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_Object
482
536
  }, {
483
537
  key: "onLoad",
484
538
  value: (function () {
485
- var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
486
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
487
- while (1) switch (_context13.prev = _context13.next) {
539
+ var _onLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
540
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
541
+ while (1) switch (_context15.prev = _context15.next) {
488
542
  case 0:
489
543
  if (this.canModify && this.obj) {
490
544
  this.obj.isDeleted = false;
491
545
  this.obj.setOriginal();
492
546
  }
493
- _context13.next = 3;
547
+ _context15.next = 3;
494
548
  return this.event_run("on_load");
495
549
  case 3:
496
- _context13.next = 5;
550
+ _context15.next = 5;
497
551
  return this.event_run("on_change", true);
498
552
  case 5:
499
- _context13.next = 7;
553
+ _context15.next = 7;
500
554
  return this.event_run("on_after_load");
501
555
  case 7:
502
- _context13.next = 9;
556
+ _context15.next = 9;
503
557
  return this.event_run("on_load_finished");
504
558
  case 9:
505
- return _context13.abrupt("return", true);
559
+ return _context15.abrupt("return", true);
506
560
  case 10:
507
561
  case "end":
508
- return _context13.stop();
562
+ return _context15.stop();
509
563
  }
510
- }, _callee13, this);
564
+ }, _callee15, this);
511
565
  }));
512
566
  function onLoad() {
513
567
  return _onLoad.apply(this, arguments);
@@ -523,27 +577,27 @@ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_Object
523
577
  }, {
524
578
  key: "onSave",
525
579
  value: (function () {
526
- var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
580
+ var _onSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
527
581
  var srt;
528
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
529
- while (1) switch (_context14.prev = _context14.next) {
582
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
583
+ while (1) switch (_context16.prev = _context16.next) {
530
584
  case 0:
531
585
  srt = this.getSaveResultType();
532
- _context14.next = 3;
586
+ _context16.next = 3;
533
587
  return this.event_run("on_save", srt);
534
588
  case 3:
535
- _context14.next = 5;
589
+ _context16.next = 5;
536
590
  return this.event_run("on_change", true);
537
591
  case 5:
538
- _context14.next = 7;
592
+ _context16.next = 7;
539
593
  return Promise.resolve(true);
540
594
  case 7:
541
- return _context14.abrupt("return", _context14.sent);
595
+ return _context16.abrupt("return", _context16.sent);
542
596
  case 8:
543
597
  case "end":
544
- return _context14.stop();
598
+ return _context16.stop();
545
599
  }
546
- }, _callee14, this);
600
+ }, _callee16, this);
547
601
  }));
548
602
  function onSave() {
549
603
  return _onSave.apply(this, arguments);
@@ -553,27 +607,27 @@ var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_Object
553
607
  }, {
554
608
  key: "onAfterSave",
555
609
  value: function () {
556
- var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
610
+ var _onAfterSave = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
557
611
  var srt;
558
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
559
- while (1) switch (_context15.prev = _context15.next) {
612
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
613
+ while (1) switch (_context17.prev = _context17.next) {
560
614
  case 0:
561
615
  srt = this.getSaveResultType();
562
- _context15.next = 3;
616
+ _context17.next = 3;
563
617
  return this.event_run("on_after_save", srt);
564
618
  case 3:
565
- _context15.next = 5;
619
+ _context17.next = 5;
566
620
  return this.event_run("on_save_finished", srt);
567
621
  case 5:
568
- _context15.next = 7;
622
+ _context17.next = 7;
569
623
  return Promise.resolve(true);
570
624
  case 7:
571
- return _context15.abrupt("return", _context15.sent);
625
+ return _context17.abrupt("return", _context17.sent);
572
626
  case 8:
573
627
  case "end":
574
- return _context15.stop();
628
+ return _context17.stop();
575
629
  }
576
- }, _callee15, this);
630
+ }, _callee17, this);
577
631
  }));
578
632
  function onAfterSave() {
579
633
  return _onAfterSave.apply(this, arguments);
@@ -29,6 +29,7 @@ export declare class SimpleObject extends MapableObject {
29
29
  _deleted?: boolean;
30
30
  _archived?: boolean;
31
31
  _deletedBy?: string;
32
+ _locked?: boolean;
32
33
  protected __errors?: any[];
33
34
  protected __showErrors?: boolean;
34
35
  protected __refresh_functions?: {
@@ -170,6 +171,8 @@ export declare class SimpleObject extends MapableObject {
170
171
  get isArchived(): boolean;
171
172
  set isArchived(v: boolean);
172
173
  get isDeleted(): boolean;
174
+ get isLocked(): boolean;
175
+ set isLocked(v: boolean);
173
176
  set isDeleted(v: boolean);
174
177
  get d(): Partial<this>;
175
178
  get allproperties(): Partial<this>;
@@ -75,6 +75,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
75
75
  _defineProperty(_assertThisInitialized(_this), "_deleted", void 0);
76
76
  _defineProperty(_assertThisInitialized(_this), "_archived", void 0);
77
77
  _defineProperty(_assertThisInitialized(_this), "_deletedBy", void 0);
78
+ //is this object locked?
79
+ _defineProperty(_assertThisInitialized(_this), "_locked", void 0);
78
80
  //errors
79
81
  _defineProperty(_assertThisInitialized(_this), "__errors", void 0);
80
82
  _defineProperty(_assertThisInitialized(_this), "__showErrors", void 0);
@@ -154,7 +156,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
154
156
  _context.next = 6;
155
157
  break;
156
158
  }
157
- throw Error("Cant use setValue when on readonly mode");
159
+ throw Error("Cant use setValue (".concat(String(key), ") when on readonly mode"));
158
160
  case 6:
159
161
  return _context.abrupt("return", false);
160
162
  case 7:
@@ -440,7 +442,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
440
442
  _context8.next = 6;
441
443
  break;
442
444
  }
443
- throw Error("Cant use setValue when on readonly mode");
445
+ throw Error("Cant use setSubValue (".concat(String(key), ") when on readonly mode"));
444
446
  case 6:
445
447
  return _context8.abrupt("return", false);
446
448
  case 7:
@@ -544,7 +546,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
544
546
  _context10.next = 8;
545
547
  break;
546
548
  }
547
- throw Error("Cant use pushValues when on readonly mode");
549
+ throw Error("Cant use pushValues (".concat(String(key), ") when on readonly mode"));
548
550
  case 8:
549
551
  return _context10.abrupt("return", false);
550
552
  case 9:
@@ -558,7 +560,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
558
560
  _context10.next = 16;
559
561
  break;
560
562
  }
561
- throw Error("Cant use pushValues on non Array keys");
563
+ throw Error("Cant use pushValues (".concat(String(key), ") on non Array keys"));
562
564
  case 16:
563
565
  return _context10.abrupt("return", false);
564
566
  case 17:
@@ -836,6 +838,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
836
838
  set: function set(v) {
837
839
  this._deleted = v;
838
840
  }
841
+ }, {
842
+ key: "isLocked",
843
+ get: function get() {
844
+ return this.get("_locked") || false;
845
+ },
846
+ set: function set(v) {
847
+ this._locked = v;
848
+ }
839
849
  }, {
840
850
  key: "d",
841
851
  get: function get() {
@@ -943,7 +953,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
943
953
  _context14.next = 3;
944
954
  break;
945
955
  }
946
- if (this.__showErrors === true) console.error("you cant use events if your object has no manager");
956
+ if (this.__showErrors === true) console.error("you cant use events (".concat(eventName, ") if your object has no manager"));
947
957
  return _context14.abrupt("return");
948
958
  case 3:
949
959
  for (_len2 = _args14.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
@@ -970,7 +980,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
970
980
  var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
971
981
  var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
972
982
  if (!this.manager) {
973
- if (this.__showErrors === true) console.error("you cant use events if your object has no manager");
983
+ if (this.__showErrors === true) console.error("you cant use events (".concat(name, ") if your object has no manager"));
974
984
  return;
975
985
  }
976
986
  return this.manager.event_use(name, runEvent, onlyOn, runOnce);
@@ -979,7 +989,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
979
989
  key: "event_remove",
980
990
  value: function event_remove(name, uname) {
981
991
  if (!this.manager) {
982
- if (this.__showErrors === true) console.error("you cant use events if your object has no manager");
992
+ if (this.__showErrors === true) console.error("you cant use events (".concat(name, ") if your object has no manager"));
983
993
  return;
984
994
  }
985
995
  return this.manager.event_remove(name, uname);
@@ -1000,7 +1010,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
1000
1010
  _context15.next = 5;
1001
1011
  break;
1002
1012
  }
1003
- if (this.__showErrors === true) console.error("you cant use events if your object has no manager");
1013
+ if (this.__showErrors === true) console.error("you cant use events (".concat(name, ") if your object has no manager"));
1004
1014
  return _context15.abrupt("return");
1005
1015
  case 5:
1006
1016
  _context15.next = 7;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.132",
3
+ "version": "1.4.135",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "eslint-plugin-standard": "^4.0.1",
47
47
  "gh-pages": "^2.2.0",
48
48
  "husky": "^8.0.1",
49
- "jest": "^27.0.5",
49
+ "jest": "^27.0.5",
50
50
  "prettier": "^2.0.4",
51
51
  "prop-types": "^15.7.2",
52
52
  "react": "^16.13.1",