orc-shared 5.8.0-dev.16 → 5.8.0-dev.18
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/components/MaterialUI/DataDisplay/Badge.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +14 -1
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -1
- package/dist/components/Routing/SegmentPage.js +1 -1
- package/dist/utils/normalizeForSearch.js +4 -1
- package/dist/utils/propertyBagHelper.js +3 -3
- package/dist/utils/propertyHelper.js +6 -6
- package/dist/utils/testUtils.js +3 -0
- package/package.json +2 -2
- package/src/components/AppFrame/ConnectedToastList.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/Badge.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +13 -1
- package/src/components/MaterialUI/Inputs/Select.test.js +37 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +1 -0
- package/src/components/Modal/Modal.test.js +3 -1
- package/src/components/Modal/Wrapper.test.js +3 -1
- package/src/components/Routing/SegmentPage.js +1 -1
- package/src/components/Scope/Scope.test.js +3 -1
- package/src/components/Sidepanel.test.js +3 -1
- package/src/utils/normalizeForSearch.js +2 -0
- package/src/utils/propertyBagHelper.js +6 -3
- package/src/utils/propertyHelper.js +6 -6
- package/src/utils/testUtils.js +25 -22
|
@@ -39,7 +39,7 @@ var Badge = function Badge(_ref) {
|
|
|
39
39
|
badge = _ref.badge,
|
|
40
40
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
41
|
var classes = useStyles();
|
|
42
|
-
var classProp =
|
|
42
|
+
var classProp = (_props$classProp = props.classProp) != null && _props$classProp.badge ? props.classProp : classes;
|
|
43
43
|
return /*#__PURE__*/_react.default.createElement(_Badge.default, {
|
|
44
44
|
overlap: "circular",
|
|
45
45
|
color: "primary",
|
|
@@ -185,6 +185,7 @@ __signature__(SelectIconButton, "useStyles{classes}", function () {
|
|
|
185
185
|
__signature__(SelectIconButton, "useStyles{classes}", function () {
|
|
186
186
|
return [useStyles];
|
|
187
187
|
});
|
|
188
|
+
var selectEmptyValue = "~~#~~";
|
|
188
189
|
var Select = function Select(_ref) {
|
|
189
190
|
var _selectProps$get;
|
|
190
191
|
var options = _ref.options,
|
|
@@ -222,6 +223,16 @@ var Select = function Select(_ref) {
|
|
|
222
223
|
options.sort(function (a, b) {
|
|
223
224
|
return a.sortOrder > b.sortOrder ? 1 : -1;
|
|
224
225
|
});
|
|
226
|
+
} else if (sortType === _SelectProps.sortTypeEnum.alphabetical) {
|
|
227
|
+
options.sort(function (a, b) {
|
|
228
|
+
if (a.value === selectEmptyValue) {
|
|
229
|
+
return -1;
|
|
230
|
+
}
|
|
231
|
+
if (b.value === selectEmptyValue) {
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
return a.label.localeCompare(b.label);
|
|
235
|
+
});
|
|
225
236
|
}
|
|
226
237
|
if (showAllValue && showAllLabel) {
|
|
227
238
|
options.unshift({
|
|
@@ -245,7 +256,7 @@ var Select = function Select(_ref) {
|
|
|
245
256
|
var items = options == null ? void 0 : options.map(function (option) {
|
|
246
257
|
var clss = option != null && option.level ? classes["level" + option.level] : "";
|
|
247
258
|
var appliedClasses = (0, _classnames.default)(classes.baseItem, clss);
|
|
248
|
-
var labelClss = (0, _classnames.default)(_defineProperty(_defineProperty({}, classes.label, true), classes.emptyLabel, option.value === "" || option.value ===
|
|
259
|
+
var labelClss = (0, _classnames.default)(_defineProperty(_defineProperty({}, classes.label, true), classes.emptyLabel, option.value === "" || option.value === selectEmptyValue));
|
|
249
260
|
var disabled = !!option.disabled;
|
|
250
261
|
var groupHeader = !!option.isGroupHeader;
|
|
251
262
|
if (groupHeader) {
|
|
@@ -332,6 +343,7 @@ var _default3 = exports.default = _default2;
|
|
|
332
343
|
reactHotLoader.register(getIconButtonMenuProps, "getIconButtonMenuProps", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
333
344
|
reactHotLoader.register(SelectIcon, "SelectIcon", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
334
345
|
reactHotLoader.register(SelectIconButton, "SelectIconButton", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
346
|
+
reactHotLoader.register(selectEmptyValue, "selectEmptyValue", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
335
347
|
reactHotLoader.register(Select, "Select", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
336
348
|
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
337
349
|
})();
|
|
@@ -351,6 +363,7 @@ var _default3 = exports.default = _default2;
|
|
|
351
363
|
reactHotLoader.register(getIconButtonMenuProps, "getIconButtonMenuProps", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
352
364
|
reactHotLoader.register(SelectIcon, "SelectIcon", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
353
365
|
reactHotLoader.register(SelectIconButton, "SelectIconButton", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
366
|
+
reactHotLoader.register(selectEmptyValue, "selectEmptyValue", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
354
367
|
reactHotLoader.register(Select, "Select", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
355
368
|
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/Select.js");
|
|
356
369
|
})();
|
|
@@ -26,7 +26,8 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
26
26
|
var sortTypeEnum = exports.sortTypeEnum = {
|
|
27
27
|
none: 0,
|
|
28
28
|
default: 1,
|
|
29
|
-
numeric: 2
|
|
29
|
+
numeric: 2,
|
|
30
|
+
alphabetical: 3
|
|
30
31
|
};
|
|
31
32
|
var SelectProps = /*#__PURE__*/function (_ComponentProps) {
|
|
32
33
|
function SelectProps() {
|
|
@@ -186,7 +186,7 @@ var SegmentPage = function SegmentPage(_ref4) {
|
|
|
186
186
|
modulePrependPath = _ref4.modulePrependPath,
|
|
187
187
|
entityIdResolver = _ref4.entityIdResolver;
|
|
188
188
|
var classes = useStyles({
|
|
189
|
-
isComponentNull:
|
|
189
|
+
isComponentNull: !View
|
|
190
190
|
});
|
|
191
191
|
var pattern = new _urlPattern.default(path);
|
|
192
192
|
var baseHref = pattern.stringify(match.params);
|
|
@@ -22,7 +22,10 @@ if ("".normalize) {
|
|
|
22
22
|
normalizeForSearch = function normalizeForSearch(str) {
|
|
23
23
|
return str.toLowerCase()
|
|
24
24
|
// Strip accents by normalizing to letters + combining chars, then strip all combining chars.
|
|
25
|
-
.normalize("NFKD")
|
|
25
|
+
.normalize("NFKD")
|
|
26
|
+
// Note AD20240801: the new eslint config complains on the next line however I have no idea what it is supposed to do so to be safe I'll disable the warning
|
|
27
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
28
|
+
.replace(/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/g, "");
|
|
26
29
|
};
|
|
27
30
|
} else {
|
|
28
31
|
// IE11 does not support string#normalize(). V. sad for IE users.
|
|
@@ -127,7 +127,7 @@ var getPropertyBagFormattedPrimitiveValue = exports.getPropertyBagFormattedPrimi
|
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
if (dataTypesChecker.isBoolean(propertyBagValue[_constants.serializationTypeKey])) {
|
|
130
|
-
return
|
|
130
|
+
return propertyBagValue.value ? formatMessage(_sharedMessages.default.valueTypeWrapperTrue) : formatMessage(_sharedMessages.default.valueTypeWrapperFalse);
|
|
131
131
|
}
|
|
132
132
|
if (dataTypesChecker.isInteger(propertyBagValue[_constants.serializationTypeKey])) {
|
|
133
133
|
return formatNumber(propertyBagValue.value, 0);
|
|
@@ -153,7 +153,7 @@ var formatNumber = exports.formatNumber = function formatNumber(value, precision
|
|
|
153
153
|
};
|
|
154
154
|
var fixPropertyBagModifiedModel = exports.fixPropertyBagModifiedModel = function fixPropertyBagModifiedModel(model) {
|
|
155
155
|
var fixProfileOperations = function fixProfileOperations(model) {
|
|
156
|
-
if (
|
|
156
|
+
if (Object.prototype.hasOwnProperty.call(model, "profileOperations")) {
|
|
157
157
|
var _model$profileOperati = model.profileOperations,
|
|
158
158
|
profilesToAdd = _model$profileOperati.profilesToAdd,
|
|
159
159
|
profilesToUpdate = _model$profileOperati.profilesToUpdate;
|
|
@@ -198,7 +198,7 @@ var fixPropertyBagEmptyValues = exports.fixPropertyBagEmptyValues = function fix
|
|
|
198
198
|
var modifiedFields = Object.keys(propertyBag);
|
|
199
199
|
modifiedFields.forEach(function (propertyName) {
|
|
200
200
|
var property = propertyBag[propertyName];
|
|
201
|
-
var propertyValue = property && (0, _propertyValidator.isObject)(property) &&
|
|
201
|
+
var propertyValue = property && (0, _propertyValidator.isObject)(property) && Object.prototype.hasOwnProperty.call(property, "value") ? property.value : property;
|
|
202
202
|
if (propertyValue === "") {
|
|
203
203
|
propertyBag[propertyName] = null;
|
|
204
204
|
}
|
|
@@ -48,11 +48,11 @@ function getPropertyOrDefault(obj, property, defaultValue, ignoreCase, startWith
|
|
|
48
48
|
return getPropertyOrDefaultFromMap(obj, property, defaultValue, ignoreCase, startWith);
|
|
49
49
|
}
|
|
50
50
|
if (ignoreCase === false && startWith === false) {
|
|
51
|
-
return
|
|
51
|
+
return Object.prototype.hasOwnProperty.call(obj, property) ? obj[property] : defaultValue;
|
|
52
52
|
}
|
|
53
53
|
var compareFunction = startWith ? caseInsensitiveStartWithCompare : caseInsensitiveCompare;
|
|
54
54
|
for (var prop in obj) {
|
|
55
|
-
if (
|
|
55
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && compareFunction(prop, property)) {
|
|
56
56
|
return obj[prop];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -60,11 +60,11 @@ function getPropertyOrDefault(obj, property, defaultValue, ignoreCase, startWith
|
|
|
60
60
|
}
|
|
61
61
|
var isObjectContainsPropertyWithValue = exports.isObjectContainsPropertyWithValue = function isObjectContainsPropertyWithValue(obj, propertyName, value) {
|
|
62
62
|
if (obj === null || obj === undefined) return false;
|
|
63
|
-
if (
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName] === value) {
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
for (var prop in obj) {
|
|
67
|
-
if (
|
|
67
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
68
68
|
if (isObjectContainsPropertyWithValue(obj[prop], propertyName, value)) return true;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -72,11 +72,11 @@ var isObjectContainsPropertyWithValue = exports.isObjectContainsPropertyWithValu
|
|
|
72
72
|
};
|
|
73
73
|
var isObjectContainsPropertyWithAnyValue = exports.isObjectContainsPropertyWithAnyValue = function isObjectContainsPropertyWithAnyValue(obj, propertyName) {
|
|
74
74
|
if (!obj) return false;
|
|
75
|
-
if (
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName]) {
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
for (var prop in obj) {
|
|
79
|
-
if (
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
80
80
|
if (isObjectContainsPropertyWithAnyValue(obj[prop], propertyName)) return true;
|
|
81
81
|
}
|
|
82
82
|
}
|
package/dist/utils/testUtils.js
CHANGED
|
@@ -43,6 +43,7 @@ var spyOnConsole = exports.spyOnConsole = function spyOnConsole(spyNames) {
|
|
|
43
43
|
spyNames = ["log", "warn", "error"];
|
|
44
44
|
}
|
|
45
45
|
var spiedFuncs;
|
|
46
|
+
// eslint-disable-next-line no-undef
|
|
46
47
|
beforeEach(function () {
|
|
47
48
|
spiedFuncs = spyNames.map(function (funcName) {
|
|
48
49
|
var func = sinon.spy().named("console." + funcName);
|
|
@@ -51,6 +52,7 @@ var spyOnConsole = exports.spyOnConsole = function spyOnConsole(spyNames) {
|
|
|
51
52
|
return oldFunc;
|
|
52
53
|
});
|
|
53
54
|
});
|
|
55
|
+
// eslint-disable-next-line no-undef
|
|
54
56
|
afterEach(function () {
|
|
55
57
|
spiedFuncs.forEach(function (func, index) {
|
|
56
58
|
var name = spyNames[index];
|
|
@@ -117,6 +119,7 @@ var PropStruct = exports.PropStruct = _react.default.forwardRef(function (props,
|
|
|
117
119
|
);
|
|
118
120
|
});
|
|
119
121
|
var ignoreConsoleError = exports.ignoreConsoleError = function ignoreConsoleError(func) {
|
|
122
|
+
// eslint-disable-next-line no-undef
|
|
120
123
|
jest.spyOn(console, "error");
|
|
121
124
|
console.error.mockImplementation(function () {});
|
|
122
125
|
func();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "5.8.0-dev.
|
|
3
|
+
"version": "5.8.0-dev.18",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@testing-library/react": "^10.4.9"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"orc-scripts": "^4.0.0-dev.
|
|
58
|
+
"orc-scripts": "^4.0.0-dev.10",
|
|
59
59
|
"react-number-format": "^5.3.0"
|
|
60
60
|
},
|
|
61
61
|
"sideEffects": false,
|
|
@@ -169,7 +169,9 @@ describe("ConnectedToastList", () => {
|
|
|
169
169
|
try {
|
|
170
170
|
ReactDOM.unmountComponentAtNode(appRoot);
|
|
171
171
|
ReactDOM.unmountComponentAtNode(document.getElementById("toast"));
|
|
172
|
-
} catch
|
|
172
|
+
} catch {
|
|
173
|
+
// don't do anything
|
|
174
|
+
}
|
|
173
175
|
document.body.removeChild(appRoot);
|
|
174
176
|
});
|
|
175
177
|
});
|
|
@@ -13,7 +13,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
13
13
|
|
|
14
14
|
const Badge = ({ children, badge, ...props }) => {
|
|
15
15
|
const classes = useStyles();
|
|
16
|
-
const classProp =
|
|
16
|
+
const classProp = props.classProp?.badge ? props.classProp : classes;
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<BadgeMui overlap="circular" color="primary" max={999} badgeContent={badge} classes={classProp}>
|
|
@@ -145,6 +145,8 @@ export const SelectIconButton = props => {
|
|
|
145
145
|
);
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
const selectEmptyValue = "~~#~~";
|
|
149
|
+
|
|
148
150
|
const Select = ({ options, selectProps, children }) => {
|
|
149
151
|
if (isSelectProps(selectProps) === false) {
|
|
150
152
|
throw new TypeError("selectProps property is not of type SelectProps");
|
|
@@ -177,6 +179,16 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
177
179
|
);
|
|
178
180
|
} else if (sortType === sortTypeEnum.default) {
|
|
179
181
|
options.sort((a, b) => (a.sortOrder > b.sortOrder ? 1 : -1));
|
|
182
|
+
} else if (sortType === sortTypeEnum.alphabetical) {
|
|
183
|
+
options.sort((a, b) => {
|
|
184
|
+
if (a.value === selectEmptyValue) {
|
|
185
|
+
return -1;
|
|
186
|
+
}
|
|
187
|
+
if (b.value === selectEmptyValue) {
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
return a.label.localeCompare(b.label);
|
|
191
|
+
});
|
|
180
192
|
}
|
|
181
193
|
|
|
182
194
|
if (showAllValue && showAllLabel) {
|
|
@@ -207,7 +219,7 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
207
219
|
const appliedClasses = classNames(classes.baseItem, clss);
|
|
208
220
|
const labelClss = classNames({
|
|
209
221
|
[classes.label]: true,
|
|
210
|
-
[classes.emptyLabel]: option.value === "" || option.value ===
|
|
222
|
+
[classes.emptyLabel]: option.value === "" || option.value === selectEmptyValue,
|
|
211
223
|
});
|
|
212
224
|
|
|
213
225
|
const disabled = !!option.disabled;
|
|
@@ -496,6 +496,43 @@ describe("Select Component", () => {
|
|
|
496
496
|
expect(optionsKeys, "to equal", ["#All#", "a", "b", "c"]);
|
|
497
497
|
});
|
|
498
498
|
|
|
499
|
+
it("Sorts select options correctly with alphabetical sorting", () => {
|
|
500
|
+
const emptyValue = "~~#~~";
|
|
501
|
+
|
|
502
|
+
const options = [
|
|
503
|
+
{ value: "c", label: "c" },
|
|
504
|
+
{ value: "a", label: "a" },
|
|
505
|
+
{ value: "b", label: "b" },
|
|
506
|
+
{ value: "f", label: "f" },
|
|
507
|
+
{ value: emptyValue, label: "empty" },
|
|
508
|
+
{ value: "h", label: "h" },
|
|
509
|
+
{ value: "g", label: "g" },
|
|
510
|
+
{ value: "e", label: "e" },
|
|
511
|
+
{ value: "d", label: "[d]" },
|
|
512
|
+
];
|
|
513
|
+
|
|
514
|
+
const selectProps = new SelectProps();
|
|
515
|
+
|
|
516
|
+
selectProps.set(SelectProps.propNames.sortType, sortTypeEnum.alphabetical);
|
|
517
|
+
selectProps.set(SelectProps.propNames.value, "b");
|
|
518
|
+
|
|
519
|
+
const component = (
|
|
520
|
+
<TestWrapper stylesProvider muiThemeProvider={{ theme }}>
|
|
521
|
+
<Select options={options} selectProps={selectProps} />
|
|
522
|
+
</TestWrapper>
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
const mountedComponent = mount(component);
|
|
526
|
+
|
|
527
|
+
const test = mountedComponent.find(SelectMUI);
|
|
528
|
+
|
|
529
|
+
const mountedOptions = test.props().children;
|
|
530
|
+
|
|
531
|
+
const optionsKeys = mountedOptions.map(option => option.key);
|
|
532
|
+
|
|
533
|
+
expect(optionsKeys, "to equal", [emptyValue, "d", "a", "b", "c", "e", "f", "g", "h"]);
|
|
534
|
+
});
|
|
535
|
+
|
|
499
536
|
it("Sorts select options correctly with numeric sorting", () => {
|
|
500
537
|
const options = [
|
|
501
538
|
{ value: "BRC-409 - BRC-PROMENADES", label: "BRC-409 - BRC-PROMENADES", sortOrder: "BRC-409 - BRC-PROMENADES" },
|
|
@@ -168,7 +168,7 @@ const SegmentPage = ({
|
|
|
168
168
|
modulePrependPath,
|
|
169
169
|
entityIdResolver,
|
|
170
170
|
}) => {
|
|
171
|
-
const classes = useStyles({ isComponentNull:
|
|
171
|
+
const classes = useStyles({ isComponentNull: !View });
|
|
172
172
|
const pattern = new UrlPattern(path);
|
|
173
173
|
const baseHref = pattern.stringify(match.params);
|
|
174
174
|
const pages = [],
|
|
@@ -121,7 +121,9 @@ beforeEach(() => {
|
|
|
121
121
|
afterEach(() => {
|
|
122
122
|
try {
|
|
123
123
|
ReactDOM.unmountComponentAtNode(appRoot);
|
|
124
|
-
} catch
|
|
124
|
+
} catch {
|
|
125
|
+
// don't do anything
|
|
126
|
+
}
|
|
125
127
|
document.body.removeChild(appRoot);
|
|
126
128
|
document.body.removeChild(modalRoot);
|
|
127
129
|
});
|
|
@@ -6,6 +6,8 @@ if ("".normalize) {
|
|
|
6
6
|
.toLowerCase()
|
|
7
7
|
// Strip accents by normalizing to letters + combining chars, then strip all combining chars.
|
|
8
8
|
.normalize("NFKD")
|
|
9
|
+
// Note AD20240801: the new eslint config complains on the next line however I have no idea what it is supposed to do so to be safe I'll disable the warning
|
|
10
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
9
11
|
.replace(/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/g, "");
|
|
10
12
|
} else {
|
|
11
13
|
// IE11 does not support string#normalize(). V. sad for IE users.
|
|
@@ -149,7 +149,7 @@ export const getPropertyBagFormattedPrimitiveValue = (propertyBagValue, formatMe
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
if (dataTypesChecker.isBoolean(propertyBagValue[serializationTypeKey])) {
|
|
152
|
-
return
|
|
152
|
+
return propertyBagValue.value
|
|
153
153
|
? formatMessage(sharedMessages.valueTypeWrapperTrue)
|
|
154
154
|
: formatMessage(sharedMessages.valueTypeWrapperFalse);
|
|
155
155
|
}
|
|
@@ -182,7 +182,7 @@ export const formatNumber = (value, precision) => Number(value).toFixed(precisio
|
|
|
182
182
|
|
|
183
183
|
export const fixPropertyBagModifiedModel = (model, ...fields) => {
|
|
184
184
|
const fixProfileOperations = model => {
|
|
185
|
-
if (
|
|
185
|
+
if (Object.prototype.hasOwnProperty.call(model, "profileOperations")) {
|
|
186
186
|
let { profilesToAdd, profilesToUpdate } = model.profileOperations;
|
|
187
187
|
if (profilesToAdd) {
|
|
188
188
|
const items = Array.isArray(profilesToAdd) ? profilesToAdd : Object.values(profilesToAdd);
|
|
@@ -224,7 +224,10 @@ export const fixPropertyBagEmptyValues = propertyBag => {
|
|
|
224
224
|
const modifiedFields = Object.keys(propertyBag);
|
|
225
225
|
modifiedFields.forEach(propertyName => {
|
|
226
226
|
let property = propertyBag[propertyName];
|
|
227
|
-
let propertyValue =
|
|
227
|
+
let propertyValue =
|
|
228
|
+
property && isObject(property) && Object.prototype.hasOwnProperty.call(property, "value")
|
|
229
|
+
? property.value
|
|
230
|
+
: property;
|
|
228
231
|
if (propertyValue === "") {
|
|
229
232
|
propertyBag[propertyName] = null;
|
|
230
233
|
}
|
|
@@ -22,13 +22,13 @@ export function getPropertyOrDefault(obj, property, defaultValue, ignoreCase = f
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (ignoreCase === false && startWith === false) {
|
|
25
|
-
return
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(obj, property) ? obj[property] : defaultValue;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const compareFunction = startWith ? caseInsensitiveStartWithCompare : caseInsensitiveCompare;
|
|
29
29
|
|
|
30
30
|
for (let prop in obj) {
|
|
31
|
-
if (
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && compareFunction(prop, property)) {
|
|
32
32
|
return obj[prop];
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -39,12 +39,12 @@ export function getPropertyOrDefault(obj, property, defaultValue, ignoreCase = f
|
|
|
39
39
|
export const isObjectContainsPropertyWithValue = (obj, propertyName, value) => {
|
|
40
40
|
if (obj === null || obj === undefined) return false;
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName] === value) {
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
for (let prop in obj) {
|
|
47
|
-
if (
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
48
48
|
if (isObjectContainsPropertyWithValue(obj[prop], propertyName, value)) return true;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -55,12 +55,12 @@ export const isObjectContainsPropertyWithValue = (obj, propertyName, value) => {
|
|
|
55
55
|
export const isObjectContainsPropertyWithAnyValue = (obj, propertyName) => {
|
|
56
56
|
if (!obj) return false;
|
|
57
57
|
|
|
58
|
-
if (
|
|
58
|
+
if (Object.prototype.hasOwnProperty.call(obj, propertyName) && obj[propertyName]) {
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
for (let prop in obj) {
|
|
63
|
-
if (
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop) && typeof obj[prop] === "object") {
|
|
64
64
|
if (isObjectContainsPropertyWithAnyValue(obj[prop], propertyName)) return true;
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/utils/testUtils.js
CHANGED
|
@@ -15,6 +15,7 @@ const sinon = require("sinon");
|
|
|
15
15
|
/* istanbul ignore next */
|
|
16
16
|
export const spyOnConsole = (spyNames = ["log", "warn", "error"]) => {
|
|
17
17
|
let spiedFuncs;
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
18
19
|
beforeEach(() => {
|
|
19
20
|
spiedFuncs = spyNames.map(funcName => {
|
|
20
21
|
const func = sinon.spy().named("console." + funcName);
|
|
@@ -23,6 +24,7 @@ export const spyOnConsole = (spyNames = ["log", "warn", "error"]) => {
|
|
|
23
24
|
return oldFunc;
|
|
24
25
|
});
|
|
25
26
|
});
|
|
27
|
+
// eslint-disable-next-line no-undef
|
|
26
28
|
afterEach(() => {
|
|
27
29
|
spiedFuncs.forEach((func, index) => {
|
|
28
30
|
const name = spyNames[index];
|
|
@@ -74,34 +76,35 @@ export const PropStruct = React.forwardRef((props, ref) => (
|
|
|
74
76
|
value === undefined || value === null
|
|
75
77
|
? null
|
|
76
78
|
: value === "__ignore"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
? [<Ignore key={"dt-" + key} />, <Ignore key={"dd-" + key} />]
|
|
80
|
+
: [
|
|
81
|
+
<dt key={"dt-" + key}>{`${key}:`}</dt>,
|
|
82
|
+
<dd key={"dd-" + key}>
|
|
83
|
+
{key === "children" ? (
|
|
84
|
+
value
|
|
85
|
+
) : typeof value === "object" ? (
|
|
86
|
+
value["$$typeof"] && value["$$typeof"] === Symbol.for("react.element") ? (
|
|
87
|
+
"React <" + (value.type.name || value.type) + ">"
|
|
88
|
+
) : (
|
|
89
|
+
<PropStruct {...value} />
|
|
90
|
+
)
|
|
91
|
+
) : typeof value === "function" ? (
|
|
92
|
+
"Function"
|
|
93
|
+
) : typeof value === "string" ? (
|
|
94
|
+
`string "${value}"`
|
|
95
|
+
) : typeof value === "symbol" ? (
|
|
96
|
+
`symbol ${value.toString()}`
|
|
86
97
|
) : (
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) : typeof value === "string" ? (
|
|
92
|
-
`string "${value}"`
|
|
93
|
-
) : typeof value === "symbol" ? (
|
|
94
|
-
`symbol ${value.toString()}`
|
|
95
|
-
) : (
|
|
96
|
-
typeof value + " " + value
|
|
97
|
-
)}
|
|
98
|
-
</dd>,
|
|
99
|
-
],
|
|
98
|
+
typeof value + " " + value
|
|
99
|
+
)}
|
|
100
|
+
</dd>,
|
|
101
|
+
],
|
|
100
102
|
)}
|
|
101
103
|
</dl>
|
|
102
104
|
));
|
|
103
105
|
|
|
104
106
|
export const ignoreConsoleError = func => {
|
|
107
|
+
// eslint-disable-next-line no-undef
|
|
105
108
|
jest.spyOn(console, "error");
|
|
106
109
|
console.error.mockImplementation(() => {});
|
|
107
110
|
|