@azrico/webobject 1.4.44 → 1.4.46
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 +2 -1
- package/dist/src/WebObjects/WebObject.js +13 -3
- package/dist/src/WebObjects/WebObjectHelper.d.ts +16 -0
- package/dist/src/WebObjects/WebObjectHelper.js +65 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +11 -0
- package/dist/src/structs/SimpleObject.d.ts +1 -0
- package/dist/src/structs/SimpleObject.js +8 -0
- package/package.json +1 -1
|
@@ -13,8 +13,9 @@ export declare class WebObject extends SimpleObject {
|
|
|
13
13
|
static readonly __web_type: string;
|
|
14
14
|
meta_data: MetaObject[];
|
|
15
15
|
_id: string;
|
|
16
|
-
_creator?: string;
|
|
17
16
|
_created_date?: string | Date;
|
|
17
|
+
_creator?: string;
|
|
18
|
+
_users?: string[];
|
|
18
19
|
constructor(is_readonly?: boolean);
|
|
19
20
|
/**
|
|
20
21
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
@@ -43,8 +43,11 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
43
43
|
_this = _super.call(this, is_readonly);
|
|
44
44
|
_defineProperty(_assertThisInitialized(_this), "meta_data", void 0);
|
|
45
45
|
_defineProperty(_assertThisInitialized(_this), "_id", "");
|
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "_creator", void 0);
|
|
47
46
|
_defineProperty(_assertThisInitialized(_this), "_created_date", void 0);
|
|
47
|
+
//the owner of the object
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "_creator", void 0);
|
|
49
|
+
//multiple users can work on one object
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "_users", void 0);
|
|
48
51
|
_defineProperty(_assertThisInitialized(_this), "get_webtype", function () {
|
|
49
52
|
return _this.__web_type || _this.get_webpath();
|
|
50
53
|
});
|
|
@@ -188,7 +191,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
188
191
|
value: function () {
|
|
189
192
|
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
|
|
190
193
|
var _this2 = this;
|
|
191
|
-
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, functionProps, index, fp, _iterator, _step, key;
|
|
194
|
+
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, functionProps, index, fp, _iterator, _step, key, tempusers;
|
|
192
195
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
193
196
|
while (1) switch (_context5.prev = _context5.next) {
|
|
194
197
|
case 0:
|
|
@@ -317,8 +320,15 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
317
320
|
final_object["_index_value"] = this.getIndex();
|
|
318
321
|
final_object["_created_date"] = this["_created_date"];
|
|
319
322
|
}
|
|
323
|
+
if (final_object["_users"]) {
|
|
324
|
+
tempusers = final_object["_users"];
|
|
325
|
+
if (typeof tempusers === "string") tempusers = tempusers.split(",").filter(function (s) {
|
|
326
|
+
return s;
|
|
327
|
+
});
|
|
328
|
+
final_object["_users"] = (0, _object.wrap_array)(tempusers);
|
|
329
|
+
}
|
|
320
330
|
return _context5.abrupt("return", final_object);
|
|
321
|
-
case
|
|
331
|
+
case 35:
|
|
322
332
|
case "end":
|
|
323
333
|
return _context5.stop();
|
|
324
334
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import WebObject from "./WebObject";
|
|
2
|
+
export default class WebObjectHelper {
|
|
3
|
+
/**
|
|
4
|
+
* get a list of all _creator and _users of the given objects
|
|
5
|
+
* @param objectlist
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
static get_users_in_objects(objectlist: WebObject | WebObject[]): string[];
|
|
9
|
+
/**
|
|
10
|
+
* check if the given user object is list of _users or _creator of the given object(s)
|
|
11
|
+
* @param user
|
|
12
|
+
* @param obj
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
static isUserWorkerOfObject(user: any, obj: any): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _WebObject = _interopRequireDefault(require("./WebObject"));
|
|
8
|
+
var _object = require("@azrico/object");
|
|
9
|
+
var _string = require("@azrico/string");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
+
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); } }
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
+
var WebObjectHelper = /*#__PURE__*/function () {
|
|
24
|
+
function WebObjectHelper() {
|
|
25
|
+
_classCallCheck(this, WebObjectHelper);
|
|
26
|
+
}
|
|
27
|
+
_createClass(WebObjectHelper, null, [{
|
|
28
|
+
key: "get_users_in_objects",
|
|
29
|
+
value:
|
|
30
|
+
/**
|
|
31
|
+
* get a list of all _creator and _users of the given objects
|
|
32
|
+
* @param objectlist
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
function get_users_in_objects(objectlist) {
|
|
36
|
+
objectlist = (0, _object.wrap_array)(objectlist);
|
|
37
|
+
var userlist = [];
|
|
38
|
+
for (var index = 0; index < objectlist.length; index++) {
|
|
39
|
+
var obj = objectlist[index];
|
|
40
|
+
userlist.push(obj._creator || "");
|
|
41
|
+
userlist.push.apply(userlist, _toConsumableArray((0, _object.wrap_array)(obj._users)));
|
|
42
|
+
//backwards compatibility: (orders have this)
|
|
43
|
+
userlist.push.apply(userlist, _toConsumableArray((0, _object.wrap_array)(obj.attentions)));
|
|
44
|
+
}
|
|
45
|
+
return (0, _object.array_remove_duplicates)(userlist).filter(function (s) {
|
|
46
|
+
return !(0, _string.string_isEmpty)(s);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* check if the given user object is list of _users or _creator of the given object(s)
|
|
51
|
+
* @param user
|
|
52
|
+
* @param obj
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
}, {
|
|
56
|
+
key: "isUserWorkerOfObject",
|
|
57
|
+
value: function isUserWorkerOfObject(user, obj) {
|
|
58
|
+
var userid = _WebObject["default"].getID(user);
|
|
59
|
+
var orderWorkers = this.get_users_in_objects(obj);
|
|
60
|
+
return orderWorkers.includes(userid);
|
|
61
|
+
}
|
|
62
|
+
}]);
|
|
63
|
+
return WebObjectHelper;
|
|
64
|
+
}();
|
|
65
|
+
exports["default"] = WebObjectHelper;
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -101,4 +101,15 @@ Object.keys(_ParentWebObject).forEach(function (key) {
|
|
|
101
101
|
return _ParentWebObject[key];
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
|
+
});
|
|
105
|
+
var _WebObjectHelper = require("./WebObjects/WebObjectHelper");
|
|
106
|
+
Object.keys(_WebObjectHelper).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _WebObjectHelper[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _WebObjectHelper[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
104
115
|
});
|
|
@@ -178,6 +178,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
178
178
|
setSaveResult(toObj: any, type?: saveResultType | "auto"): void;
|
|
179
179
|
getSaveResult(original?: boolean): any;
|
|
180
180
|
getSaveResultType(): saveResultType;
|
|
181
|
+
static setTemp(obj: any, key: string, value: any): any;
|
|
181
182
|
static factoryClear(obj: SimpleObject): void;
|
|
182
183
|
static delete_cache(): void;
|
|
183
184
|
static get_canModify(o: SimpleObject): boolean;
|
|
@@ -1064,6 +1064,14 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
return false;
|
|
1066
1066
|
}
|
|
1067
|
+
}, {
|
|
1068
|
+
key: "setTemp",
|
|
1069
|
+
value: function setTemp(obj, key, value) {
|
|
1070
|
+
if (_typeof(obj) !== "object" || !obj || Array.isArray(obj)) return;
|
|
1071
|
+
if (obj instanceof SimpleObject) return obj.setTemp(key, value);
|
|
1072
|
+
if (obj.__temp == null) obj.__temp = {};
|
|
1073
|
+
if (value == null) delete obj.__temp[key];else obj.__temp[key] = value;
|
|
1074
|
+
}
|
|
1067
1075
|
}, {
|
|
1068
1076
|
key: "factoryClear",
|
|
1069
1077
|
value: function factoryClear(obj) {
|