@builttocreate/engine-utils 1.8.2 → 1.9.0-rc.1.1.0
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/activityHelper.js +3 -3
- package/dist/constants/Roles.js +38 -0
- package/dist/index.js +16 -2
- package/dist/roleHelper.js +33 -0
- package/dist/tableHelper.js +1 -1
- package/package.json +2 -2
package/dist/activityHelper.js
CHANGED
|
@@ -138,8 +138,8 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
138
138
|
*/
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
nextActivity.document.value = fieldRowsLookup[activity.document.field][activity.document.row];
|
|
142
|
-
nextActivity.document.rowIndex = fieldRowIndexLookup[activity.document.field][activity.document.row];
|
|
141
|
+
nextActivity.document.value = fieldRowsLookup[activity.document.field] && fieldRowsLookup[activity.document.field][activity.document.row] ? fieldRowsLookup[activity.document.field][activity.document.row] : null;
|
|
142
|
+
nextActivity.document.rowIndex = fieldRowIndexLookup[activity.document.field] && fieldRowIndexLookup[activity.document.field][activity.document.row] ? fieldRowIndexLookup[activity.document.field][activity.document.row] : null;
|
|
143
143
|
} else if (docFieldValue && templateField.type === _FieldTypes["default"].inputGroup) {
|
|
144
144
|
/**
|
|
145
145
|
* Input Group Step 1: create an easy way to lookup a row with the dropdown cells populated.
|
|
@@ -153,7 +153,7 @@ var addDocumentDataToActivities = function addDocumentDataToActivities(activitie
|
|
|
153
153
|
* whole row because input group display components are treated like regular field and not like table rows.
|
|
154
154
|
*/
|
|
155
155
|
|
|
156
|
-
nextActivity.document.value = fieldRowsLookup[activity.document.field][activity.document.row].cells[activity.document.column];
|
|
156
|
+
nextActivity.document.value = fieldRowsLookup[activity.document.field] && fieldRowsLookup[activity.document.field][activity.document.row] && fieldRowsLookup[activity.document.field][activity.document.row].cells[activity.document.column] ? fieldRowsLookup[activity.document.field][activity.document.row].cells[activity.document.column] : null;
|
|
157
157
|
} else if (docFieldValue && templateField.type === _FieldTypes["default"].multiSelect) {
|
|
158
158
|
var parsedDocFieldValue = docFieldValue && typeof docFieldValue === 'string' ? docFieldValue.split(',') : docFieldValue;
|
|
159
159
|
var _nextDocFieldValue = '';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Role Types:
|
|
10
|
+
*
|
|
11
|
+
* admin - They can do everything
|
|
12
|
+
* contributor - They can do everything, except modify users or templates
|
|
13
|
+
* readyOnly - They can see all but can't do anything.
|
|
14
|
+
* restricted - They can only see the stuff they authored. They don't have access to any other users stuff.
|
|
15
|
+
*/
|
|
16
|
+
var roles = {
|
|
17
|
+
admin: {
|
|
18
|
+
value: 'admin',
|
|
19
|
+
label: 'Full Access'
|
|
20
|
+
},
|
|
21
|
+
contributor: {
|
|
22
|
+
value: 'contributor',
|
|
23
|
+
label: 'Limited Access'
|
|
24
|
+
},
|
|
25
|
+
readOnly: {
|
|
26
|
+
value: 'readOnly',
|
|
27
|
+
label: 'ReadOnly'
|
|
28
|
+
},
|
|
29
|
+
restricted: {
|
|
30
|
+
value: 'restricted',
|
|
31
|
+
label: 'Restricted'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
roles.all = Object.keys(roles).map(function (key) {
|
|
35
|
+
return roles[key];
|
|
36
|
+
});
|
|
37
|
+
var _default = roles;
|
|
38
|
+
exports["default"] = _default;
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,13 @@ Object.defineProperty(exports, "changedKeys", {
|
|
|
25
25
|
return _changedKeys["default"];
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
Object.defineProperty(exports, "Roles", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function get() {
|
|
31
|
+
return _Roles["default"];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.paginationHelper = exports.roleHelper = exports.fileHelper = exports.activityHelper = exports.fieldHelper = exports.chartHelper = exports.tableHelper = exports["default"] = void 0;
|
|
29
35
|
|
|
30
36
|
var tableHelper = _interopRequireWildcard(require("./tableHelper"));
|
|
31
37
|
|
|
@@ -47,6 +53,10 @@ var fileHelper = _interopRequireWildcard(require("./fileHelper"));
|
|
|
47
53
|
|
|
48
54
|
exports.fileHelper = fileHelper;
|
|
49
55
|
|
|
56
|
+
var roleHelper = _interopRequireWildcard(require("./roleHelper"));
|
|
57
|
+
|
|
58
|
+
exports.roleHelper = roleHelper;
|
|
59
|
+
|
|
50
60
|
var _reduxApiMiddleware = _interopRequireWildcard(require("./reduxApiMiddleware"));
|
|
51
61
|
|
|
52
62
|
var paginationHelper = _interopRequireWildcard(require("./paginationHelper"));
|
|
@@ -55,6 +65,8 @@ exports.paginationHelper = paginationHelper;
|
|
|
55
65
|
|
|
56
66
|
var _changedKeys = _interopRequireDefault(require("./changedKeys"));
|
|
57
67
|
|
|
68
|
+
var _Roles = _interopRequireDefault(require("./constants/Roles"));
|
|
69
|
+
|
|
58
70
|
var _default = {
|
|
59
71
|
fileHelper: fileHelper,
|
|
60
72
|
tableHelper: tableHelper,
|
|
@@ -64,6 +76,8 @@ var _default = {
|
|
|
64
76
|
reduxApiMiddleware: _reduxApiMiddleware["default"],
|
|
65
77
|
CALL_API: _reduxApiMiddleware.CALL_API,
|
|
66
78
|
paginationHelper: paginationHelper,
|
|
67
|
-
changedKeys: _changedKeys["default"]
|
|
79
|
+
changedKeys: _changedKeys["default"],
|
|
80
|
+
roleHelper: roleHelper,
|
|
81
|
+
Roles: _Roles["default"]
|
|
68
82
|
};
|
|
69
83
|
exports["default"] = _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.hasRoles = exports.hasAdminRole = void 0;
|
|
9
|
+
|
|
10
|
+
var _Roles = _interopRequireDefault(require("./constants/Roles"));
|
|
11
|
+
|
|
12
|
+
var hasAdminRole = function hasAdminRole(permissions) {
|
|
13
|
+
return hasRoles([_Roles["default"].admin.value], permissions);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.hasAdminRole = hasAdminRole;
|
|
17
|
+
|
|
18
|
+
var hasRoles = function hasRoles(roles, permissions) {
|
|
19
|
+
/**
|
|
20
|
+
* If one of users permissions has a role inside of the
|
|
21
|
+
* roles property then return true
|
|
22
|
+
*/
|
|
23
|
+
return !permissions || permissions.length < 1 ? false : permissions.find(function (perm) {
|
|
24
|
+
return roles.indexOf(perm.role) !== -1;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.hasRoles = hasRoles;
|
|
29
|
+
var _default = {
|
|
30
|
+
hasAdminRole: hasAdminRole,
|
|
31
|
+
hasRoles: hasRoles
|
|
32
|
+
};
|
|
33
|
+
exports["default"] = _default;
|
package/dist/tableHelper.js
CHANGED
|
@@ -517,7 +517,7 @@ var resolveOperandValue = function resolveOperandValue(sourceOperand, targetOper
|
|
|
517
517
|
// It creates and infinite circular loop of trying to resovle a value
|
|
518
518
|
// because they both depend on eachother.
|
|
519
519
|
|
|
520
|
-
if (sourceOperand && hasCircularOperandReference(targetValue, sourceOperand)) return '* INVALID - Circular Reference'; // 4. If targetCell has a formula value
|
|
520
|
+
if (sourceOperand && hasCircularOperandReference(targetValue, sourceOperand) || targetOperand && hasCircularOperandReference(targetValue, targetOperand)) return '* INVALID - Circular Reference'; // 4. If targetCell has a formula value
|
|
521
521
|
|
|
522
522
|
if (targetValue !== undefined && targetValue.charAt(0) === '=') {
|
|
523
523
|
var result = getFormulaResult(sourceOperand, targetValue, tableLookup);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builttocreate/engine-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0-rc.1.1.0",
|
|
4
4
|
"description": "Utility library for common logic shared across web and mobile",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"eslint-plugin-import": "^2.22.1",
|
|
42
42
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
43
43
|
"eslint-plugin-react": "^7.22.0",
|
|
44
|
-
"jest": "^
|
|
44
|
+
"jest": "^27.0.6"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/polyfill": "^7.12.1",
|