@azrico/webobject 1.2.33 → 1.2.35
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.
|
@@ -33,7 +33,7 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
33
33
|
getSaveResult(): any;
|
|
34
34
|
getSaveResultType(): saveResultType | null;
|
|
35
35
|
setSaveResult(toObj: any, type: saveResultType): void | undefined;
|
|
36
|
-
apply_changes(): boolean
|
|
36
|
+
apply_changes(): boolean;
|
|
37
37
|
getValue(key: PropOf<ObjType>, original?: boolean): import("./SimpleObject").PropType<ObjType, any> | undefined;
|
|
38
38
|
get: (key: PropOf<ObjType>, original?: boolean) => import("./SimpleObject").PropType<ObjType, any> | undefined;
|
|
39
39
|
/**
|
|
@@ -161,7 +161,7 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
161
161
|
key: "apply_changes",
|
|
162
162
|
value: function apply_changes() {
|
|
163
163
|
var _this$obj5;
|
|
164
|
-
return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.apply_changes();
|
|
164
|
+
return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.apply_changes()) || false;
|
|
165
165
|
}
|
|
166
166
|
}, {
|
|
167
167
|
key: "getValue",
|
|
@@ -355,22 +355,24 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
355
355
|
* Apply the changes and empty the delta object
|
|
356
356
|
*/
|
|
357
357
|
function apply_changes() {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
try {
|
|
359
|
+
if (!this.__use_delta) {
|
|
360
|
+
//in this mode , we track changes by updating the original product
|
|
361
|
+
this.setOriginal();
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
if (!this.isChanged) {
|
|
365
|
+
console.warn("No changes to apply");
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
for (var key in this.__delta) {
|
|
369
|
+
var nv = this.__delta[key];
|
|
370
|
+
this[key] = nv;
|
|
371
|
+
}
|
|
361
372
|
return true;
|
|
362
|
-
}
|
|
363
|
-
if (!this.isChanged) {
|
|
364
|
-
console.warn("No changes to apply");
|
|
373
|
+
} finally {
|
|
365
374
|
this.clear_changes();
|
|
366
|
-
return false;
|
|
367
|
-
}
|
|
368
|
-
for (var key in this.__delta) {
|
|
369
|
-
var nv = this.__delta[key];
|
|
370
|
-
this[key] = nv;
|
|
371
375
|
}
|
|
372
|
-
this.clear_changes();
|
|
373
|
-
return true;
|
|
374
376
|
}
|
|
375
377
|
}, {
|
|
376
378
|
key: "clear_changes",
|
|
@@ -398,23 +400,28 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
398
400
|
/* -------------------------------------------------------------------------- */
|
|
399
401
|
function get() {
|
|
400
402
|
var _this2 = this;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
403
|
+
////const deltaIsBlank = object_isEmpty(this.__delta);
|
|
404
|
+
////if (!deltaIsBlank) return true; //delta is not blank, definitely changed
|
|
405
|
+
////if (this.__use_delta) return !deltaIsBlank; //trust the delta.
|
|
406
|
+
if (this.__use_delta) return !(0, _object.object_isEmpty)(this.__delta);
|
|
407
|
+
/* -------------------------------------------------------------------------- */
|
|
408
|
+
/* check the properties one by one */
|
|
409
|
+
/* -------------------------------------------------------------------------- */
|
|
410
|
+
var orig = this.getOriginal();
|
|
411
|
+
if (!orig) return false; //we dont know if anything has changed
|
|
412
|
+
/* if object is not using delta mode, check changes by comparing changable fields with original object */
|
|
413
|
+
if (Array.isArray(this.__changeables)) {
|
|
414
|
+
//console.log("chk", this.__changeables, "for changes");
|
|
415
|
+
return this.__changeables.find(function (c) {
|
|
416
|
+
return !(0, _object.object_equals)(_this2[c], orig[c]);
|
|
417
|
+
}) != undefined;
|
|
418
|
+
} else {
|
|
419
|
+
/* check all fields */
|
|
420
|
+
for (var key in this) {
|
|
421
|
+
if (key.startsWith("__")) continue;
|
|
422
|
+
if (!(0, _object.object_equals)(this[key], orig[key])) return true;
|
|
417
423
|
}
|
|
424
|
+
return false;
|
|
418
425
|
}
|
|
419
426
|
return false;
|
|
420
427
|
}
|
|
@@ -819,7 +826,8 @@ function _getSubProperty2(key, subkey) {
|
|
|
819
826
|
return subobj[subkey];
|
|
820
827
|
}
|
|
821
828
|
function _setProperty2(key, value) {
|
|
822
|
-
|
|
829
|
+
this.__delta[key] = value; //always update delta to keep track of changes
|
|
830
|
+
if (!this.__use_delta) this[key] = value; //on noDelta mode, also update the obj
|
|
823
831
|
return true;
|
|
824
832
|
}
|
|
825
833
|
function _setDefaultProperty2(key, value) {
|