@azrico/webobject 1.4.48 → 1.4.50
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/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -101,15 +101,4 @@ 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
|
-
});
|
|
115
104
|
});
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import WebObject from "./WebObject";
|
|
2
|
-
export declare class WebObjectHelper {
|
|
3
|
-
/**
|
|
4
|
-
* get a list of all _creator and _users of the given objects
|
|
5
|
-
* @param objectlist
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
static getUsersOfObject(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 isUserInObject(user: any, obj: WebObject | WebObject[]): boolean;
|
|
16
|
-
}
|
|
17
|
-
export default WebObjectHelper;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.WebObjectHelper = 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: "getUsersOfObject",
|
|
29
|
-
value:
|
|
30
|
-
/**
|
|
31
|
-
* get a list of all _creator and _users of the given objects
|
|
32
|
-
* @param objectlist
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
function getUsersOfObject(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
|
-
var useridlist = userlist.map(function (r) {
|
|
46
|
-
return _typeof(r) === "object" ? _WebObject["default"].getID(r) : r;
|
|
47
|
-
});
|
|
48
|
-
return (0, _object.array_remove_duplicates)(useridlist).filter(function (s) {
|
|
49
|
-
return !(0, _string.string_isEmpty)(s);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* check if the given user object is list of _users or _creator of the given object(s)
|
|
54
|
-
* @param user
|
|
55
|
-
* @param obj
|
|
56
|
-
* @returns
|
|
57
|
-
*/
|
|
58
|
-
}, {
|
|
59
|
-
key: "isUserInObject",
|
|
60
|
-
value: function isUserInObject(user, obj) {
|
|
61
|
-
var userid = _WebObject["default"].getID(user);
|
|
62
|
-
var orderWorkers = this.getUsersOfObject(obj);
|
|
63
|
-
return orderWorkers.includes(userid);
|
|
64
|
-
}
|
|
65
|
-
}]);
|
|
66
|
-
return WebObjectHelper;
|
|
67
|
-
}();
|
|
68
|
-
exports.WebObjectHelper = WebObjectHelper;
|
|
69
|
-
var _default = WebObjectHelper;
|
|
70
|
-
exports["default"] = _default;
|