@azrico/webobject 1.4.79 → 1.4.80
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.
- package/dist/src/WebObjects/WebObject.d.ts +5 -0
- package/dist/src/WebObjects/WebObject.js +18 -2
- package/dist/src/WebObjects/WebObjectManager.d.ts +4 -2
- package/dist/src/WebObjects/WebObjectManager.js +26 -10
- package/dist/src/structs/ObjectManager.d.ts +2 -4
- package/dist/src/structs/ObjectManager.js +0 -6
- package/dist/src/structs/SimpleObject.d.ts +12 -17
- package/dist/src/structs/SimpleObject.js +0 -19
- package/package.json +1 -1
|
@@ -10,6 +10,8 @@ export type deltaParams = {
|
|
|
10
10
|
applyFilter?: boolean;
|
|
11
11
|
};
|
|
12
12
|
export declare class WebObject extends SimpleObject {
|
|
13
|
+
static readonly __web_path: string;
|
|
14
|
+
static readonly __web_type: string;
|
|
13
15
|
static readonly __protectedProperties: string[];
|
|
14
16
|
static readonly __requiredProperties: never[];
|
|
15
17
|
meta_data: {
|
|
@@ -68,7 +70,10 @@ export declare class WebObject extends SimpleObject {
|
|
|
68
70
|
* @returns
|
|
69
71
|
*/
|
|
70
72
|
get_deltaObject(p?: deltaParams): Promise<any>;
|
|
73
|
+
get __web_path(): string;
|
|
74
|
+
get __web_type(): string;
|
|
71
75
|
get manager(): WebObjectManager<any> | undefined;
|
|
76
|
+
static get_webname(): string | undefined;
|
|
72
77
|
onDelete(...p: any): Promise<any>;
|
|
73
78
|
onLoad(...p: any): Promise<any>;
|
|
74
79
|
onSave(...p: any): Promise<any>;
|
|
@@ -421,15 +421,24 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
421
421
|
}, _callee6, this, [[17, 28, 31, 34]]);
|
|
422
422
|
}))).apply(this, arguments);
|
|
423
423
|
} /* --------------------------------- Getters -------------------------------- */
|
|
424
|
+
}, {
|
|
425
|
+
key: "__web_path",
|
|
426
|
+
get: function get() {
|
|
427
|
+
return this.constructor["__web_path"] || this.__web_type;
|
|
428
|
+
}
|
|
429
|
+
}, {
|
|
430
|
+
key: "__web_type",
|
|
431
|
+
get: function get() {
|
|
432
|
+
return this.constructor["__web_type"];
|
|
433
|
+
}
|
|
424
434
|
}, {
|
|
425
435
|
key: "manager",
|
|
426
436
|
get: function get() {
|
|
427
437
|
return this.get_managerClass() || undefined;
|
|
428
438
|
}
|
|
429
|
-
/* -------------------------------------------------------------------------- */
|
|
430
439
|
}, {
|
|
431
440
|
key: "onDelete",
|
|
432
|
-
value: function onDelete() {
|
|
441
|
+
value: /* -------------------------------------------------------------------------- */function onDelete() {
|
|
433
442
|
return (_onDelete = _onDelete || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
434
443
|
var _this$manager;
|
|
435
444
|
var _len,
|
|
@@ -752,6 +761,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
752
761
|
}, _callee12, this);
|
|
753
762
|
}))).apply(this, arguments);
|
|
754
763
|
}
|
|
764
|
+
}, {
|
|
765
|
+
key: "get_webname",
|
|
766
|
+
value: function get_webname() {
|
|
767
|
+
return this.__web_path || this.__web_type || this.__cache_name;
|
|
768
|
+
}
|
|
755
769
|
}, {
|
|
756
770
|
key: "saveResultHasID",
|
|
757
771
|
value: function saveResultHasID(s) {
|
|
@@ -899,6 +913,8 @@ var WebObject = /*#__PURE__*/function (_SimpleObject, _setMetaValue, _Save, _Del
|
|
|
899
913
|
return WebObject;
|
|
900
914
|
}(_index3.SimpleObject);
|
|
901
915
|
exports.WebObject = WebObject;
|
|
916
|
+
_defineProperty(WebObject, "__web_path", "");
|
|
917
|
+
_defineProperty(WebObject, "__web_type", "");
|
|
902
918
|
_defineProperty(WebObject, "__protectedProperties", ["_users"]);
|
|
903
919
|
//you cant create a new weboject without these properties
|
|
904
920
|
_defineProperty(WebObject, "__requiredProperties", []);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { sendChangesType } from "../
|
|
1
|
+
import { WebObject, sendChangesType } from "../index";
|
|
2
2
|
import ObjectManager from "../structs/ObjectManager";
|
|
3
|
-
import WebObject from "./WebObject";
|
|
4
3
|
/**
|
|
5
4
|
* This class manages the events of an Simple Object
|
|
6
5
|
*/
|
|
7
6
|
export declare class WebObjectManager<T extends WebObject> extends ObjectManager<T> {
|
|
8
7
|
static readonly __save_message: boolean;
|
|
8
|
+
protected __last_web_path: string;
|
|
9
|
+
protected __last_web_type: string;
|
|
9
10
|
constructor();
|
|
11
|
+
setObject(toObj: T | undefined): boolean;
|
|
10
12
|
/**
|
|
11
13
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
12
14
|
* @param key
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.WebObjectManager = void 0;
|
|
7
|
+
var _index = require("../index");
|
|
7
8
|
var _ObjectManager2 = _interopRequireDefault(require("../structs/ObjectManager"));
|
|
8
9
|
var _global = require("@azrico/global");
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -14,6 +15,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
14
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
16
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
17
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
19
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
17
20
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
21
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
22
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -36,6 +39,8 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
|
|
|
36
39
|
_classCallCheck(this, WebObjectManager);
|
|
37
40
|
_this = _super.call(this);
|
|
38
41
|
/* ---------------- should we display a message after saving ? -------------- */
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "__last_web_path", "");
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "__last_web_type", "");
|
|
39
44
|
if (_this.constructor["__save_message"]) {
|
|
40
45
|
_this.event_add("on_save", "onsave_sendmsg", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
41
46
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -78,17 +83,28 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager, _setMetaValue, _ge
|
|
|
78
83
|
return _this;
|
|
79
84
|
}
|
|
80
85
|
/* -------------------------------------------------------------------------- */
|
|
81
|
-
/* Meta data */
|
|
82
|
-
/* -------------------------------------------------------------------------- */
|
|
83
|
-
/**
|
|
84
|
-
* Update meta value of this object , meta data is stored in meta_data variable
|
|
85
|
-
* @param key
|
|
86
|
-
* @param value
|
|
87
|
-
* @param createIfNotExists should we create a new meta if key does not exist
|
|
88
|
-
* @param sendChange
|
|
89
|
-
* @returns
|
|
90
|
-
*/
|
|
91
86
|
_createClass(WebObjectManager, [{
|
|
87
|
+
key: "setObject",
|
|
88
|
+
value: function setObject(toObj) {
|
|
89
|
+
var res = _get(_getPrototypeOf(WebObjectManager.prototype), "setObject", this).call(this, toObj);
|
|
90
|
+
if (this.__currentObject instanceof _index.SimpleObject) {
|
|
91
|
+
this.__last_web_path == this.__currentObject.__web_path || this.__last_web_path;
|
|
92
|
+
this.__last_web_type == this.__currentObject.__web_type || this.__last_web_type;
|
|
93
|
+
}
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
/* -------------------------------------------------------------------------- */
|
|
97
|
+
/* Meta data */
|
|
98
|
+
/* -------------------------------------------------------------------------- */
|
|
99
|
+
/**
|
|
100
|
+
* Update meta value of this object , meta data is stored in meta_data variable
|
|
101
|
+
* @param key
|
|
102
|
+
* @param value
|
|
103
|
+
* @param createIfNotExists should we create a new meta if key does not exist
|
|
104
|
+
* @param sendChange
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
}, {
|
|
92
108
|
key: "setMetaValue",
|
|
93
109
|
value: function setMetaValue(_x, _x2) {
|
|
94
110
|
return (_setMetaValue = _setMetaValue || _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
@@ -8,11 +8,9 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
8
8
|
__eventList: any;
|
|
9
9
|
__eventPrefix?: string;
|
|
10
10
|
__stopEvents?: boolean;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
protected __currentObject?: ObjType | null;
|
|
12
|
+
protected __options?: object;
|
|
13
13
|
__object_nullable: boolean;
|
|
14
|
-
__last_web_path: string;
|
|
15
|
-
__last_web_type: string;
|
|
16
14
|
notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[] | undefined>;
|
|
17
15
|
get obj(): ObjType | undefined;
|
|
18
16
|
/**
|
|
@@ -33,8 +33,6 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
|
|
|
33
33
|
_defineProperty(this, "__options", void 0);
|
|
34
34
|
//can the current object be set to null safely?
|
|
35
35
|
_defineProperty(this, "__object_nullable", false);
|
|
36
|
-
_defineProperty(this, "__last_web_path", "");
|
|
37
|
-
_defineProperty(this, "__last_web_type", "");
|
|
38
36
|
_defineProperty(this, "get", this.getValue);
|
|
39
37
|
}
|
|
40
38
|
_createClass(ObjectManager, [{
|
|
@@ -92,10 +90,6 @@ var ObjectManager = /*#__PURE__*/function (_notifyChanged, _setValue, _setSubVal
|
|
|
92
90
|
if (this.__currentObject) {
|
|
93
91
|
this.__currentObject.set_managerClass(this);
|
|
94
92
|
}
|
|
95
|
-
if (this.__currentObject instanceof _SimpleObject["default"]) {
|
|
96
|
-
this.__last_web_path == this.__currentObject.__web_path || this.__last_web_path;
|
|
97
|
-
this.__last_web_type == this.__currentObject.__web_type || this.__last_web_type;
|
|
98
|
-
}
|
|
99
93
|
if (toObj == null && !this.__object_nullable) {
|
|
100
94
|
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
101
95
|
}
|
|
@@ -9,8 +9,6 @@ export type WriteablePropOf<obj> = keyof obj;
|
|
|
9
9
|
export type PropType<obj, prop extends keyof obj> = obj[prop];
|
|
10
10
|
export declare class SimpleObject extends MapableObject {
|
|
11
11
|
#private;
|
|
12
|
-
static readonly __web_path: string;
|
|
13
|
-
static readonly __web_type: string;
|
|
14
12
|
static readonly __cache_name?: string;
|
|
15
13
|
static readonly __unchangeables?: string[];
|
|
16
14
|
static readonly __changeables?: string[];
|
|
@@ -23,26 +21,23 @@ export declare class SimpleObject extends MapableObject {
|
|
|
23
21
|
static readonly __checkProperties?: string[];
|
|
24
22
|
static readonly __use_delta: boolean;
|
|
25
23
|
_static(): Function;
|
|
26
|
-
__originalobject?: this;
|
|
27
|
-
__delta: Partial<this>;
|
|
28
|
-
__temp: any;
|
|
29
|
-
__changed: boolean;
|
|
30
|
-
__lastChanged?: string;
|
|
31
|
-
__is_readonly?: boolean;
|
|
32
|
-
__throw_errors?: boolean;
|
|
24
|
+
protected __originalobject?: this;
|
|
25
|
+
protected __delta: Partial<this>;
|
|
26
|
+
protected __temp: any;
|
|
27
|
+
protected __changed: boolean;
|
|
28
|
+
protected __lastChanged?: string;
|
|
29
|
+
protected __is_readonly?: boolean;
|
|
30
|
+
protected __throw_errors?: boolean;
|
|
33
31
|
_deleted?: boolean;
|
|
34
32
|
_deletedBy?: string;
|
|
35
|
-
__errors?: any[];
|
|
36
|
-
__showErrors?: boolean;
|
|
37
|
-
__saveResultObject?: any;
|
|
38
|
-
__saveResultIsSuccess: boolean;
|
|
39
|
-
__saveResultType?: saveResultType;
|
|
33
|
+
protected __errors?: any[];
|
|
34
|
+
protected __showErrors?: boolean;
|
|
35
|
+
protected __saveResultObject?: any;
|
|
36
|
+
protected __saveResultIsSuccess: boolean;
|
|
37
|
+
protected __saveResultType?: saveResultType;
|
|
40
38
|
_index_key: string;
|
|
41
39
|
_index_value: number;
|
|
42
40
|
constructor(is_readonly?: boolean);
|
|
43
|
-
get __web_path(): string;
|
|
44
|
-
get __web_type(): string;
|
|
45
|
-
static get_webname(): string | undefined;
|
|
46
41
|
loadValues(initObject: any, fullUpdate?: boolean): boolean;
|
|
47
42
|
static loadValues(obj: SimpleObject, initObject: any, fullUpdate?: boolean): boolean;
|
|
48
43
|
static getValue<T extends SimpleObject, MKey extends PropOf<T>>(o: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
|
|
@@ -65,7 +65,6 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
|
|
|
65
65
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setDefaultProperty);
|
|
66
66
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setProperty);
|
|
67
67
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _getSubProperty);
|
|
68
|
-
/* -------------------------------------------------------------------------- */
|
|
69
68
|
_classPrivateMethodInitSpec(_assertThisInitialized(_this), _setSubProperty);
|
|
70
69
|
//an exact copy of this object is stored here
|
|
71
70
|
_defineProperty(_assertThisInitialized(_this), "__originalobject", void 0);
|
|
@@ -113,22 +112,11 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
|
|
|
113
112
|
_this.clear_changes();
|
|
114
113
|
return _this;
|
|
115
114
|
}
|
|
116
|
-
/* -------------------------------------------------------------------------- */
|
|
117
115
|
_createClass(SimpleObject, [{
|
|
118
116
|
key: "_static",
|
|
119
117
|
value: function _static() {
|
|
120
118
|
return this.constructor;
|
|
121
119
|
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "__web_path",
|
|
124
|
-
get: function get() {
|
|
125
|
-
return this.constructor["__web_path"] || this.__web_type;
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "__web_type",
|
|
129
|
-
get: function get() {
|
|
130
|
-
return this.constructor["__web_type"];
|
|
131
|
-
}
|
|
132
120
|
}, {
|
|
133
121
|
key: "loadValues",
|
|
134
122
|
value: /* -------------------------------------------------------------------------- */
|
|
@@ -892,11 +880,6 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject, _setValue, _setTemp, _
|
|
|
892
880
|
/* statics */
|
|
893
881
|
/* -------------------------------------------------------------------------- */
|
|
894
882
|
}], [{
|
|
895
|
-
key: "get_webname",
|
|
896
|
-
value: function get_webname() {
|
|
897
|
-
return this.__web_path || this.__web_type || this.__cache_name;
|
|
898
|
-
}
|
|
899
|
-
}, {
|
|
900
883
|
key: "loadValues",
|
|
901
884
|
value: function loadValues(obj, initObject) {
|
|
902
885
|
var fullUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -1265,8 +1248,6 @@ function _setSaveResultObject2(toObj) {
|
|
|
1265
1248
|
if (toObj == null) toObj = null; //null or undefined
|
|
1266
1249
|
this.__saveResultObject = toObj;
|
|
1267
1250
|
}
|
|
1268
|
-
_defineProperty(SimpleObject, "__web_path", "");
|
|
1269
|
-
_defineProperty(SimpleObject, "__web_type", "");
|
|
1270
1251
|
_defineProperty(SimpleObject, "__cache_name", void 0);
|
|
1271
1252
|
//these properties should not be changed and are usually set by server
|
|
1272
1253
|
_defineProperty(SimpleObject, "__unchangeables", void 0);
|