orc-shared 5.7.0-dev.0 → 5.7.0-dev.2
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/Modal.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +2 -3
- package/dist/components/MaterialUI/Inputs/Checkbox.js +3 -4
- package/dist/components/MaterialUI/Inputs/CheckboxGroup.js +5 -6
- package/dist/components/MaterialUI/Inputs/InputBase.js +11 -0
- package/dist/components/MaterialUI/Inputs/Select.js +1 -2
- package/dist/components/MaterialUI/Inputs/StandaloneRadio.js +2 -3
- package/dist/components/MaterialUI/Inputs/createInput.js +3 -4
- package/dist/components/MaterialUI/muiThemes.js +10 -11
- package/dist/components/Routing/SubPage.js +5 -4
- package/dist/constants.js +53 -1
- package/dist/hocs/withToggle.js +1 -2
- package/dist/hooks/useDispatchWithErrorHandling.js +24 -9
- package/dist/reducers/authentication.js +3 -0
- package/dist/sharedMessages.js +8 -0
- package/dist/utils/modelValidationHelper.js +5 -6
- package/dist/utils/propertyBagHelper.js +265 -0
- package/dist/utils/responseProcessingHelper.js +17 -3
- package/package.json +1 -1
- package/src/components/MaterialUI/Inputs/InputBase.js +18 -0
- package/src/components/MaterialUI/Inputs/InputBase.test.js +156 -0
- package/src/components/Routing/SubPage.js +6 -5
- package/src/constants.js +48 -0
- package/src/hooks/useDispatchWithErrorHandling.js +16 -2
- package/src/hooks/useDispatchWithErrorHandling.test.js +15 -13
- package/src/reducers/authentication.js +5 -0
- package/src/reducers/authentication.test.js +81 -0
- package/src/sharedMessages.js +8 -0
- package/src/translations/en-US.json +2 -0
- package/src/translations/fr-CA.json +2 -0
- package/src/utils/propertyBagHelper.js +239 -0
- package/src/utils/propertyBagHelper.test.js +709 -0
- package/src/utils/responseProcessingHelper.js +28 -3
- package/src/utils/responseProcessingHelper.test.js +256 -12
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.toJsonCargo = exports.setRequiredBooleansDefault = exports.isTieredAttribute = exports.getPropertyBagFormattedPrimitiveValue = exports.formatNumber = exports.fixPropertyBagModifiedModel = exports.fixPropertyBagEmptyValues = exports.customDataType = exports.createJsonCargo = void 0;
|
|
5
|
+
var _constants = require("../constants");
|
|
6
|
+
var _propertyValidator = require("./propertyValidator");
|
|
7
|
+
var _sharedMessages = _interopRequireDefault(require("../sharedMessages"));
|
|
8
|
+
var _parseHelper = require("./parseHelper");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
(function () {
|
|
11
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
12
|
+
enterModule && enterModule(module);
|
|
13
|
+
})();
|
|
14
|
+
(function () {
|
|
15
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
16
|
+
enterModule && enterModule(module);
|
|
17
|
+
})();
|
|
18
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var customDataType = exports.customDataType = {
|
|
25
|
+
money: "Money",
|
|
26
|
+
priceTieredRateTable: "PriceTieredRateTable",
|
|
27
|
+
quantityTieredRateTable: "QuantityTieredRateTable",
|
|
28
|
+
password: "Password",
|
|
29
|
+
carrierProviderSelector: "CarrierProviderSelector",
|
|
30
|
+
routingProviderSelector: "RoutingProviderSelector",
|
|
31
|
+
multipleCarrierProvidersSelector: "MultipleCarrierProvidersSelector"
|
|
32
|
+
};
|
|
33
|
+
var tieredAttributeTypes = [customDataType.priceTieredRateTable, customDataType.quantityTieredRateTable];
|
|
34
|
+
var isTieredAttribute = exports.isTieredAttribute = function isTieredAttribute(attribute) {
|
|
35
|
+
return tieredAttributeTypes.includes(attribute.customDataType);
|
|
36
|
+
};
|
|
37
|
+
var buildValueOfType = function buildValueOfType(cargoType) {
|
|
38
|
+
return "ValueOf".concat(cargoType);
|
|
39
|
+
};
|
|
40
|
+
var buildValueContainerOfType = function buildValueContainerOfType(dotNetType) {
|
|
41
|
+
return "Orckestra.Overture.Entities.ValueContainer`1[[".concat(dotNetType, ", mscorlib]], Orckestra.Overture.Entities");
|
|
42
|
+
};
|
|
43
|
+
var createJsonCargo = exports.createJsonCargo = function createJsonCargo(cargoType, value) {
|
|
44
|
+
return {
|
|
45
|
+
__type: buildValueOfType(cargoType),
|
|
46
|
+
value: value
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var createTieredTableJsonCargo = function createTieredTableJsonCargo(tiers) {
|
|
50
|
+
return {
|
|
51
|
+
__type: "Orckestra.Overture.Entities.Orders.TieredRateTable, Orckestra.Overture.Entities",
|
|
52
|
+
tiers: tiers.filter(function (tier) {
|
|
53
|
+
var _tier$min;
|
|
54
|
+
return ((_tier$min = tier == null ? void 0 : tier.min) != null ? _tier$min : "") !== "";
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var toJsonCargo = exports.toJsonCargo = function toJsonCargo(attribute, value) {
|
|
59
|
+
switch (attribute.dataType) {
|
|
60
|
+
case _constants.attributeDataType.text:
|
|
61
|
+
case _constants.attributeDataType.lookup:
|
|
62
|
+
return value;
|
|
63
|
+
case _constants.attributeDataType.boolean:
|
|
64
|
+
return createJsonCargo(_constants.jsonCargoType.boolean, value);
|
|
65
|
+
case _constants.attributeDataType.integer:
|
|
66
|
+
return createJsonCargo(_constants.jsonCargoType.integer, Number(formatNumber(value, 0)));
|
|
67
|
+
case _constants.attributeDataType.decimal:
|
|
68
|
+
return createJsonCargo(_constants.jsonCargoType.double, Number(value));
|
|
69
|
+
case _constants.attributeDataType.dateTime:
|
|
70
|
+
return createJsonCargo(_constants.jsonCargoType.dateTime, value);
|
|
71
|
+
case _constants.attributeDataType.customType:
|
|
72
|
+
switch (attribute.customDataType) {
|
|
73
|
+
case customDataType.money:
|
|
74
|
+
return createJsonCargo(_constants.jsonCargoType.double, Number(formatNumber(value, 2)));
|
|
75
|
+
case customDataType.priceTieredRateTable:
|
|
76
|
+
case customDataType.quantityTieredRateTable:
|
|
77
|
+
return createTieredTableJsonCargo(value);
|
|
78
|
+
case customDataType.password:
|
|
79
|
+
case customDataType.carrierProviderSelector: // To be properly handled when user story 61801 will be addressed
|
|
80
|
+
case customDataType.routingProviderSelector: // To be properly handled when user story 61801 will be addressed
|
|
81
|
+
case customDataType.multipleCarrierProvidersSelector:
|
|
82
|
+
// To be properly handled when user story 61801 will be addressed
|
|
83
|
+
return value;
|
|
84
|
+
default:
|
|
85
|
+
throw new Error("toJsonCargo: attribute.customDataType ".concat(attribute.customDataType, " is not implemented"));
|
|
86
|
+
}
|
|
87
|
+
case _constants.attributeDataType.entityReference:
|
|
88
|
+
return createJsonCargo(_constants.jsonCargoType.entityReferences, value);
|
|
89
|
+
default:
|
|
90
|
+
throw new Error("toJsonCargo: attribute.dataType ".concat(attribute.dataType, " is not implemented"));
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var dataTypesChecker = {
|
|
94
|
+
booleanDataTypes: [buildValueOfType(_constants.propertyBagPrimitiveDataType.boolean), buildValueContainerOfType(_constants.dotNetDataTypes.boolean)],
|
|
95
|
+
integerDataTypes: [buildValueOfType(_constants.propertyBagPrimitiveDataType.byte), buildValueContainerOfType(_constants.dotNetDataTypes.byte), buildValueOfType(_constants.propertyBagPrimitiveDataType.sbyte), buildValueContainerOfType(_constants.dotNetDataTypes.sbyte), buildValueOfType(_constants.propertyBagPrimitiveDataType.int16), buildValueContainerOfType(_constants.dotNetDataTypes.int16), buildValueOfType(_constants.propertyBagPrimitiveDataType.uint16), buildValueContainerOfType(_constants.dotNetDataTypes.uint16), buildValueOfType(_constants.propertyBagPrimitiveDataType.int32), buildValueContainerOfType(_constants.dotNetDataTypes.int32), buildValueOfType(_constants.propertyBagPrimitiveDataType.uint32), buildValueContainerOfType(_constants.dotNetDataTypes.uint32), buildValueOfType(_constants.propertyBagPrimitiveDataType.int64), buildValueContainerOfType(_constants.dotNetDataTypes.int64), buildValueOfType(_constants.propertyBagPrimitiveDataType.uint64), buildValueContainerOfType(_constants.dotNetDataTypes.uint64)],
|
|
96
|
+
textDataTypes: [buildValueOfType(_constants.propertyBagPrimitiveDataType.char), buildValueContainerOfType(_constants.dotNetDataTypes.char), buildValueOfType(_constants.propertyBagPrimitiveDataType.string), buildValueContainerOfType(_constants.dotNetDataTypes.string)],
|
|
97
|
+
decimalDataTypes: [buildValueOfType(_constants.propertyBagPrimitiveDataType.single), buildValueContainerOfType(_constants.dotNetDataTypes.single), buildValueOfType(_constants.propertyBagPrimitiveDataType.double), buildValueContainerOfType(_constants.dotNetDataTypes.double), buildValueOfType(_constants.propertyBagPrimitiveDataType.decimal), buildValueContainerOfType(_constants.dotNetDataTypes.decimal)],
|
|
98
|
+
dateTimeDataTypes: [buildValueOfType(_constants.propertyBagPrimitiveDataType.dateTime), buildValueContainerOfType(_constants.dotNetDataTypes.dateTime)],
|
|
99
|
+
guidDataTypes: [buildValueOfType(_constants.propertyBagPrimitiveDataType.guid), buildValueContainerOfType(_constants.dotNetDataTypes.guid)],
|
|
100
|
+
isBoolean: function isBoolean(type) {
|
|
101
|
+
return dataTypesChecker.booleanDataTypes.includes(type);
|
|
102
|
+
},
|
|
103
|
+
isInteger: function isInteger(type) {
|
|
104
|
+
return dataTypesChecker.integerDataTypes.includes(type);
|
|
105
|
+
},
|
|
106
|
+
isText: function isText(type) {
|
|
107
|
+
return dataTypesChecker.textDataTypes.includes(type);
|
|
108
|
+
},
|
|
109
|
+
isDecimal: function isDecimal(type) {
|
|
110
|
+
return dataTypesChecker.decimalDataTypes.includes(type);
|
|
111
|
+
},
|
|
112
|
+
isDateTime: function isDateTime(type) {
|
|
113
|
+
return dataTypesChecker.dateTimeDataTypes.includes(type);
|
|
114
|
+
},
|
|
115
|
+
isGuid: function isGuid(type) {
|
|
116
|
+
return dataTypesChecker.guidDataTypes.includes(type);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var getPropertyBagFormattedPrimitiveValue = exports.getPropertyBagFormattedPrimitiveValue = function getPropertyBagFormattedPrimitiveValue(propertyBagValue, formatMessage, formatDate, formatTime) {
|
|
120
|
+
if (propertyBagValue === null || propertyBagValue === undefined || !(0, _propertyValidator.isObject)(propertyBagValue)) {
|
|
121
|
+
return propertyBagValue;
|
|
122
|
+
}
|
|
123
|
+
if (propertyBagValue.value === null || propertyBagValue.value === undefined) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (dataTypesChecker.isBoolean(propertyBagValue[_constants.serializationTypeKey])) {
|
|
127
|
+
return Boolean(propertyBagValue.value) ? formatMessage(_sharedMessages.default.valueTypeWrapperTrue) : formatMessage(_sharedMessages.default.valueTypeWrapperFalse);
|
|
128
|
+
}
|
|
129
|
+
if (dataTypesChecker.isInteger(propertyBagValue[_constants.serializationTypeKey])) {
|
|
130
|
+
return formatNumber(propertyBagValue.value, 0);
|
|
131
|
+
}
|
|
132
|
+
if (dataTypesChecker.isText(propertyBagValue[_constants.serializationTypeKey])) {
|
|
133
|
+
return propertyBagValue.value.toString();
|
|
134
|
+
}
|
|
135
|
+
if (dataTypesChecker.isDecimal(propertyBagValue[_constants.serializationTypeKey])) {
|
|
136
|
+
return formatNumber(propertyBagValue.value, 2);
|
|
137
|
+
}
|
|
138
|
+
if (dataTypesChecker.isDateTime(propertyBagValue[_constants.serializationTypeKey])) {
|
|
139
|
+
return "".concat(formatDate(propertyBagValue.value), " ").concat(formatTime(propertyBagValue.value));
|
|
140
|
+
}
|
|
141
|
+
if (dataTypesChecker.isGuid(propertyBagValue[_constants.serializationTypeKey])) {
|
|
142
|
+
return (0, _parseHelper.parseGuid)(propertyBagValue.value);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// we ignore other data types since we have no way to format them
|
|
146
|
+
return null;
|
|
147
|
+
};
|
|
148
|
+
var formatNumber = exports.formatNumber = function formatNumber(value, precision) {
|
|
149
|
+
return Number(value).toFixed(precision);
|
|
150
|
+
};
|
|
151
|
+
var fixPropertyBagModifiedModel = exports.fixPropertyBagModifiedModel = function fixPropertyBagModifiedModel(model) {
|
|
152
|
+
var fixProfileOperations = function fixProfileOperations(model) {
|
|
153
|
+
if (model.hasOwnProperty("profileOperations")) {
|
|
154
|
+
var _model$profileOperati = model.profileOperations,
|
|
155
|
+
profilesToAdd = _model$profileOperati.profilesToAdd,
|
|
156
|
+
profilesToUpdate = _model$profileOperati.profilesToUpdate;
|
|
157
|
+
if (profilesToAdd) {
|
|
158
|
+
var items = Array.isArray(profilesToAdd) ? profilesToAdd : Object.values(profilesToAdd);
|
|
159
|
+
items.forEach(function (pr) {
|
|
160
|
+
fixPropertyBagEmptyValues(pr.propertyBag);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (profilesToUpdate) {
|
|
164
|
+
var _items = Array.isArray(profilesToUpdate) ? profilesToUpdate : Object.values(profilesToUpdate);
|
|
165
|
+
_items.forEach(function (pr) {
|
|
166
|
+
fixPropertyBagEmptyValues(pr.propertyBag);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
fixPropertyBagEmptyValues(model.propertyBag);
|
|
172
|
+
fixProfileOperations(model);
|
|
173
|
+
for (var _len = arguments.length, fields = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
174
|
+
fields[_key - 1] = arguments[_key];
|
|
175
|
+
}
|
|
176
|
+
fields.forEach(function (field) {
|
|
177
|
+
var _model$field;
|
|
178
|
+
var fieldValue = (_model$field = model[field]) == null ? void 0 : _model$field.value;
|
|
179
|
+
if (!fieldValue) return;
|
|
180
|
+
if (Array.isArray(fieldValue)) {
|
|
181
|
+
fieldValue.forEach(function (fieldItem) {
|
|
182
|
+
fixPropertyBagEmptyValues(fieldItem.propertyBag);
|
|
183
|
+
fixProfileOperations(fieldItem);
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
fixPropertyBagEmptyValues(fieldValue.propertyBag);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
var fixPropertyBagEmptyValues = exports.fixPropertyBagEmptyValues = function fixPropertyBagEmptyValues(propertyBag) {
|
|
191
|
+
if (!propertyBag) return;
|
|
192
|
+
//we need to pass null to backend to remove attribute instead of empty string
|
|
193
|
+
//in case if attribute has validation for min length and when we will pass empty string, then we will get error from platform
|
|
194
|
+
//in case if DateTime attribute has empty value Backend will transform it to some '01/01/1900' date, so we need to pass null
|
|
195
|
+
var modifiedFields = Object.keys(propertyBag);
|
|
196
|
+
modifiedFields.forEach(function (propertyName) {
|
|
197
|
+
var property = propertyBag[propertyName];
|
|
198
|
+
var propertyValue = property && (0, _propertyValidator.isObject)(property) && property.hasOwnProperty("value") ? property.value : property;
|
|
199
|
+
if (propertyValue === "") {
|
|
200
|
+
propertyBag[propertyName] = null;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
var setRequiredBooleansDefault = exports.setRequiredBooleansDefault = function setRequiredBooleansDefault(attributes, propertyBag) {
|
|
205
|
+
var requiredBools = attributes.filter(function (a) {
|
|
206
|
+
return a.isRequired && a.dataType === _constants.attributeDataType.boolean;
|
|
207
|
+
});
|
|
208
|
+
requiredBools.forEach(function (attr) {
|
|
209
|
+
if (!propertyBag[attr.name]) {
|
|
210
|
+
propertyBag[attr.name] = toJsonCargo(attr, false);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
;
|
|
215
|
+
(function () {
|
|
216
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
217
|
+
if (!reactHotLoader) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
reactHotLoader.register(customDataType, "customDataType", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
221
|
+
reactHotLoader.register(tieredAttributeTypes, "tieredAttributeTypes", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
222
|
+
reactHotLoader.register(isTieredAttribute, "isTieredAttribute", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
223
|
+
reactHotLoader.register(buildValueOfType, "buildValueOfType", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
224
|
+
reactHotLoader.register(buildValueContainerOfType, "buildValueContainerOfType", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
225
|
+
reactHotLoader.register(createJsonCargo, "createJsonCargo", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
226
|
+
reactHotLoader.register(createTieredTableJsonCargo, "createTieredTableJsonCargo", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
227
|
+
reactHotLoader.register(toJsonCargo, "toJsonCargo", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
228
|
+
reactHotLoader.register(dataTypesChecker, "dataTypesChecker", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
229
|
+
reactHotLoader.register(getPropertyBagFormattedPrimitiveValue, "getPropertyBagFormattedPrimitiveValue", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
230
|
+
reactHotLoader.register(formatNumber, "formatNumber", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
231
|
+
reactHotLoader.register(fixPropertyBagModifiedModel, "fixPropertyBagModifiedModel", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
232
|
+
reactHotLoader.register(fixPropertyBagEmptyValues, "fixPropertyBagEmptyValues", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
233
|
+
reactHotLoader.register(setRequiredBooleansDefault, "setRequiredBooleansDefault", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
234
|
+
})();
|
|
235
|
+
;
|
|
236
|
+
(function () {
|
|
237
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
238
|
+
leaveModule && leaveModule(module);
|
|
239
|
+
})();
|
|
240
|
+
;
|
|
241
|
+
(function () {
|
|
242
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
243
|
+
if (!reactHotLoader) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
reactHotLoader.register(customDataType, "customDataType", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
247
|
+
reactHotLoader.register(tieredAttributeTypes, "tieredAttributeTypes", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
248
|
+
reactHotLoader.register(isTieredAttribute, "isTieredAttribute", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
249
|
+
reactHotLoader.register(buildValueOfType, "buildValueOfType", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
250
|
+
reactHotLoader.register(buildValueContainerOfType, "buildValueContainerOfType", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
251
|
+
reactHotLoader.register(createJsonCargo, "createJsonCargo", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
252
|
+
reactHotLoader.register(createTieredTableJsonCargo, "createTieredTableJsonCargo", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
253
|
+
reactHotLoader.register(toJsonCargo, "toJsonCargo", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
254
|
+
reactHotLoader.register(dataTypesChecker, "dataTypesChecker", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
255
|
+
reactHotLoader.register(getPropertyBagFormattedPrimitiveValue, "getPropertyBagFormattedPrimitiveValue", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
256
|
+
reactHotLoader.register(formatNumber, "formatNumber", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
257
|
+
reactHotLoader.register(fixPropertyBagModifiedModel, "fixPropertyBagModifiedModel", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
258
|
+
reactHotLoader.register(fixPropertyBagEmptyValues, "fixPropertyBagEmptyValues", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
259
|
+
reactHotLoader.register(setRequiredBooleansDefault, "setRequiredBooleansDefault", "/home/vsts/work/1/s/src/utils/propertyBagHelper.js");
|
|
260
|
+
})();
|
|
261
|
+
;
|
|
262
|
+
(function () {
|
|
263
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
264
|
+
leaveModule && leaveModule(module);
|
|
265
|
+
})();
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.extractStandardErrorMessagesFromResponse = void 0;
|
|
5
|
+
var _propertyBagHelper = require("./propertyBagHelper");
|
|
5
6
|
(function () {
|
|
6
7
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
7
8
|
enterModule && enterModule(module);
|
|
@@ -16,7 +17,17 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
16
17
|
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
17
18
|
return a;
|
|
18
19
|
};
|
|
19
|
-
var
|
|
20
|
+
var parseFailureContext = function parseFailureContext(context, formatMessage, formatDate, formatTime) {
|
|
21
|
+
if (!context) {
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
var newContext = {};
|
|
25
|
+
Object.keys(context).forEach(function (key) {
|
|
26
|
+
newContext[key] = (0, _propertyBagHelper.getPropertyBagFormattedPrimitiveValue)(context[key], formatMessage, formatDate, formatTime);
|
|
27
|
+
});
|
|
28
|
+
return newContext;
|
|
29
|
+
};
|
|
30
|
+
var extractStandardErrorMessagesFromResponse = exports.extractStandardErrorMessagesFromResponse = function extractStandardErrorMessagesFromResponse(response, validationLookupModule, validationLookupName, formatMessage, formatDate, formatTime, lookupKeyCustomizer) {
|
|
20
31
|
var hasErrors = false;
|
|
21
32
|
var messages = [];
|
|
22
33
|
if (response != null && response.error) {
|
|
@@ -32,7 +43,8 @@ var extractStandardErrorMessagesFromResponse = exports.extractStandardErrorMessa
|
|
|
32
43
|
message: failure.errorMessage,
|
|
33
44
|
lookupModule: validationLookupModule,
|
|
34
45
|
lookupName: validationLookupName,
|
|
35
|
-
lookupKey: failure.errorCode
|
|
46
|
+
lookupKey: lookupKeyCustomizer ? lookupKeyCustomizer(failure.errorCode) : failure.errorCode,
|
|
47
|
+
lookupReplacementValues: parseFailureContext(failure.context, formatMessage, formatDate, formatTime)
|
|
36
48
|
});
|
|
37
49
|
}
|
|
38
50
|
});
|
|
@@ -46,7 +58,7 @@ var extractStandardErrorMessagesFromResponse = exports.extractStandardErrorMessa
|
|
|
46
58
|
message: err.message,
|
|
47
59
|
lookupModule: err.lookupModule,
|
|
48
60
|
lookupName: err.lookupName,
|
|
49
|
-
lookupKey: err.lookupKey,
|
|
61
|
+
lookupKey: lookupKeyCustomizer ? lookupKeyCustomizer(err.lookupKey) : err.lookupKey,
|
|
50
62
|
lookupReplacementValues: err.lookupReplacementValues
|
|
51
63
|
});
|
|
52
64
|
});
|
|
@@ -64,6 +76,7 @@ var extractStandardErrorMessagesFromResponse = exports.extractStandardErrorMessa
|
|
|
64
76
|
if (!reactHotLoader) {
|
|
65
77
|
return;
|
|
66
78
|
}
|
|
79
|
+
reactHotLoader.register(parseFailureContext, "parseFailureContext", "/home/vsts/work/1/s/src/utils/responseProcessingHelper.js");
|
|
67
80
|
reactHotLoader.register(extractStandardErrorMessagesFromResponse, "extractStandardErrorMessagesFromResponse", "/home/vsts/work/1/s/src/utils/responseProcessingHelper.js");
|
|
68
81
|
})();
|
|
69
82
|
;
|
|
@@ -77,6 +90,7 @@ var extractStandardErrorMessagesFromResponse = exports.extractStandardErrorMessa
|
|
|
77
90
|
if (!reactHotLoader) {
|
|
78
91
|
return;
|
|
79
92
|
}
|
|
93
|
+
reactHotLoader.register(parseFailureContext, "parseFailureContext", "/home/vsts/work/1/s/src/utils/responseProcessingHelper.js");
|
|
80
94
|
reactHotLoader.register(extractStandardErrorMessagesFromResponse, "extractStandardErrorMessagesFromResponse", "/home/vsts/work/1/s/src/utils/responseProcessingHelper.js");
|
|
81
95
|
})();
|
|
82
96
|
;
|
package/package.json
CHANGED
|
@@ -137,6 +137,24 @@ const InputBase = ({ inputProps }) => {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
if (isAdvancedNumericInput) {
|
|
141
|
+
if (inputAttributes.max === undefined) {
|
|
142
|
+
inputAttributes.max = 2147483647;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (inputAttributes.min === undefined) {
|
|
146
|
+
inputAttributes.min = -2147483648;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
inputAttributes.isAllowed = val => {
|
|
150
|
+
return (
|
|
151
|
+
val.value === "" ||
|
|
152
|
+
val.value === "-" ||
|
|
153
|
+
(val.floatValue >= inputAttributes.min && val.floatValue <= inputAttributes.max)
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
140
158
|
const defaultRows = 4;
|
|
141
159
|
let rows = rowsProps;
|
|
142
160
|
if (rows === null || rows === undefined) rows = defaultRows;
|
|
@@ -685,4 +685,160 @@ describe("AdvancedNumericInput", () => {
|
|
|
685
685
|
|
|
686
686
|
// no idea what to assert here, this test is mostly for code coverage
|
|
687
687
|
});
|
|
688
|
+
|
|
689
|
+
it("Change advanced numeric input value with min value out of default bounds", () => {
|
|
690
|
+
const inputProps = new InputBaseProps();
|
|
691
|
+
const aLabel = "aLabel";
|
|
692
|
+
const aValue = "12.2";
|
|
693
|
+
const metadata = {
|
|
694
|
+
test: "value",
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
698
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
699
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
700
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
701
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
702
|
+
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
703
|
+
|
|
704
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
705
|
+
const mountedComponent = mount(component);
|
|
706
|
+
const input = mountedComponent.find("input");
|
|
707
|
+
input.simulate("change", { target: { value: "-3147483648", focus: noop } });
|
|
708
|
+
|
|
709
|
+
expect(update, "not to have calls satisfying", [{ args: ["-3147483648", metadata] }]);
|
|
710
|
+
|
|
711
|
+
input.simulate("change", { target: { value: "-111", focus: noop } });
|
|
712
|
+
expect(update, "to have calls satisfying", [{ args: ["-111", metadata] }]);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
it("Change advanced numeric input value with min value out of specified bounds", () => {
|
|
716
|
+
const inputProps = new InputBaseProps();
|
|
717
|
+
const aLabel = "aLabel";
|
|
718
|
+
const aValue = "12.2";
|
|
719
|
+
const metadata = {
|
|
720
|
+
test: "value",
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
724
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
725
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
726
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
727
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
728
|
+
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
729
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, {
|
|
730
|
+
min: -100,
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
734
|
+
const mountedComponent = mount(component);
|
|
735
|
+
const input = mountedComponent.find("input");
|
|
736
|
+
input.simulate("change", { target: { value: "-2000", focus: noop } });
|
|
737
|
+
|
|
738
|
+
expect(update, "not to have calls satisfying", [{ args: ["-2000", metadata] }]);
|
|
739
|
+
|
|
740
|
+
input.simulate("change", { target: { value: "-11", focus: noop } });
|
|
741
|
+
expect(update, "to have calls satisfying", [{ args: ["-11", metadata] }]);
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
it("Change advanced numeric input value with max value out of default bounds", () => {
|
|
745
|
+
const inputProps = new InputBaseProps();
|
|
746
|
+
const aLabel = "aLabel";
|
|
747
|
+
const aValue = "12.2";
|
|
748
|
+
const metadata = {
|
|
749
|
+
test: "value",
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
753
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
754
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
755
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
756
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
757
|
+
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
758
|
+
|
|
759
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
760
|
+
const mountedComponent = mount(component);
|
|
761
|
+
const input = mountedComponent.find("input");
|
|
762
|
+
input.simulate("change", { target: { value: "3147483648", focus: noop } });
|
|
763
|
+
|
|
764
|
+
expect(update, "not to have calls satisfying", [{ args: ["3147483648", metadata] }]);
|
|
765
|
+
|
|
766
|
+
input.simulate("change", { target: { value: "111", focus: noop } });
|
|
767
|
+
expect(update, "to have calls satisfying", [{ args: ["111", metadata] }]);
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
it("Change advanced numeric input value with max value out of specified bounds", () => {
|
|
771
|
+
const inputProps = new InputBaseProps();
|
|
772
|
+
const aLabel = "aLabel";
|
|
773
|
+
const aValue = "12.2";
|
|
774
|
+
const metadata = {
|
|
775
|
+
test: "value",
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
779
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
780
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
781
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
782
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
783
|
+
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
784
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, {
|
|
785
|
+
max: 100,
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
789
|
+
const mountedComponent = mount(component);
|
|
790
|
+
const input = mountedComponent.find("input");
|
|
791
|
+
input.simulate("change", { target: { value: "2000", focus: noop } });
|
|
792
|
+
|
|
793
|
+
expect(update, "not to have calls satisfying", [{ args: ["2000", metadata] }]);
|
|
794
|
+
|
|
795
|
+
input.simulate("change", { target: { value: "11", focus: noop } });
|
|
796
|
+
expect(update, "to have calls satisfying", [{ args: ["11", metadata] }]);
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
it("Change advanced numeric input value: dash is allowed", () => {
|
|
800
|
+
const inputProps = new InputBaseProps();
|
|
801
|
+
const aLabel = "aLabel";
|
|
802
|
+
const aValue = "12.2";
|
|
803
|
+
const metadata = {
|
|
804
|
+
test: "value",
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
808
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
809
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
810
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
811
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
812
|
+
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
813
|
+
|
|
814
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
815
|
+
const mountedComponent = mount(component);
|
|
816
|
+
const input = mountedComponent.find("input");
|
|
817
|
+
input.simulate("change", { target: { value: "-", focus: noop } });
|
|
818
|
+
|
|
819
|
+
expect(update, "to have calls satisfying", [{ args: ["-", metadata] }]);
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
it("Change advanced numeric input value: empty value is allowed", () => {
|
|
823
|
+
const inputProps = new InputBaseProps();
|
|
824
|
+
const aLabel = "aLabel";
|
|
825
|
+
const aValue = "12.2";
|
|
826
|
+
const metadata = {
|
|
827
|
+
test: "value",
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
831
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
832
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
833
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
834
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
835
|
+
inputProps.set(InputBaseProps.propNames.metadata, metadata);
|
|
836
|
+
|
|
837
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
838
|
+
const mountedComponent = mount(component);
|
|
839
|
+
const input = mountedComponent.find("input");
|
|
840
|
+
input.simulate("change", { target: { value: "", focus: noop } });
|
|
841
|
+
|
|
842
|
+
expect(update, "to have calls satisfying", [{ args: ["", metadata] }]);
|
|
843
|
+
});
|
|
688
844
|
});
|
|
@@ -47,11 +47,12 @@ export const SubPage = ({ config, match, location, history, root, modulePrependP
|
|
|
47
47
|
|
|
48
48
|
const modalProps = new ModalProps();
|
|
49
49
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const formattedMsgProps = {
|
|
51
|
+
id: props?.title?.id,
|
|
52
|
+
defaultMessage: props?.title?.defaultMessage,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const titleComponent = props?.title?.id ? <FormattedMessage {...formattedMsgProps} /> : props?.title;
|
|
55
56
|
|
|
56
57
|
modalProps.set(ModalProps.propNames.title, titleComponent);
|
|
57
58
|
modalProps.set(ModalProps.propNames.open, true);
|
package/src/constants.js
CHANGED
|
@@ -120,3 +120,51 @@ export const taskStatuses = {
|
|
|
120
120
|
ignored: "Ignored",
|
|
121
121
|
queuedForSequence: "QueuedForSequence",
|
|
122
122
|
};
|
|
123
|
+
|
|
124
|
+
export const propertyBagPrimitiveDataType = {
|
|
125
|
+
boolean: "Boolean",
|
|
126
|
+
byte: "Byte",
|
|
127
|
+
sbyte: "SByte",
|
|
128
|
+
int16: "Int16",
|
|
129
|
+
uint16: "UInt16",
|
|
130
|
+
int32: "Int32",
|
|
131
|
+
uint32: "UInt32",
|
|
132
|
+
int64: "Int64",
|
|
133
|
+
uint64: "UInt64",
|
|
134
|
+
single: "Single",
|
|
135
|
+
double: "Double",
|
|
136
|
+
decimal: "Decimal",
|
|
137
|
+
dateTime: "DateTime",
|
|
138
|
+
char: "Char",
|
|
139
|
+
string: "String",
|
|
140
|
+
guid: "Guid",
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const dotNetDataTypes = {
|
|
144
|
+
boolean: "System.Boolean",
|
|
145
|
+
byte: "System.Byte",
|
|
146
|
+
sbyte: "System.SByte",
|
|
147
|
+
int16: "System.Int16",
|
|
148
|
+
uint16: "System.UInt16",
|
|
149
|
+
int32: "System.Int32",
|
|
150
|
+
uint32: "System.UInt32",
|
|
151
|
+
int64: "System.Int64",
|
|
152
|
+
uint64: "System.UInt64",
|
|
153
|
+
single: "System.Single",
|
|
154
|
+
double: "System.Double",
|
|
155
|
+
decimal: "System.Decimal",
|
|
156
|
+
dateTime: "System.DateTime",
|
|
157
|
+
char: "System.Char",
|
|
158
|
+
string: "System.String",
|
|
159
|
+
guid: "System.Guid",
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const serializationTypeKey = "__type";
|
|
163
|
+
|
|
164
|
+
export const jsonCargoType = {
|
|
165
|
+
boolean: "Boolean",
|
|
166
|
+
double: "Double",
|
|
167
|
+
dateTime: "DateTime",
|
|
168
|
+
integer: "Int32",
|
|
169
|
+
entityReferences: "Guid[]",
|
|
170
|
+
};
|
|
@@ -2,6 +2,7 @@ import { useDispatch } from "react-redux";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { extractStandardErrorMessagesFromResponse } from "../utils/responseProcessingHelper";
|
|
4
4
|
import { pushGlobalErrorMessage } from "../actions/globalErrorMessages";
|
|
5
|
+
import { useIntl } from "react-intl";
|
|
5
6
|
|
|
6
7
|
export const executeDispatchWithErrorHandling = ({
|
|
7
8
|
dispatch,
|
|
@@ -10,12 +11,20 @@ export const executeDispatchWithErrorHandling = ({
|
|
|
10
11
|
errorDescription,
|
|
11
12
|
validationLookupModule,
|
|
12
13
|
validationLookupName,
|
|
14
|
+
formatMessage,
|
|
15
|
+
formatDate,
|
|
16
|
+
formatTime,
|
|
17
|
+
lookupKeyCustomizer = null,
|
|
13
18
|
}) => {
|
|
14
19
|
return dispatch(action).then(data => {
|
|
15
20
|
const extractedMessages = extractStandardErrorMessagesFromResponse(
|
|
16
21
|
data,
|
|
17
22
|
validationLookupModule,
|
|
18
23
|
validationLookupName,
|
|
24
|
+
formatMessage,
|
|
25
|
+
formatDate,
|
|
26
|
+
formatTime,
|
|
27
|
+
lookupKeyCustomizer,
|
|
19
28
|
);
|
|
20
29
|
if (extractedMessages.hasErrors) {
|
|
21
30
|
const newMsg = {
|
|
@@ -38,9 +47,10 @@ export const executeDispatchWithErrorHandling = ({
|
|
|
38
47
|
|
|
39
48
|
export const useDispatchWithErrorHandling = () => {
|
|
40
49
|
const dispatch = useDispatch();
|
|
50
|
+
const { formatMessage, formatDate, formatTime } = useIntl();
|
|
41
51
|
|
|
42
52
|
return useCallback(
|
|
43
|
-
({ action, errorTitle, errorDescription, validationLookupModule, validationLookupName }) => {
|
|
53
|
+
({ action, errorTitle, errorDescription, validationLookupModule, validationLookupName, lookupKeyCustomizer }) => {
|
|
44
54
|
return executeDispatchWithErrorHandling({
|
|
45
55
|
dispatch,
|
|
46
56
|
action,
|
|
@@ -48,9 +58,13 @@ export const useDispatchWithErrorHandling = () => {
|
|
|
48
58
|
errorDescription,
|
|
49
59
|
validationLookupModule,
|
|
50
60
|
validationLookupName,
|
|
61
|
+
formatMessage,
|
|
62
|
+
formatDate,
|
|
63
|
+
formatTime,
|
|
64
|
+
lookupKeyCustomizer,
|
|
51
65
|
});
|
|
52
66
|
},
|
|
53
|
-
[dispatch],
|
|
67
|
+
[dispatch, formatDate, formatMessage, formatTime],
|
|
54
68
|
);
|
|
55
69
|
};
|
|
56
70
|
|