@azrico/webobject 1.4.14 → 1.4.15
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.
|
@@ -274,7 +274,10 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
274
274
|
dlt = allProperties || !useDelta && isChild && chkChangables ? _objectSpread({}, this.allproperties) : _objectSpread({}, this.__delta);
|
|
275
275
|
allkeys = Object.keys(dlt);
|
|
276
276
|
changableKeys = chkChangables ? allkeys.filter(function (s) {
|
|
277
|
-
return _SimpleObject2["default"].canChangeKey(_this2, s,
|
|
277
|
+
return _SimpleObject2["default"].canChangeKey(_this2, s, {
|
|
278
|
+
useExtraProps: useExtraProps,
|
|
279
|
+
ignoreProtected: allProperties
|
|
280
|
+
});
|
|
278
281
|
}) : allkeys;
|
|
279
282
|
_iterator = _createForOfIteratorHelper(changableKeys);
|
|
280
283
|
_context5.prev = 13;
|
|
@@ -95,7 +95,10 @@ export declare class SimpleObject extends MapableObject {
|
|
|
95
95
|
* @param useExtraProps should we check extra props?
|
|
96
96
|
* @returns
|
|
97
97
|
*/
|
|
98
|
-
static canChangeKey(object: SimpleObject, key: string,
|
|
98
|
+
static canChangeKey(object: SimpleObject, key: string, options: {
|
|
99
|
+
useExtraProps?: boolean;
|
|
100
|
+
ignoreProtected?: boolean;
|
|
101
|
+
}): boolean;
|
|
99
102
|
static hasIllegalChanges(referenceObject: any, changesObject: any, updaterUser: any): boolean;
|
|
100
103
|
/**
|
|
101
104
|
* Apply the changes and empty the delta object
|
|
@@ -839,8 +839,10 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
839
839
|
}
|
|
840
840
|
}, {
|
|
841
841
|
key: "canChangeKey",
|
|
842
|
-
value: function canChangeKey(object, key,
|
|
842
|
+
value: function canChangeKey(object, key, options) {
|
|
843
843
|
if (!object || !key) return false;
|
|
844
|
+
var useExtraProps = options.useExtraProps,
|
|
845
|
+
ignoreProtected = options.ignoreProtected;
|
|
844
846
|
if (useExtraProps) {
|
|
845
847
|
var __extraProperties = object.constructor["__extraProperties"];
|
|
846
848
|
if (__extraProperties != null && __extraProperties.includes(key)) return true;
|
|
@@ -848,16 +850,18 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
848
850
|
/* -------------------------------------------------------------------------- */
|
|
849
851
|
var __changeables = object.constructor["__changeables"];
|
|
850
852
|
var __unchangeables = object.constructor["__unchangeables"];
|
|
851
|
-
var __protectedProperties = object.constructor["__protectedProperties"];
|
|
852
853
|
/* -------------------------------------------------------------------------- */
|
|
853
854
|
if (__changeables != null && !__changeables.includes(key)) return false;
|
|
854
855
|
if (__unchangeables != null && __unchangeables.includes(key)) return false;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
856
|
+
if (!ignoreProtected) {
|
|
857
|
+
var __protectedProperties = object.constructor["__protectedProperties"];
|
|
858
|
+
if (__protectedProperties != null && __protectedProperties.includes(key)) {
|
|
859
|
+
//protected keys can only be changed by the creator of this object
|
|
860
|
+
//make sure you set the is_current_user function correctly
|
|
861
|
+
if (object.isNew) return true;
|
|
862
|
+
var creatorOfObject = object.get("_creator");
|
|
863
|
+
return Boolean(_global.gfunc.run_action_sync("is_current_user", creatorOfObject));
|
|
864
|
+
}
|
|
861
865
|
}
|
|
862
866
|
return true;
|
|
863
867
|
}
|