orc-shared 5.7.0-dev.5 → 5.7.0-dev.7
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/Inputs/DatePicker.js +4 -2
- package/dist/components/MaterialUI/Inputs/LookupSelect.js +88 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +29 -12
- package/dist/constants.js +4 -1
- package/dist/utils/filterHelper.js +89 -0
- package/package.json +3 -3
- package/src/components/MaterialUI/Inputs/DatePicker.js +8 -1
- package/src/components/MaterialUI/Inputs/LookupSelect.js +26 -0
- package/src/components/MaterialUI/Inputs/LookupSelect.test.js +213 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +19 -10
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +28 -0
- package/src/constants.js +2 -0
- package/src/utils/filterHelper.js +34 -0
- package/src/utils/filterHelper.test.js +109 -0
|
@@ -12,7 +12,7 @@ var _styles = require("@material-ui/core/styles");
|
|
|
12
12
|
var _timezoneHelper = require("../../../utils/timezoneHelper");
|
|
13
13
|
var _metadata = require("../../../selectors/metadata");
|
|
14
14
|
var _reactRedux = require("react-redux");
|
|
15
|
-
var _excluded = ["value", "useTime", "useDate", "onChange", "useTimeZone", "dateFormat", "showTimeZone", "timeInputLabel", "readOnly", "showTimeSelectOnly", "metadata", "timePickerTimeZone", "error"];
|
|
15
|
+
var _excluded = ["value", "useTime", "useDate", "onChange", "useTimeZone", "dateFormat", "showTimeZone", "timeInputLabel", "readOnly", "showTimeSelectOnly", "metadata", "timePickerTimeZone", "error", "timeOption"];
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
(function () {
|
|
18
18
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
@@ -165,6 +165,7 @@ var WrappedDatePicker = function WrappedDatePicker(_ref) {
|
|
|
165
165
|
metadata = _ref.metadata,
|
|
166
166
|
timePickerTimeZone = _ref.timePickerTimeZone,
|
|
167
167
|
error = _ref.error,
|
|
168
|
+
timeOption = _ref.timeOption,
|
|
168
169
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
169
170
|
var classes = useStyles({
|
|
170
171
|
readOnly: readOnly
|
|
@@ -194,7 +195,8 @@ var WrappedDatePicker = function WrappedDatePicker(_ref) {
|
|
|
194
195
|
useTime: useTime != null ? useTime : false,
|
|
195
196
|
customTimeInput: useTime ? /*#__PURE__*/_react.default.createElement(_TimePicker.default, {
|
|
196
197
|
showTimeZone: showTimeZone,
|
|
197
|
-
requestedTimeZone: localizedTimeZoneName
|
|
198
|
+
requestedTimeZone: localizedTimeZoneName,
|
|
199
|
+
timeOption: timeOption
|
|
198
200
|
}) : null,
|
|
199
201
|
timeInputLabel: timeInputLabel != null ? timeInputLabel : "",
|
|
200
202
|
readOnly: readOnly,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _reactRedux = require("react-redux");
|
|
6
|
+
var _filterHelper = require("../../../utils/filterHelper");
|
|
7
|
+
var _metadata = require("../../../selectors/metadata");
|
|
8
|
+
var _localizationHelper = require("../../../utils/localizationHelper");
|
|
9
|
+
var _createInput = _interopRequireWildcard(require("./createInput"));
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
(function () {
|
|
13
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
14
|
+
enterModule && enterModule(module);
|
|
15
|
+
})();
|
|
16
|
+
(function () {
|
|
17
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
18
|
+
enterModule && enterModule(module);
|
|
19
|
+
})();
|
|
20
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var LookupSelect = function LookupSelect(_ref) {
|
|
27
|
+
var moduleName = _ref.moduleName,
|
|
28
|
+
lookupName = _ref.lookupName,
|
|
29
|
+
value = _ref.value,
|
|
30
|
+
onChange = _ref.onChange,
|
|
31
|
+
disabled = _ref.disabled,
|
|
32
|
+
metadata = _ref.metadata;
|
|
33
|
+
var options = (0, _filterHelper.extractDropboxOptions)((0, _reactRedux.useSelector)((0, _metadata.namedLookupValuesSelector)(moduleName, lookupName)));
|
|
34
|
+
if (value !== null && !options.some(function (x) {
|
|
35
|
+
return x.value === value;
|
|
36
|
+
})) {
|
|
37
|
+
options.push({
|
|
38
|
+
label: (0, _localizationHelper.getNotLocalizedString)(value),
|
|
39
|
+
value: value,
|
|
40
|
+
sortOrder: 0
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return (0, _createInput.default)(_createInput.inputTypes.select, {
|
|
44
|
+
options: options,
|
|
45
|
+
value: value,
|
|
46
|
+
update: function update(newValue) {
|
|
47
|
+
return onChange(newValue, metadata);
|
|
48
|
+
},
|
|
49
|
+
disabled: disabled
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
__signature__(LookupSelect, "useSelector{}", function () {
|
|
53
|
+
return [_reactRedux.useSelector];
|
|
54
|
+
});
|
|
55
|
+
__signature__(LookupSelect, "useSelector{}", function () {
|
|
56
|
+
return [_reactRedux.useSelector];
|
|
57
|
+
});
|
|
58
|
+
var _default = LookupSelect;
|
|
59
|
+
var _default2 = _default;
|
|
60
|
+
var _default3 = exports.default = _default2;
|
|
61
|
+
;
|
|
62
|
+
(function () {
|
|
63
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
64
|
+
if (!reactHotLoader) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
reactHotLoader.register(LookupSelect, "LookupSelect", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
|
|
68
|
+
reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
|
|
69
|
+
})();
|
|
70
|
+
;
|
|
71
|
+
(function () {
|
|
72
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
73
|
+
leaveModule && leaveModule(module);
|
|
74
|
+
})();
|
|
75
|
+
;
|
|
76
|
+
(function () {
|
|
77
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
78
|
+
if (!reactHotLoader) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
reactHotLoader.register(LookupSelect, "LookupSelect", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
|
|
82
|
+
reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
|
|
83
|
+
})();
|
|
84
|
+
;
|
|
85
|
+
(function () {
|
|
86
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
87
|
+
leaveModule && leaveModule(module);
|
|
88
|
+
})();
|
|
@@ -22,10 +22,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
22
22
|
})();
|
|
23
23
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
24
24
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
-
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); }
|
|
26
|
-
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; }
|
|
27
25
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
28
26
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
+
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); }
|
|
29
|
+
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; }
|
|
29
30
|
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
30
31
|
return a;
|
|
31
32
|
};
|
|
@@ -128,8 +129,17 @@ var calculateHours = function calculateHours(time, showAMPM) {
|
|
|
128
129
|
if (!showAMPM) return time.getHours();
|
|
129
130
|
return time.getHours() === 0 || time.getHours() === 12 ? 12 : time.getHours() % 12;
|
|
130
131
|
};
|
|
131
|
-
var calculateMins = function calculateMins(time) {
|
|
132
|
-
|
|
132
|
+
var calculateMins = function calculateMins(time, minuteValues) {
|
|
133
|
+
var selectedMinute = minuteValues[0];
|
|
134
|
+
for (var _iterator = _createForOfIteratorHelperLoose(minuteValues), _step; !(_step = _iterator()).done;) {
|
|
135
|
+
var minuteValue = _step.value;
|
|
136
|
+
if (time.getMinutes() >= parseInt(minuteValue.value, 10)) {
|
|
137
|
+
selectedMinute = minuteValue;
|
|
138
|
+
} else {
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return selectedMinute.value;
|
|
133
143
|
};
|
|
134
144
|
var calculateAMPM = function calculateAMPM(time) {
|
|
135
145
|
return isAM(time) ? "AM" : "PM";
|
|
@@ -151,7 +161,8 @@ var AMPMSelect = exports.AMPMSelect = function AMPMSelect(_ref) {
|
|
|
151
161
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
152
162
|
className: classes.timePickerSegmentWrapper
|
|
153
163
|
}, /*#__PURE__*/_react.default.createElement(_Select.default, {
|
|
154
|
-
selectProps: selectProps
|
|
164
|
+
selectProps: selectProps,
|
|
165
|
+
"data-qa": "time-ampm"
|
|
155
166
|
}, ampmOptions.map(function (option) {
|
|
156
167
|
return /*#__PURE__*/_react.default.createElement("option", {
|
|
157
168
|
key: "ampm" + option.value,
|
|
@@ -182,7 +193,8 @@ var HoursSelect = exports.HoursSelect = function HoursSelect(_ref2) {
|
|
|
182
193
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
183
194
|
className: classes.timePickerSegmentWrapper
|
|
184
195
|
}, /*#__PURE__*/_react.default.createElement(_Select.default, {
|
|
185
|
-
selectProps: selectProps
|
|
196
|
+
selectProps: selectProps,
|
|
197
|
+
"data-qa": "time-hours"
|
|
186
198
|
}, properHourOptions.map(function (option) {
|
|
187
199
|
return /*#__PURE__*/_react.default.createElement("option", {
|
|
188
200
|
key: "hour" + option.value,
|
|
@@ -198,11 +210,13 @@ __signature__(HoursSelect, "useStyles{classes}", function () {
|
|
|
198
210
|
});
|
|
199
211
|
var MinsSelect = exports.MinsSelect = function MinsSelect(_ref3) {
|
|
200
212
|
var updateTimeOptions = _ref3.updateTimeOptions,
|
|
201
|
-
time = _ref3.time
|
|
213
|
+
time = _ref3.time,
|
|
214
|
+
_ref3$values = _ref3.values,
|
|
215
|
+
values = _ref3$values === void 0 ? minOptions : _ref3$values;
|
|
202
216
|
var classes = useStyles();
|
|
203
217
|
var selectProps = new _SelectProps.default();
|
|
204
218
|
selectProps.set(_SelectProps.default.propNames.update, updateTimeOptions("mins"));
|
|
205
|
-
selectProps.set(_SelectProps.default.propNames.value, calculateMins(time));
|
|
219
|
+
selectProps.set(_SelectProps.default.propNames.value, calculateMins(time, values));
|
|
206
220
|
selectProps.set(_SelectProps.default.propNames.native, true);
|
|
207
221
|
selectProps.set(_SelectProps.default.propNames.inputProps, {
|
|
208
222
|
name: "mins",
|
|
@@ -211,8 +225,9 @@ var MinsSelect = exports.MinsSelect = function MinsSelect(_ref3) {
|
|
|
211
225
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
212
226
|
className: classes.timePickerSegmentWrapper
|
|
213
227
|
}, /*#__PURE__*/_react.default.createElement(_Select.default, {
|
|
214
|
-
selectProps: selectProps
|
|
215
|
-
|
|
228
|
+
selectProps: selectProps,
|
|
229
|
+
"data-qa": "time-minutes"
|
|
230
|
+
}, values.map(function (option) {
|
|
216
231
|
return /*#__PURE__*/_react.default.createElement("option", {
|
|
217
232
|
key: "min" + option.value,
|
|
218
233
|
value: option.value
|
|
@@ -231,7 +246,8 @@ var TimePicker = function TimePicker(_ref4) {
|
|
|
231
246
|
onChange = _ref4.onChange,
|
|
232
247
|
showTimeZone = _ref4.showTimeZone,
|
|
233
248
|
showAMPM = _ref4.showAMPM,
|
|
234
|
-
requestedTimeZone = _ref4.requestedTimeZone
|
|
249
|
+
requestedTimeZone = _ref4.requestedTimeZone,
|
|
250
|
+
timeOption = _ref4.timeOption;
|
|
235
251
|
var classes = useStyles();
|
|
236
252
|
showAMPM = (_showAMPM = showAMPM) != null ? _showAMPM : isBrowserUsingAMPM();
|
|
237
253
|
var _useState = (0, _react.useState)(parseTime(value || "00:00")),
|
|
@@ -291,7 +307,8 @@ var TimePicker = function TimePicker(_ref4) {
|
|
|
291
307
|
showAMPM: showAMPM
|
|
292
308
|
}), /*#__PURE__*/_react.default.createElement("label", null, " : "), /*#__PURE__*/_react.default.createElement(MinsSelect, {
|
|
293
309
|
updateTimeOptions: updateTimeOptions,
|
|
294
|
-
time: time
|
|
310
|
+
time: time,
|
|
311
|
+
values: timeOption == null ? void 0 : timeOption.minutes
|
|
295
312
|
}), /*#__PURE__*/_react.default.createElement(AMPMSelect, {
|
|
296
313
|
showAMPM: showAMPM,
|
|
297
314
|
updateTimeOptions: updateTimeOptions,
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.validationErrorTypes = exports.taskStatuses = exports.serializationTypeKey = exports.scopeTypes = exports.scopeConfirmationDialogTypes = exports.roleGroups = exports.requestStates = exports.requestStateOperations = exports.requestStateOperationMap = exports.propertyBagPrimitiveDataType = exports.platformRoles = exports.overtureModule = exports.jsonCargoType = exports.infoBar = exports.dotNetDataTypes = exports.displayMode = exports.definitionType = exports.attributeDataType = void 0;
|
|
4
|
+
exports.validationErrorTypes = exports.taskStatuses = exports.serializationTypeKey = exports.scopeTypes = exports.scopeConfirmationDialogTypes = exports.roleGroups = exports.requestStates = exports.requestStateOperations = exports.requestStateOperationMap = exports.propertyBagPrimitiveDataType = exports.platformRoles = exports.overtureModule = exports.jsonCargoType = exports.infoBar = exports.dotNetDataTypes = exports.displayMode = exports.definitionType = exports.attributeDataType = exports.allValue = void 0;
|
|
5
5
|
(function () {
|
|
6
6
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
7
7
|
enterModule && enterModule(module);
|
|
@@ -171,6 +171,7 @@ var jsonCargoType = exports.jsonCargoType = {
|
|
|
171
171
|
integer: "Int32",
|
|
172
172
|
entityReferences: "Guid[]"
|
|
173
173
|
};
|
|
174
|
+
var allValue = exports.allValue = "#All#";
|
|
174
175
|
;
|
|
175
176
|
(function () {
|
|
176
177
|
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
@@ -195,6 +196,7 @@ var jsonCargoType = exports.jsonCargoType = {
|
|
|
195
196
|
reactHotLoader.register(dotNetDataTypes, "dotNetDataTypes", "/home/vsts/work/1/s/src/constants.js");
|
|
196
197
|
reactHotLoader.register(serializationTypeKey, "serializationTypeKey", "/home/vsts/work/1/s/src/constants.js");
|
|
197
198
|
reactHotLoader.register(jsonCargoType, "jsonCargoType", "/home/vsts/work/1/s/src/constants.js");
|
|
199
|
+
reactHotLoader.register(allValue, "allValue", "/home/vsts/work/1/s/src/constants.js");
|
|
198
200
|
})();
|
|
199
201
|
;
|
|
200
202
|
(function () {
|
|
@@ -225,6 +227,7 @@ var jsonCargoType = exports.jsonCargoType = {
|
|
|
225
227
|
reactHotLoader.register(dotNetDataTypes, "dotNetDataTypes", "/home/vsts/work/1/s/src/constants.js");
|
|
226
228
|
reactHotLoader.register(serializationTypeKey, "serializationTypeKey", "/home/vsts/work/1/s/src/constants.js");
|
|
227
229
|
reactHotLoader.register(jsonCargoType, "jsonCargoType", "/home/vsts/work/1/s/src/constants.js");
|
|
230
|
+
reactHotLoader.register(allValue, "allValue", "/home/vsts/work/1/s/src/constants.js");
|
|
228
231
|
})();
|
|
229
232
|
;
|
|
230
233
|
(function () {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.substituteAllForNull = exports.getValueWithAll = exports.extractDropboxOptionsMemo = exports.extractDropboxOptions = void 0;
|
|
5
|
+
var _constants = require("../constants");
|
|
6
|
+
var _index = require("./index");
|
|
7
|
+
(function () {
|
|
8
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
9
|
+
enterModule && enterModule(module);
|
|
10
|
+
})();
|
|
11
|
+
(function () {
|
|
12
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
13
|
+
enterModule && enterModule(module);
|
|
14
|
+
})();
|
|
15
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
16
|
+
return a;
|
|
17
|
+
};
|
|
18
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var getValueWithAll = exports.getValueWithAll = function getValueWithAll(value) {
|
|
22
|
+
if (!value) return _constants.allValue;
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
var substituteAllForNull = exports.substituteAllForNull = function substituteAllForNull(value) {
|
|
26
|
+
return value === _constants.allValue ? null : value;
|
|
27
|
+
};
|
|
28
|
+
var extractDropboxOptionsMemo = exports.extractDropboxOptionsMemo = function extractDropboxOptionsMemo(data, config) {
|
|
29
|
+
var _config;
|
|
30
|
+
if (config === void 0) {
|
|
31
|
+
config = undefined;
|
|
32
|
+
}
|
|
33
|
+
var _ref = (_config = config) != null ? _config : {},
|
|
34
|
+
_ref$activeKey = _ref.activeKey,
|
|
35
|
+
activeKey = _ref$activeKey === void 0 ? "isActive" : _ref$activeKey,
|
|
36
|
+
_ref$valueKey = _ref.valueKey,
|
|
37
|
+
valueKey = _ref$valueKey === void 0 ? "value" : _ref$valueKey,
|
|
38
|
+
_ref$labelKey = _ref.labelKey,
|
|
39
|
+
labelKey = _ref$labelKey === void 0 ? "displayName" : _ref$labelKey,
|
|
40
|
+
_ref$fallbackLabelKey = _ref.fallbackLabelKey,
|
|
41
|
+
fallbackLabelKey = _ref$fallbackLabelKey === void 0 ? undefined : _ref$fallbackLabelKey,
|
|
42
|
+
_ref$sortOrderKey = _ref.sortOrderKey,
|
|
43
|
+
sortOrderKey = _ref$sortOrderKey === void 0 ? "sortOrder" : _ref$sortOrderKey;
|
|
44
|
+
var items = Array.isArray(data) ? data : data.valueSeq();
|
|
45
|
+
var options = [];
|
|
46
|
+
items.forEach(function (v) {
|
|
47
|
+
if (!activeKey || v.get(activeKey)) {
|
|
48
|
+
options.push({
|
|
49
|
+
value: v.get(valueKey),
|
|
50
|
+
label: v.get(labelKey) || fallbackLabelKey && v.get(fallbackLabelKey),
|
|
51
|
+
sortOrder: v.get(sortOrderKey)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return options;
|
|
56
|
+
};
|
|
57
|
+
var extractDropboxOptions = exports.extractDropboxOptions = (0, _index.memoize)(extractDropboxOptionsMemo);
|
|
58
|
+
;
|
|
59
|
+
(function () {
|
|
60
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
61
|
+
if (!reactHotLoader) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
reactHotLoader.register(getValueWithAll, "getValueWithAll", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
65
|
+
reactHotLoader.register(substituteAllForNull, "substituteAllForNull", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
66
|
+
reactHotLoader.register(extractDropboxOptionsMemo, "extractDropboxOptionsMemo", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
67
|
+
reactHotLoader.register(extractDropboxOptions, "extractDropboxOptions", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
68
|
+
})();
|
|
69
|
+
;
|
|
70
|
+
(function () {
|
|
71
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
72
|
+
leaveModule && leaveModule(module);
|
|
73
|
+
})();
|
|
74
|
+
;
|
|
75
|
+
(function () {
|
|
76
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
77
|
+
if (!reactHotLoader) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
reactHotLoader.register(getValueWithAll, "getValueWithAll", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
81
|
+
reactHotLoader.register(substituteAllForNull, "substituteAllForNull", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
82
|
+
reactHotLoader.register(extractDropboxOptionsMemo, "extractDropboxOptionsMemo", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
83
|
+
reactHotLoader.register(extractDropboxOptions, "extractDropboxOptions", "/home/vsts/work/1/s/src/utils/filterHelper.js");
|
|
84
|
+
})();
|
|
85
|
+
;
|
|
86
|
+
(function () {
|
|
87
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
88
|
+
leaveModule && leaveModule(module);
|
|
89
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "5.7.0-dev.
|
|
3
|
+
"version": "5.7.0-dev.7",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@testing-library/react": "^10.4.9"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"orc-scripts": "2.0.0-dev.
|
|
58
|
+
"orc-scripts": "2.0.0-dev.4"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"orc-scripts": "2.0.0-dev.
|
|
61
|
+
"orc-scripts": "2.0.0-dev.4",
|
|
62
62
|
"react-number-format": "^5.3.0"
|
|
63
63
|
},
|
|
64
64
|
"sideEffects": false,
|
|
@@ -136,6 +136,7 @@ const WrappedDatePicker = ({
|
|
|
136
136
|
metadata,
|
|
137
137
|
timePickerTimeZone,
|
|
138
138
|
error,
|
|
139
|
+
timeOption,
|
|
139
140
|
...props
|
|
140
141
|
}) => {
|
|
141
142
|
const classes = useStyles({ readOnly });
|
|
@@ -166,7 +167,13 @@ const WrappedDatePicker = ({
|
|
|
166
167
|
showTimeInput={useTime ?? false}
|
|
167
168
|
useTime={useTime ?? false}
|
|
168
169
|
customTimeInput={
|
|
169
|
-
useTime ?
|
|
170
|
+
useTime ? (
|
|
171
|
+
<TimePicker
|
|
172
|
+
showTimeZone={showTimeZone}
|
|
173
|
+
requestedTimeZone={localizedTimeZoneName}
|
|
174
|
+
timeOption={timeOption}
|
|
175
|
+
/>
|
|
176
|
+
) : null
|
|
170
177
|
}
|
|
171
178
|
timeInputLabel={timeInputLabel ?? ""}
|
|
172
179
|
readOnly={readOnly}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useSelector } from "react-redux";
|
|
2
|
+
import { extractDropboxOptions } from "../../../utils/filterHelper";
|
|
3
|
+
import { namedLookupValuesSelector } from "../../../selectors/metadata";
|
|
4
|
+
import { getNotLocalizedString } from "../../../utils/localizationHelper";
|
|
5
|
+
import createInput, { inputTypes } from "./createInput";
|
|
6
|
+
|
|
7
|
+
const LookupSelect = ({ moduleName, lookupName, value, onChange, disabled, metadata }) => {
|
|
8
|
+
const options = extractDropboxOptions(useSelector(namedLookupValuesSelector(moduleName, lookupName)));
|
|
9
|
+
|
|
10
|
+
if (value !== null && !options.some(x => x.value === value)) {
|
|
11
|
+
options.push({
|
|
12
|
+
label: getNotLocalizedString(value),
|
|
13
|
+
value: value,
|
|
14
|
+
sortOrder: 0,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return createInput(inputTypes.select, {
|
|
19
|
+
options: options,
|
|
20
|
+
value: value,
|
|
21
|
+
update: newValue => onChange(newValue, metadata),
|
|
22
|
+
disabled: disabled,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default LookupSelect;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { mount } from "enzyme";
|
|
3
|
+
import Select from "./Select";
|
|
4
|
+
import SelectMUI from "@material-ui/core/Select";
|
|
5
|
+
import sinon from "sinon";
|
|
6
|
+
import { createMuiTheme, TestWrapper } from "../../../utils/testUtils";
|
|
7
|
+
import SelectProps from "./SelectProps";
|
|
8
|
+
import Immutable from "immutable";
|
|
9
|
+
import LookupSelect from "./LookupSelect";
|
|
10
|
+
|
|
11
|
+
const theme = createMuiTheme();
|
|
12
|
+
|
|
13
|
+
describe("LookupSelect Component", () => {
|
|
14
|
+
let store, state;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
state = Immutable.fromJS({
|
|
17
|
+
locale: { locale: "it-IT" },
|
|
18
|
+
metadata: {
|
|
19
|
+
lookups: {
|
|
20
|
+
order: {
|
|
21
|
+
index: {
|
|
22
|
+
CanceledStatusReasons: {
|
|
23
|
+
lookupName: "CanceledStatusReasons",
|
|
24
|
+
values: {
|
|
25
|
+
CanceledReason1: {
|
|
26
|
+
id: "e16d07f847284775b77cfb985724cf58",
|
|
27
|
+
value: "CanceledReason1",
|
|
28
|
+
lookupId: "CanceledStatusReasons",
|
|
29
|
+
sortOrder: 0,
|
|
30
|
+
isActive: true,
|
|
31
|
+
isSystem: true,
|
|
32
|
+
displayName: {
|
|
33
|
+
"en-CA": "Cancel for reason 1",
|
|
34
|
+
"en-US": "Cancel for reason 1",
|
|
35
|
+
"fr-CA": "Annulé pour raison 1",
|
|
36
|
+
"it-IT": "Annulla per motivo 1",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
CanceledReason2: {
|
|
40
|
+
id: "6bbfe77703c745d68b8eaceb9cd484b1",
|
|
41
|
+
value: "CanceledReason2",
|
|
42
|
+
lookupId: "CanceledStatusReasons",
|
|
43
|
+
sortOrder: 0,
|
|
44
|
+
isActive: true,
|
|
45
|
+
isSystem: true,
|
|
46
|
+
displayName: {
|
|
47
|
+
"en-CA": "Cancel for reason 2",
|
|
48
|
+
"en-US": "Cancel for reason 2",
|
|
49
|
+
"fr-CA": "Annulé pour raison 2",
|
|
50
|
+
"it-IT": "Annulla per motivo 2",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
isActive: true,
|
|
55
|
+
isSystem: true,
|
|
56
|
+
},
|
|
57
|
+
CartStatus: {
|
|
58
|
+
lookupName: "CartStatus",
|
|
59
|
+
values: {},
|
|
60
|
+
isActive: true,
|
|
61
|
+
isSystem: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
list: [],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
store = {
|
|
70
|
+
subscribe: () => {},
|
|
71
|
+
getState: () => state,
|
|
72
|
+
dispatch: sinon.spy().named("dispatch"),
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("renders select based on lookup.", () => {
|
|
77
|
+
const options = [
|
|
78
|
+
{ value: "CanceledReason1", label: "Annulla per motivo 1" },
|
|
79
|
+
{ value: "CanceledReason2", label: "Annulla per motivo 2" },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
const selectProps = new SelectProps();
|
|
83
|
+
selectProps.set(SelectProps.propNames.value, "CanceledReason1");
|
|
84
|
+
|
|
85
|
+
expect(
|
|
86
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
87
|
+
<LookupSelect
|
|
88
|
+
moduleName={"order"}
|
|
89
|
+
lookupName={"CanceledStatusReasons"}
|
|
90
|
+
value={"CanceledReason1"}
|
|
91
|
+
onChange={() => {}}
|
|
92
|
+
/>
|
|
93
|
+
</TestWrapper>,
|
|
94
|
+
"when mounted",
|
|
95
|
+
"to satisfy",
|
|
96
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
97
|
+
<Select options={options} selectProps={selectProps} />
|
|
98
|
+
</TestWrapper>,
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("renders disabled select based on lookup.", () => {
|
|
103
|
+
const options = [
|
|
104
|
+
{ value: "CanceledReason1", label: "Annulla per motivo 1" },
|
|
105
|
+
{ value: "CanceledReason2", label: "Annulla per motivo 2" },
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
const selectProps = new SelectProps();
|
|
109
|
+
selectProps.set(SelectProps.propNames.value, "CanceledReason1");
|
|
110
|
+
selectProps.set(SelectProps.propNames.disabled, true);
|
|
111
|
+
|
|
112
|
+
expect(
|
|
113
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
114
|
+
<LookupSelect
|
|
115
|
+
moduleName={"order"}
|
|
116
|
+
lookupName={"CanceledStatusReasons"}
|
|
117
|
+
value={"CanceledReason1"}
|
|
118
|
+
disabled={true}
|
|
119
|
+
onChange={() => {}}
|
|
120
|
+
/>
|
|
121
|
+
</TestWrapper>,
|
|
122
|
+
"when mounted",
|
|
123
|
+
"to satisfy",
|
|
124
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
125
|
+
<Select options={options} selectProps={selectProps} />
|
|
126
|
+
</TestWrapper>,
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("renders select based on lookup with missing selected value", () => {
|
|
131
|
+
const options = [
|
|
132
|
+
{ value: "CanceledReason1", label: "Annulla per motivo 1" },
|
|
133
|
+
{ value: "CanceledReason2", label: "Annulla per motivo 2" },
|
|
134
|
+
{ value: "CanceledReason3", label: "[CanceledReason3]" },
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
const selectProps = new SelectProps();
|
|
138
|
+
selectProps.set(SelectProps.propNames.value, "CanceledReason3");
|
|
139
|
+
|
|
140
|
+
expect(
|
|
141
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
142
|
+
<LookupSelect
|
|
143
|
+
moduleName={"order"}
|
|
144
|
+
lookupName={"CanceledStatusReasons"}
|
|
145
|
+
value={"CanceledReason3"}
|
|
146
|
+
onChange={() => {}}
|
|
147
|
+
/>
|
|
148
|
+
</TestWrapper>,
|
|
149
|
+
"when mounted",
|
|
150
|
+
"to satisfy",
|
|
151
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
152
|
+
<Select options={options} selectProps={selectProps} />
|
|
153
|
+
</TestWrapper>,
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("LookupSelect component handles change", () => {
|
|
158
|
+
const update = sinon.spy().named("update");
|
|
159
|
+
const component = (
|
|
160
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
161
|
+
<LookupSelect
|
|
162
|
+
moduleName={"order"}
|
|
163
|
+
lookupName={"CanceledStatusReasons"}
|
|
164
|
+
value={"CanceledReason3"}
|
|
165
|
+
onChange={update}
|
|
166
|
+
/>
|
|
167
|
+
</TestWrapper>
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const mountedComponent = mount(component);
|
|
171
|
+
|
|
172
|
+
const selectMui = mountedComponent.find(SelectMUI);
|
|
173
|
+
|
|
174
|
+
const event = {
|
|
175
|
+
target: {
|
|
176
|
+
value: "CanceledReason2",
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
selectMui.invoke("onChange")(event);
|
|
181
|
+
|
|
182
|
+
expect(update, "to have calls satisfying", [{ args: ["CanceledReason2", undefined] }]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("LookupSelect component handles change with metadata", () => {
|
|
186
|
+
const update = sinon.spy().named("update");
|
|
187
|
+
const component = (
|
|
188
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
|
|
189
|
+
<LookupSelect
|
|
190
|
+
moduleName={"order"}
|
|
191
|
+
lookupName={"CanceledStatusReasons"}
|
|
192
|
+
value={"CanceledReason3"}
|
|
193
|
+
onChange={update}
|
|
194
|
+
metadata={{ a: 123 }}
|
|
195
|
+
/>
|
|
196
|
+
</TestWrapper>
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const mountedComponent = mount(component);
|
|
200
|
+
|
|
201
|
+
const selectMui = mountedComponent.find(SelectMUI);
|
|
202
|
+
|
|
203
|
+
const event = {
|
|
204
|
+
target: {
|
|
205
|
+
value: "CanceledReason2",
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
selectMui.invoke("onChange")(event);
|
|
210
|
+
|
|
211
|
+
expect(update, "to have calls satisfying", [{ args: ["CanceledReason2", { a: 123 }] }]);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
@@ -91,8 +91,17 @@ const calculateHours = (time, showAMPM) => {
|
|
|
91
91
|
return time.getHours() === 0 || time.getHours() === 12 ? 12 : time.getHours() % 12;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
const calculateMins = time => {
|
|
95
|
-
|
|
94
|
+
const calculateMins = (time, minuteValues) => {
|
|
95
|
+
let selectedMinute = minuteValues[0];
|
|
96
|
+
for (const minuteValue of minuteValues) {
|
|
97
|
+
if (time.getMinutes() >= parseInt(minuteValue.value, 10)) {
|
|
98
|
+
selectedMinute = minuteValue;
|
|
99
|
+
} else {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return selectedMinute.value;
|
|
96
105
|
};
|
|
97
106
|
|
|
98
107
|
const calculateAMPM = time => (isAM(time) ? "AM" : "PM");
|
|
@@ -113,7 +122,7 @@ export const AMPMSelect = ({ showAMPM, updateTimeOptions, time }) => {
|
|
|
113
122
|
|
|
114
123
|
return (
|
|
115
124
|
<div className={classes.timePickerSegmentWrapper}>
|
|
116
|
-
<Select selectProps={selectProps}>
|
|
125
|
+
<Select selectProps={selectProps} data-qa="time-ampm">
|
|
117
126
|
{ampmOptions.map(option => (
|
|
118
127
|
<option key={"ampm" + option.value} value={option.value}>
|
|
119
128
|
{option.label}
|
|
@@ -139,7 +148,7 @@ export const HoursSelect = ({ updateTimeOptions, time, showAMPM }) => {
|
|
|
139
148
|
|
|
140
149
|
return (
|
|
141
150
|
<div className={classes.timePickerSegmentWrapper}>
|
|
142
|
-
<Select selectProps={selectProps}>
|
|
151
|
+
<Select selectProps={selectProps} data-qa="time-hours">
|
|
143
152
|
{properHourOptions.map(option => (
|
|
144
153
|
<option key={"hour" + option.value} value={option.value}>
|
|
145
154
|
{option.label}
|
|
@@ -150,12 +159,12 @@ export const HoursSelect = ({ updateTimeOptions, time, showAMPM }) => {
|
|
|
150
159
|
);
|
|
151
160
|
};
|
|
152
161
|
|
|
153
|
-
export const MinsSelect = ({ updateTimeOptions, time }) => {
|
|
162
|
+
export const MinsSelect = ({ updateTimeOptions, time, values = minOptions }) => {
|
|
154
163
|
const classes = useStyles();
|
|
155
164
|
const selectProps = new SelectProps();
|
|
156
165
|
|
|
157
166
|
selectProps.set(SelectProps.propNames.update, updateTimeOptions("mins"));
|
|
158
|
-
selectProps.set(SelectProps.propNames.value, calculateMins(time));
|
|
167
|
+
selectProps.set(SelectProps.propNames.value, calculateMins(time, values));
|
|
159
168
|
selectProps.set(SelectProps.propNames.native, true);
|
|
160
169
|
selectProps.set(SelectProps.propNames.inputProps, {
|
|
161
170
|
name: "mins",
|
|
@@ -164,8 +173,8 @@ export const MinsSelect = ({ updateTimeOptions, time }) => {
|
|
|
164
173
|
|
|
165
174
|
return (
|
|
166
175
|
<div className={classes.timePickerSegmentWrapper}>
|
|
167
|
-
<Select selectProps={selectProps}>
|
|
168
|
-
{
|
|
176
|
+
<Select selectProps={selectProps} data-qa="time-minutes">
|
|
177
|
+
{values.map(option => (
|
|
169
178
|
<option key={"min" + option.value} value={option.value}>
|
|
170
179
|
{option.label}
|
|
171
180
|
</option>
|
|
@@ -175,7 +184,7 @@ export const MinsSelect = ({ updateTimeOptions, time }) => {
|
|
|
175
184
|
);
|
|
176
185
|
};
|
|
177
186
|
|
|
178
|
-
const TimePicker = ({ value, onChange, showTimeZone, showAMPM, requestedTimeZone }) => {
|
|
187
|
+
const TimePicker = ({ value, onChange, showTimeZone, showAMPM, requestedTimeZone, timeOption }) => {
|
|
179
188
|
const classes = useStyles();
|
|
180
189
|
showAMPM = showAMPM ?? isBrowserUsingAMPM();
|
|
181
190
|
const [time, setTime] = useState(parseTime(value || "00:00"));
|
|
@@ -232,7 +241,7 @@ const TimePicker = ({ value, onChange, showTimeZone, showAMPM, requestedTimeZone
|
|
|
232
241
|
<span className={classes.timePickerWrapper}>
|
|
233
242
|
<HoursSelect updateTimeOptions={updateTimeOptions} time={time} showAMPM={showAMPM} />
|
|
234
243
|
<label> : </label>
|
|
235
|
-
<MinsSelect updateTimeOptions={updateTimeOptions} time={time} />
|
|
244
|
+
<MinsSelect updateTimeOptions={updateTimeOptions} time={time} values={timeOption?.minutes} />
|
|
236
245
|
<AMPMSelect showAMPM={showAMPM} updateTimeOptions={updateTimeOptions} time={time} />
|
|
237
246
|
</span>
|
|
238
247
|
{showTimeZone && (
|
|
@@ -313,6 +313,34 @@ describe("Time Component", () => {
|
|
|
313
313
|
</TestWrapper>,
|
|
314
314
|
));
|
|
315
315
|
|
|
316
|
+
it("sets up a time 559pm", () => {
|
|
317
|
+
const component = mount(
|
|
318
|
+
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} intlProvider={{ messages }}>
|
|
319
|
+
<div>
|
|
320
|
+
<TimePicker
|
|
321
|
+
showAMPM={true}
|
|
322
|
+
onChange={jest.fn()}
|
|
323
|
+
value="10:59"
|
|
324
|
+
timeOption={{
|
|
325
|
+
minutes: [
|
|
326
|
+
{ value: "00", label: "00" },
|
|
327
|
+
{ value: "15", label: "15" },
|
|
328
|
+
{ value: "30", label: "30" },
|
|
329
|
+
{ value: "45", label: "45" },
|
|
330
|
+
{ value: "59", label: "59" },
|
|
331
|
+
],
|
|
332
|
+
}}
|
|
333
|
+
/>
|
|
334
|
+
</div>
|
|
335
|
+
</TestWrapper>,
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
const minSelect = component.find("[data-qa='time-minutes']");
|
|
339
|
+
|
|
340
|
+
expect(minSelect.length, "to equal", 1);
|
|
341
|
+
expect(minSelect.at(0).props().selectProps.componentProps.get("value"), "to equal", "59");
|
|
342
|
+
});
|
|
343
|
+
|
|
316
344
|
it("sets up a time 545pm without AMPM", () =>
|
|
317
345
|
expect(
|
|
318
346
|
<TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }} intlProvider={{ messages }}>
|
package/src/constants.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { allValue } from "../constants";
|
|
2
|
+
import { memoize } from "./index";
|
|
3
|
+
|
|
4
|
+
export const getValueWithAll = value => {
|
|
5
|
+
if (!value) return allValue;
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const substituteAllForNull = value => (value === allValue ? null : value);
|
|
10
|
+
|
|
11
|
+
export const extractDropboxOptionsMemo = (data, config = undefined) => {
|
|
12
|
+
const {
|
|
13
|
+
activeKey = "isActive",
|
|
14
|
+
valueKey = "value",
|
|
15
|
+
labelKey = "displayName",
|
|
16
|
+
fallbackLabelKey = undefined,
|
|
17
|
+
sortOrderKey = "sortOrder",
|
|
18
|
+
} = config ?? {};
|
|
19
|
+
let items = Array.isArray(data) ? data : data.valueSeq();
|
|
20
|
+
let options = [];
|
|
21
|
+
items.forEach(v => {
|
|
22
|
+
if (!activeKey || v.get(activeKey)) {
|
|
23
|
+
options.push({
|
|
24
|
+
value: v.get(valueKey),
|
|
25
|
+
label: v.get(labelKey) || (fallbackLabelKey && v.get(fallbackLabelKey)),
|
|
26
|
+
sortOrder: v.get(sortOrderKey),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return options;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const extractDropboxOptions = memoize(extractDropboxOptionsMemo);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { allValue } from "~/constants";
|
|
2
|
+
import { substituteAllForNull, getValueWithAll, extractDropboxOptions } from "./filterHelper";
|
|
3
|
+
import Immutable from "immutable";
|
|
4
|
+
|
|
5
|
+
describe("getValueWithAll", () => {
|
|
6
|
+
it("Retrieves allValue if value is null", () => {
|
|
7
|
+
const result = getValueWithAll(null);
|
|
8
|
+
|
|
9
|
+
expect(result, "to be", allValue);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("Retrieves value if value is not null", () => {
|
|
13
|
+
const result = getValueWithAll("value");
|
|
14
|
+
|
|
15
|
+
expect(result, "to be", "value");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe("substituteAllForNull", () => {
|
|
20
|
+
it("Retrieves null if value is allValue", () => {
|
|
21
|
+
const result = substituteAllForNull(allValue);
|
|
22
|
+
|
|
23
|
+
expect(result, "to be", null);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("Retrieves value if value is not allValue", () => {
|
|
27
|
+
const result = substituteAllForNull("value");
|
|
28
|
+
|
|
29
|
+
expect(result, "to be", "value");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("extractDropboxOptions", () => {
|
|
34
|
+
it("Retrieves correct array if lookup is not null and is an immutable array", () => {
|
|
35
|
+
const data = [
|
|
36
|
+
{ value: "value1", isActive: true, label: "label1", sortOrder: 0, smth: "smth1" },
|
|
37
|
+
{ value: "value2", isActive: false, label: "label2", sortOrder: 1, smth: "smth2" },
|
|
38
|
+
{ value: "value3", isActive: true, label: "label3", sortOrder: 3, smth: "smth3" },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const lookup = Immutable.fromJS(data);
|
|
42
|
+
|
|
43
|
+
const result = extractDropboxOptions(lookup);
|
|
44
|
+
|
|
45
|
+
expect(result, "to equal", [
|
|
46
|
+
{ value: "value1", label: undefined, sortOrder: 0 },
|
|
47
|
+
{ value: "value3", label: undefined, sortOrder: 3 },
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("Retrieves correct array if lookup is not null and is an array", () => {
|
|
52
|
+
const data = [
|
|
53
|
+
{ value: "value4", isActive: true, label: "label4", sortOrder: 0, smth: "smth4" },
|
|
54
|
+
{ value: "value5", isActive: false, label: "label5", sortOrder: 1, smth: "smth5" },
|
|
55
|
+
{ value: "value6", isActive: true, label: "label6", sortOrder: 3, smth: "smth6" },
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const lookups = data.map(x => Immutable.fromJS(x));
|
|
59
|
+
|
|
60
|
+
const result = extractDropboxOptions(lookups);
|
|
61
|
+
|
|
62
|
+
expect(result, "to equal", [
|
|
63
|
+
{ value: "value4", label: undefined, sortOrder: 0 },
|
|
64
|
+
{ value: "value6", label: undefined, sortOrder: 3 },
|
|
65
|
+
]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("Retrieves correct array if lookup is not an array", () => {
|
|
69
|
+
const data = {
|
|
70
|
+
l1: { value: "value1", isActive: true, label: "label1", sortOrder: 0, smth: "smth1" },
|
|
71
|
+
l2: { value: "value2", isActive: false, label: "label2", sortOrder: 1, smth: "smth2" },
|
|
72
|
+
l3: { value: "value3", isActive: true, label: "label3", sortOrder: 3, smth: "smth3" },
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const lookup = Immutable.fromJS(data);
|
|
76
|
+
|
|
77
|
+
const result = extractDropboxOptions(lookup);
|
|
78
|
+
|
|
79
|
+
expect(result, "to equal", [
|
|
80
|
+
{ value: "value1", label: undefined, sortOrder: 0 },
|
|
81
|
+
{ value: "value3", label: undefined, sortOrder: 3 },
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("Uses fallback label key", () => {
|
|
86
|
+
const data = {
|
|
87
|
+
l1: { value: "value1", isActive: true, label: "label1", sortOrder: 0, smth: "smth1" },
|
|
88
|
+
l2: { value: "value2", isActive: false, label: "label2", sortOrder: 1, smth: "smth2" },
|
|
89
|
+
l3: { value: "value3", isActive: true, label: "label3", sortOrder: 3, smth: "smth3" },
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const lookup = Immutable.fromJS(data);
|
|
93
|
+
|
|
94
|
+
const result = extractDropboxOptions(lookup, {
|
|
95
|
+
fallbackLabelKey: "label",
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
expect(result, "to equal", [
|
|
99
|
+
{ value: "value1", label: "label1", sortOrder: 0 },
|
|
100
|
+
{ value: "value3", label: "label3", sortOrder: 3 },
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("Retrieves empty array if lookup is empty", () => {
|
|
105
|
+
const result = extractDropboxOptions(Immutable.fromJS([]));
|
|
106
|
+
|
|
107
|
+
expect(result, "to equal", []);
|
|
108
|
+
});
|
|
109
|
+
});
|