@azrico/webobject 1.2.21 → 1.2.23

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.
@@ -32,7 +32,7 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
32
32
  get __cache_name(): string;
33
33
  getSaveResult(): any;
34
34
  getSaveResultType(): saveResultType | null;
35
- setSaveResult(toObj: any, type: saveResultType): any;
35
+ setSaveResult(toObj: any, type: saveResultType): void | undefined;
36
36
  apply_changes(): false | undefined;
37
37
  getValue(key: PropOf<ObjType>, original?: boolean): NonNullable<ObjType>[any] | undefined;
38
38
  get: (key: PropOf<ObjType>, original?: boolean) => NonNullable<ObjType>[any] | undefined;
@@ -200,7 +200,9 @@ var ObjectManager = /*#__PURE__*/function () {
200
200
  }, {
201
201
  key: "setSaveResult",
202
202
  value: function setSaveResult(toObj, type) {
203
- return this.setSaveResult(toObj, type);
203
+ var _this$getObject3;
204
+
205
+ return (_this$getObject3 = this.getObject()) === null || _this$getObject3 === void 0 ? void 0 : _this$getObject3.setSaveResult(toObj, type);
204
206
  }
205
207
  }, {
206
208
  key: "apply_changes",
@@ -16,6 +16,7 @@ export declare class SimpleObject extends MapableObject {
16
16
  _static(): Function;
17
17
  __originalobject?: this;
18
18
  __delta: Partial<this>;
19
+ __temp: any;
19
20
  __changed: boolean;
20
21
  __lastChanged: string;
21
22
  __is_readonly: boolean;
@@ -24,7 +25,7 @@ export declare class SimpleObject extends MapableObject {
24
25
  __showErrors?: boolean;
25
26
  __saveResultObject?: any;
26
27
  __saveResultIsSuccess?: boolean;
27
- __saveResultType: saveResultType | null;
28
+ __saveResultType?: saveResultType;
28
29
  _index_key: string;
29
30
  _index_value: number;
30
31
  constructor(is_readonly?: boolean);
@@ -33,6 +34,7 @@ export declare class SimpleObject extends MapableObject {
33
34
  static getValue<T extends SimpleObject, MKey extends PropOf<T>>(o: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
34
35
  getValue: <MKey extends keyof this>(key: MKey, original?: boolean) => PropType<this, MKey>;
35
36
  get: <MKey extends keyof this>(key: MKey, original?: boolean) => PropType<this, MKey>;
37
+ getTemp: (key: string) => any;
36
38
  /**
37
39
  * set value
38
40
  * @param key
@@ -41,6 +43,7 @@ export declare class SimpleObject extends MapableObject {
41
43
  */
42
44
  setValue(key: WriteablePropOf<this>, value: any, sendChanges?: sendChangesType): Promise<boolean>;
43
45
  set: (key: WriteablePropOf<this>, value: any, sendChanges?: sendChangesType) => Promise<boolean>;
46
+ setTemp: (key: string, value: any) => any;
44
47
  setDefaultValue(key: WriteablePropOf<this>, value: any): boolean;
45
48
  setDefault: (key: WriteablePropOf<this>, value: any) => boolean;
46
49
  /**
@@ -59,6 +62,7 @@ export declare class SimpleObject extends MapableObject {
59
62
  */
60
63
  apply_changes(): false | undefined;
61
64
  clear_changes(): void;
65
+ clear_cache(): void;
62
66
  /**
63
67
  * Sets readonly property on given objects
64
68
  * @param objs array of given objects or a single object
@@ -95,10 +99,20 @@ export declare class SimpleObject extends MapableObject {
95
99
  static addError(o?: SimpleObject, title?: string, message?: string, sendToRegister?: boolean | "auto"): any[] | undefined;
96
100
  static getErrors(o: SimpleObject): any[];
97
101
  static clearErrors(o: SimpleObject): boolean;
102
+ /**
103
+ * Checks if the given object is a valid and truthy save result
104
+ * @param result_object
105
+ * @returns
106
+ */
98
107
  static isResultValid(result_object: any): any;
99
- setSaveResult(toObj: any, type: saveResultType): void;
108
+ /**
109
+ * set the response of last save from site
110
+ * and its type
111
+ * @param toObj
112
+ */
113
+ setSaveResult(toObj: any, type: saveResultType | "auto"): void;
100
114
  getSaveResult(): any;
101
- getSaveResultType(): saveResultType | null;
115
+ getSaveResultType(): saveResultType;
102
116
  static factoryClear(obj: SimpleObject): void;
103
117
  static delete_cache(): void;
104
118
  static get_canModify(o: SimpleObject): boolean;
@@ -67,6 +67,10 @@ var _setDefaultProperty = /*#__PURE__*/new WeakSet();
67
67
 
68
68
  var _getProperty = /*#__PURE__*/new WeakSet();
69
69
 
70
+ var _getTempProperty = /*#__PURE__*/new WeakSet();
71
+
72
+ var _setTempProperty = /*#__PURE__*/new WeakSet();
73
+
70
74
  var _setSaveResultObject = /*#__PURE__*/new WeakSet();
71
75
 
72
76
  var SimpleObject = /*#__PURE__*/function (_MapableObject) {
@@ -85,6 +89,10 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
85
89
 
86
90
  _classPrivateMethodInitSpec(_assertThisInitialized(_this), _setSaveResultObject);
87
91
 
92
+ _classPrivateMethodInitSpec(_assertThisInitialized(_this), _setTempProperty);
93
+
94
+ _classPrivateMethodInitSpec(_assertThisInitialized(_this), _getTempProperty);
95
+
88
96
  _classPrivateMethodInitSpec(_assertThisInitialized(_this), _getProperty);
89
97
 
90
98
  _classPrivateMethodInitSpec(_assertThisInitialized(_this), _setDefaultProperty);
@@ -99,6 +107,8 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
99
107
 
100
108
  _defineProperty(_assertThisInitialized(_this), "__delta", void 0);
101
109
 
110
+ _defineProperty(_assertThisInitialized(_this), "__temp", void 0);
111
+
102
112
  _defineProperty(_assertThisInitialized(_this), "__changed", false);
103
113
 
104
114
  _defineProperty(_assertThisInitialized(_this), "__lastChanged", "");
@@ -115,7 +125,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
115
125
 
116
126
  _defineProperty(_assertThisInitialized(_this), "__saveResultIsSuccess", void 0);
117
127
 
118
- _defineProperty(_assertThisInitialized(_this), "__saveResultType", null);
128
+ _defineProperty(_assertThisInitialized(_this), "__saveResultType", void 0);
119
129
 
120
130
  _defineProperty(_assertThisInitialized(_this), "_index_key", "");
121
131
 
@@ -125,8 +135,12 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
125
135
 
126
136
  _defineProperty(_assertThisInitialized(_this), "get", _classPrivateMethodGet(_assertThisInitialized(_this), _getProperty, _getProperty2));
127
137
 
138
+ _defineProperty(_assertThisInitialized(_this), "getTemp", _classPrivateMethodGet(_assertThisInitialized(_this), _getTempProperty, _getTempProperty2));
139
+
128
140
  _defineProperty(_assertThisInitialized(_this), "set", _this.setValue);
129
141
 
142
+ _defineProperty(_assertThisInitialized(_this), "setTemp", _classPrivateMethodGet(_assertThisInitialized(_this), _setTempProperty, _setTempProperty2));
143
+
130
144
  _defineProperty(_assertThisInitialized(_this), "setDefault", _this.setDefaultValue);
131
145
 
132
146
  _defineProperty(_assertThisInitialized(_this), "get_managerClass", function () {
@@ -134,6 +148,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
134
148
  });
135
149
 
136
150
  _this.__delta = {};
151
+ _this.__temp = {};
137
152
  _this.__is_readonly = is_readonly;
138
153
  _this.__throw_errors = true;
139
154
 
@@ -498,6 +513,11 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
498
513
  this.__delta = {};
499
514
  this.__changed = false;
500
515
  }
516
+ }, {
517
+ key: "clear_cache",
518
+ value: function clear_cache() {
519
+ this.__temp = {};
520
+ }
501
521
  /**
502
522
  * Sets readonly property on given objects
503
523
  * @param objs array of given objects or a single object
@@ -663,19 +683,33 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
663
683
  }
664
684
  }, {
665
685
  key: "setSaveResult",
666
- value: function setSaveResult(toObj, type) {
667
- this.__saveResultType = type;
686
+ value:
687
+ /**
688
+ * set the response of last save from site
689
+ * and its type
690
+ * @param toObj
691
+ */
692
+ function setSaveResult(toObj, type) {
693
+ if (toObj != null) {
694
+ _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
695
+ } else {
696
+ _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, null);
697
+ } //check if the given object is a valid save result
668
698
 
669
- if (toObj === true) {} else if (toObj === false) {} else {
670
- if (toObj) {
671
- _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, toObj);
672
- } else {
673
- _classPrivateMethodGet(this, _setSaveResultObject, _setSaveResultObject2).call(this, null);
674
- }
699
+
700
+ this.__saveResultIsSuccess = Boolean(type === "nothing" || this.constructor["isResultValid"](toObj));
701
+
702
+ if (type === "auto") {
703
+ type = this.__saveResultIsSuccess ? "normal" : "error";
675
704
  }
676
705
 
677
- this.__saveResultIsSuccess = (type === "normal" || type === "nothing") && toObj != null;
706
+ this.__saveResultType = type;
678
707
  }
708
+ /**
709
+ * set the response of last save from site
710
+ * @param toObj
711
+ */
712
+
679
713
  }, {
680
714
  key: "getSaveResult",
681
715
  value: function getSaveResult() {
@@ -685,7 +719,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
685
719
  }, {
686
720
  key: "getSaveResultType",
687
721
  value: function getSaveResultType() {
688
- return this.__saveResultType || null;
722
+ return this.__saveResultType || "nothing";
689
723
  }
690
724
  /* -------------------------------------------------------------------------- */
691
725
 
@@ -895,6 +929,12 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
895
929
 
896
930
  /* -------------------------------------------------------------------------- */
897
931
 
932
+ /**
933
+ * Checks if the given object is a valid and truthy save result
934
+ * @param result_object
935
+ * @returns
936
+ */
937
+
898
938
  }, {
899
939
  key: "isResultValid",
900
940
  value: function isResultValid(result_object) {
@@ -1010,6 +1050,16 @@ function _getProperty2(key) {
1010
1050
  return this[key];
1011
1051
  }
1012
1052
 
1053
+ function _getTempProperty2(key) {
1054
+ if (!this.__temp) return undefined;
1055
+ return this.__temp[key];
1056
+ }
1057
+
1058
+ function _setTempProperty2(key, value) {
1059
+ if (!this.__temp) this.__temp = {};
1060
+ this.__temp[key] = value;
1061
+ }
1062
+
1013
1063
  function _setSaveResultObject2(toObj) {
1014
1064
  this.__saveResultObject = toObj;
1015
1065
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",