@k-int/stripes-kint-components 5.25.1 → 5.25.3
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/CHANGELOG.md +14 -0
- package/es/__mocks__/@folio/stripes/components.js +7 -3
- package/es/__mocks__/@folio/stripes/core.js +6 -4
- package/es/__mocks__/@folio/stripes/smart-components.js +6 -4
- package/es/__mocks__/react-query.js +6 -4
- package/es/__mocks__/react-router-dom.js +6 -6
- package/es/lib/ActionList/ActionList.js +33 -26
- package/es/lib/ActionList/ActionListFieldArray.js +119 -103
- package/es/lib/ComboButton/ComboButton.js +47 -42
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +17 -11
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +46 -42
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +58 -58
- package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +8 -4
- package/es/lib/CustomProperties/Config/CustomPropertyView.js +33 -32
- package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +1 -1
- package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +1 -1
- package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +3 -3
- package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +35 -29
- package/es/lib/CustomProperties/Edit/CustomPropertyField.js +59 -61
- package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +20 -20
- package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +2 -2
- package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +1 -1
- package/es/lib/CustomProperties/Edit/testResources.js +12 -11
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +33 -22
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +35 -23
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +1 -1
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +6 -6
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +6 -3
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +8 -4
- package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +17 -14
- package/es/lib/CustomProperties/Filter/testResources.js +2 -1
- package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +2 -1
- package/es/lib/CustomProperties/View/CustomPropertiesView.js +1 -1
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +26 -18
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +6 -3
- package/es/lib/CustomProperties/View/CustomPropertyCard.js +11 -7
- package/es/lib/CycleButton/CycleButton.js +17 -9
- package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +46 -30
- package/es/lib/EditableRefdataList/EditableRefdataList.js +43 -33
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray/EditableSettingsListFieldArray.js +9 -5
- package/es/lib/EditableSettingsList/SettingField/EditSettingValue/EditSettingValue.js +6 -6
- package/es/lib/EditableSettingsList/SettingField/RenderSettingValue/RenderSettingValue.js +12 -10
- package/es/lib/EditableSettingsList/SettingField/SettingField.js +12 -8
- package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +3 -3
- package/es/lib/FormModal/FormModal.js +32 -24
- package/es/lib/FormattedKintMessage/FormattedKintMessage.js +30 -23
- package/es/lib/IconSelect/IconSelect.js +32 -22
- package/es/lib/NoResultsMessage/NoResultsMessage.js +5 -4
- package/es/lib/NumberField/NumberField.js +25 -17
- package/es/lib/NumberField/NumberField.test.js +7 -6
- package/es/lib/QueryTypedown/QueryTypedown.js +15 -8
- package/es/lib/RefdataButtons/RefdataButtons.js +9 -6
- package/es/lib/RefdataCategoriesSettings/RefdataCategoriesSettings.js +26 -19
- package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +60 -48
- package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +6 -5
- package/es/lib/RichSelect/RichSelect.js +36 -31
- package/es/lib/RichSelect/useSelectedOption.js +2 -1
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +94 -91
- package/es/lib/SASQLookupComponent/TableBody/TableBody.js +51 -41
- package/es/lib/SASQRoute/SASQRoute.js +29 -25
- package/es/lib/SASQViewComponent/SASQViewComponent.js +76 -68
- package/es/lib/SearchField/SearchField.js +13 -7
- package/es/lib/SearchKeyControl/SearchKeyControl.js +13 -8
- package/es/lib/SearchKeyControl/SearchKeyControl.test.js +6 -2
- package/es/lib/SettingPage/SettingPagePane/SettingPagePane.js +2 -2
- package/es/lib/SettingsFormContainer/SettingsFormContainer.js +35 -30
- package/es/lib/Tags/Tags.js +8 -5
- package/es/lib/Tags/hooks/useTags.js +1 -1
- package/es/lib/Tags/hooks/useTagsEnabled.js +1 -1
- package/es/lib/Tags/tagsConfig.js +1 -1
- package/es/lib/Typedown/Typedown.js +28 -21
- package/es/lib/hooks/__mocks__/index.js +7 -3
- package/es/lib/hooks/intlHooks/useIntlKeyStore/useIntlKeyStore.js +26 -20
- package/es/lib/hooks/intlHooks/useKintIntl/useKintIntl.js +34 -24
- package/es/lib/hooks/typedownHooks/useTypedown.js +2 -2
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +2 -2
- package/es/lib/hooks/useActionListRef.js +1 -1
- package/es/lib/hooks/useActiveElement.js +1 -1
- package/es/lib/hooks/useCustomProperties.js +10 -6
- package/es/lib/hooks/useHelperApp.js +16 -13
- package/es/lib/hooks/useKiwtFieldArray.js +8 -7
- package/es/lib/hooks/useKiwtSASQuery.js +19 -15
- package/es/lib/hooks/useLocalPageStore.js +10 -7
- package/es/lib/hooks/useModConfigEntries.js +2 -2
- package/es/lib/hooks/useMutateCustomProperties/useMutateCustomProperties.js +17 -10
- package/es/lib/hooks/useMutateGeneric/useMutateGeneric.js +2 -2
- package/es/lib/hooks/useMutateModConfigEntry.js +2 -2
- package/es/lib/hooks/useMutateRefdataCategory/useMutateRefdataCategory.js +21 -15
- package/es/lib/hooks/useMutateRefdataValue/useMutateRefdataValue.js +23 -16
- package/es/lib/hooks/usePrevNextPagination.js +19 -17
- package/es/lib/hooks/useQIndex.js +14 -11
- package/es/lib/hooks/useRefdata.js +3 -3
- package/es/lib/hooks/useTemplates.js +4 -4
- package/es/lib/settingsHooks/useAppSettings/useAppSettings.js +11 -7
- package/es/lib/settingsHooks/useSettingSection/useSettingSection.js +18 -12
- package/es/lib/settingsHooks/useSettings/useSettings.js +60 -60
- package/es/lib/utils/buildUrl.js +3 -2
- package/es/lib/utils/filterParsers/deparseKiwtQueryFilters.js +5 -5
- package/es/lib/utils/filterParsers/parseKiwtQueryFilters.js +2 -2
- package/es/lib/utils/filterParsers/parseKiwtQueryGroups.js +5 -4
- package/es/lib/utils/filterParsers/parseKiwtQueryString.js +1 -1
- package/es/lib/utils/generateKiwtQueryParams/generateKiwtQueryParams.js +82 -70
- package/es/lib/utils/groupCustomPropertiesByCtx.js +9 -5
- package/es/lib/utils/matchString.js +7 -5
- package/es/lib/utils/parseErrorResponse.js +4 -3
- package/es/lib/utils/selectorSafe.js +3 -2
- package/es/lib/utils/sortByLabel.js +3 -2
- package/es/lib/validators/validators.js +9 -6
- package/package.json +1 -1
- package/src/lib/SASQViewComponent/SASQViewComponent.js +2 -3
- package/styles/TypeDown.css +3 -1
|
@@ -12,19 +12,28 @@ var _useParseActiveFilterStrings = _interopRequireDefault(require("./useParseAct
|
|
|
12
12
|
var _CustomPropertiesFilterForm = _interopRequireDefault(require("./CustomPropertiesFilterForm"));
|
|
13
13
|
var _customProperties = require("../../constants/customProperties");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
const _excluded = ["customProperties"];
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
23
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
16
24
|
const CustomPropertiesFilter = _ref => {
|
|
25
|
+
var _parsedFilterData$num, _parsedFilterData$num2;
|
|
17
26
|
let {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
activeFilters: {
|
|
28
|
+
customProperties: custPropFilters
|
|
29
|
+
},
|
|
30
|
+
customPropertiesEndpoint,
|
|
31
|
+
filterHandlers,
|
|
32
|
+
intlKey: passedIntlKey,
|
|
33
|
+
intlNS: passedIntlNS,
|
|
34
|
+
labelOverrides = {}
|
|
35
|
+
} = _ref,
|
|
36
|
+
restOfFilters = _objectWithoutProperties(_ref.activeFilters, _excluded);
|
|
28
37
|
const [editingFilters, setEditingFilters] = (0, _react.useState)(false);
|
|
29
38
|
const openEditModal = () => setEditingFilters(true);
|
|
30
39
|
const closeEditModal = () => setEditingFilters(false);
|
|
@@ -73,30 +82,32 @@ const CustomPropertiesFilter = _ref => {
|
|
|
73
82
|
filters = []
|
|
74
83
|
} = values;
|
|
75
84
|
const filterStrings = filters.filter(filter => filter.rules).map(filter => {
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
85
|
+
var _custprops$filter$, _custprops$filter;
|
|
86
|
+
const relevantCustomProperty = (_custprops$filter$ = custprops === null || custprops === void 0 || (_custprops$filter = custprops.filter(cp => cp.name === filter.customProperty)) === null || _custprops$filter === void 0 ? void 0 : _custprops$filter[0]) !== null && _custprops$filter$ !== void 0 ? _custprops$filter$ : {};
|
|
87
|
+
const filterByValueId = (relevantCustomProperty === null || relevantCustomProperty === void 0 ? void 0 : relevantCustomProperty.type) === _customProperties.MULTI_REFDATA_CLASS_NAME || (relevantCustomProperty === null || relevantCustomProperty === void 0 ? void 0 : relevantCustomProperty.type) === _customProperties.REFDATA_CLASS_NAME;
|
|
88
|
+
return filter.rules.map(rule => {
|
|
89
|
+
var _rule$value;
|
|
90
|
+
return "customProperties.".concat(filter.customProperty, ".value").concat(filterByValueId ? '.id' : '').concat(rule.operator).concat((_rule$value = rule.value) !== null && _rule$value !== void 0 ? _rule$value : '');
|
|
91
|
+
}).join('||');
|
|
79
92
|
});
|
|
80
|
-
filterHandlers.state({
|
|
81
|
-
...restOfFilters,
|
|
93
|
+
filterHandlers.state(_objectSpread(_objectSpread({}, restOfFilters), {}, {
|
|
82
94
|
customProperties: filterStrings
|
|
83
|
-
});
|
|
95
|
+
}));
|
|
84
96
|
setEditingFilters(false);
|
|
85
97
|
return Promise.resolve();
|
|
86
98
|
};
|
|
87
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Accordion, {
|
|
88
100
|
closedByDefault: true,
|
|
89
|
-
displayClearButton: (parsedFilterData
|
|
101
|
+
displayClearButton: ((_parsedFilterData$num = parsedFilterData === null || parsedFilterData === void 0 ? void 0 : parsedFilterData.numberOfFilters) !== null && _parsedFilterData$num !== void 0 ? _parsedFilterData$num : 0) > 0,
|
|
90
102
|
header: _components.FilterAccordionHeader,
|
|
91
103
|
id: "clickable-custprop-filter",
|
|
92
104
|
label: kintIntl.formatKintMessage({
|
|
93
105
|
id: 'customProperties',
|
|
94
106
|
overrideValue: labelOverrides.customProperties
|
|
95
107
|
}),
|
|
96
|
-
onClearFilter: () => filterHandlers.state({
|
|
97
|
-
...restOfFilters,
|
|
108
|
+
onClearFilter: () => filterHandlers.state(_objectSpread(_objectSpread({}, restOfFilters), {}, {
|
|
98
109
|
customProperties: []
|
|
99
|
-
}),
|
|
110
|
+
})),
|
|
100
111
|
separator: false,
|
|
101
112
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Layout, {
|
|
102
113
|
className: "padding-bottom-gutter",
|
|
@@ -104,12 +115,12 @@ const CustomPropertiesFilter = _ref => {
|
|
|
104
115
|
id: 'customProperty.filtersApplied',
|
|
105
116
|
overrideValue: labelOverrides.filtersApplied
|
|
106
117
|
}, {
|
|
107
|
-
count: parsedFilterData
|
|
118
|
+
count: (_parsedFilterData$num2 = parsedFilterData === null || parsedFilterData === void 0 ? void 0 : parsedFilterData.numberOfFilters) !== null && _parsedFilterData$num2 !== void 0 ? _parsedFilterData$num2 : 0
|
|
108
119
|
})
|
|
109
120
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesFilterForm.default, {
|
|
110
121
|
customProperties: custprops,
|
|
111
122
|
editingFilters: editingFilters,
|
|
112
|
-
filters: parsedFilterData
|
|
123
|
+
filters: parsedFilterData === null || parsedFilterData === void 0 ? void 0 : parsedFilterData.filters,
|
|
113
124
|
handlers: {
|
|
114
125
|
closeEditModal,
|
|
115
126
|
openEditModal
|
|
@@ -14,7 +14,13 @@ var _CustomPropertiesRule = _interopRequireDefault(require("./CustomPropertiesRu
|
|
|
14
14
|
var _hooks = require("../../hooks");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
22
|
const CustomPropertiesFilterField = _ref => {
|
|
23
|
+
var _customProperties$fin, _customProperties$fin2, _fields$value$index2;
|
|
18
24
|
let {
|
|
19
25
|
customProperties = [],
|
|
20
26
|
fields,
|
|
@@ -37,23 +43,23 @@ const CustomPropertiesFilterField = _ref => {
|
|
|
37
43
|
const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
|
|
38
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
39
45
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
40
|
-
id:
|
|
46
|
+
id: "input-custprop-".concat(index),
|
|
41
47
|
label: kintIntl.formatKintMessage({
|
|
42
48
|
id: 'customProperty',
|
|
43
49
|
overrideValue: labelOverrides.customProperty
|
|
44
50
|
}),
|
|
45
|
-
name:
|
|
51
|
+
name: "".concat(name, ".customProperty"),
|
|
46
52
|
placeholder: " ",
|
|
47
53
|
render: fieldProps => {
|
|
48
|
-
|
|
54
|
+
var _Object$entries;
|
|
55
|
+
const sortedGroupedCustProps = (_Object$entries = Object.entries(groupedCustomProperties)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.sort((a, b) => {
|
|
49
56
|
if (a[0] === 'isNull') return -1; // Make sure noContext is at top
|
|
50
57
|
|
|
51
58
|
if (a[0].toLowerCase() < b[0].toLowerCase()) return -1;
|
|
52
59
|
if (a[0].toLowerCase() > b[0].toLowerCase()) return 1;
|
|
53
60
|
return 0;
|
|
54
61
|
});
|
|
55
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Select, {
|
|
56
|
-
...fieldProps,
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Select, _objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
57
63
|
placeholder: null // placeholder default causes issues
|
|
58
64
|
,
|
|
59
65
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
|
|
@@ -74,19 +80,22 @@ const CustomPropertiesFilterField = _ref => {
|
|
|
74
80
|
}) : v.label
|
|
75
81
|
}, v.id);
|
|
76
82
|
})
|
|
77
|
-
},
|
|
83
|
+
}, "custom-property-optgroup-".concat(key));
|
|
78
84
|
})]
|
|
79
|
-
});
|
|
85
|
+
}));
|
|
80
86
|
},
|
|
81
87
|
required: true,
|
|
82
88
|
validate: _validators.required
|
|
83
89
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
84
|
-
"data-testid":
|
|
85
|
-
id:
|
|
90
|
+
"data-testid": "selected-custprop-name-".concat(index),
|
|
91
|
+
id: "selected-custprop-name-".concat(index),
|
|
86
92
|
style: {
|
|
87
93
|
display: 'none'
|
|
88
94
|
},
|
|
89
|
-
children: customProperties.find(t =>
|
|
95
|
+
children: (_customProperties$fin = (_customProperties$fin2 = customProperties.find(t => {
|
|
96
|
+
var _fields$value$index;
|
|
97
|
+
return t.name === ((_fields$value$index = fields.value[index]) === null || _fields$value$index === void 0 ? void 0 : _fields$value$index.customProperty);
|
|
98
|
+
})) === null || _customProperties$fin2 === void 0 ? void 0 : _customProperties$fin2.label) !== null && _customProperties$fin !== void 0 ? _customProperties$fin : ''
|
|
90
99
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Row, {
|
|
91
100
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
92
101
|
xs: 2
|
|
@@ -114,26 +123,29 @@ const CustomPropertiesFilterField = _ref => {
|
|
|
114
123
|
xs: 2
|
|
115
124
|
})]
|
|
116
125
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalFormArrays.FieldArray, {
|
|
117
|
-
name:
|
|
126
|
+
name: "".concat(name, ".rules"),
|
|
118
127
|
children: _ref3 => {
|
|
119
128
|
let {
|
|
120
129
|
fields: ruleFields
|
|
121
130
|
} = _ref3;
|
|
122
|
-
return ruleFields.map((ruleFieldName, ruleFieldIndex) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
return ruleFields.map((ruleFieldName, ruleFieldIndex) => {
|
|
132
|
+
var _values$filters$index;
|
|
133
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesRule.default, {
|
|
134
|
+
ariaLabelledby: "selected-custprop-name-".concat(index),
|
|
135
|
+
clearRuleValue: () => change("filters[".concat(index, "].rules[").concat(ruleFieldIndex, "].value"), ''),
|
|
136
|
+
custPropDefinition: customProperties.find(t => t.name === fields.value[index].customProperty),
|
|
137
|
+
index: ruleFieldIndex,
|
|
138
|
+
labelOverrides: labelOverrides,
|
|
139
|
+
name: ruleFieldName,
|
|
140
|
+
onDelete: () => ruleFields.remove(ruleFieldIndex),
|
|
141
|
+
value: (_values$filters$index = values.filters[index]) === null || _values$filters$index === void 0 ? void 0 : _values$filters$index.rules[ruleFieldIndex]
|
|
142
|
+
}, ruleFieldName);
|
|
143
|
+
});
|
|
132
144
|
}
|
|
133
145
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
134
146
|
"data-test-add-rule-btn": true,
|
|
135
|
-
disabled: !fields.value[index]
|
|
136
|
-
onClick: () => push(
|
|
147
|
+
disabled: !((_fields$value$index2 = fields.value[index]) !== null && _fields$value$index2 !== void 0 && _fields$value$index2.customProperty),
|
|
148
|
+
onClick: () => push("".concat(name, ".rules")),
|
|
137
149
|
children: kintIntl.formatKintMessage({
|
|
138
150
|
id: 'addRule',
|
|
139
151
|
overrideValue: labelOverrides.addRule
|
|
@@ -36,7 +36,7 @@ const CustomPropertiesFilterFieldArray = _ref => {
|
|
|
36
36
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
37
37
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Card, {
|
|
38
38
|
headerEnd: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
39
|
-
id:
|
|
39
|
+
id: "custom-property-filter-card-delete-[".concat(index, "]-tooltip"),
|
|
40
40
|
text: kintIntl.formatKintMessage({
|
|
41
41
|
id: 'customProperty.removeFilter',
|
|
42
42
|
overrideValue: labelOverrides.removeFilter
|
|
@@ -52,7 +52,7 @@ const CustomPropertiesFilterFieldArray = _ref => {
|
|
|
52
52
|
ref: ref,
|
|
53
53
|
"aria-labelledby": ariaIds.text,
|
|
54
54
|
icon: "trash",
|
|
55
|
-
id:
|
|
55
|
+
id: "custom-property-filter-card-delete-[".concat(index, "]"),
|
|
56
56
|
onClick: () => fields.remove(index)
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -72,15 +72,15 @@ const CustomPropertiesFilterFieldArray = _ref => {
|
|
|
72
72
|
index: index,
|
|
73
73
|
labelOverrides: labelOverrides,
|
|
74
74
|
name: name
|
|
75
|
-
},
|
|
76
|
-
},
|
|
75
|
+
}, "custom-property-filter-field-".concat(name, "[").concat(index, "]"))
|
|
76
|
+
}, "custom-property-filter-card[".concat(index, "]")), index < fields.value.length - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Layout, {
|
|
77
77
|
className: "textCentered",
|
|
78
78
|
children: kintIntl.formatKintMessage({
|
|
79
79
|
id: 'AND',
|
|
80
80
|
overrideValue: labelOverrides.AND
|
|
81
81
|
})
|
|
82
|
-
},
|
|
83
|
-
},
|
|
82
|
+
}, "custom-property-filter[".concat(index, "]-AND"))]
|
|
83
|
+
}, "custom-property-filter-card[".concat(index, "]-container"));
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
@@ -12,6 +12,11 @@ var _CustomPropertiesFilterFieldArray = _interopRequireDefault(require("./Custom
|
|
|
12
12
|
var _hooks = require("../../hooks");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
20
|
const CustomPropertyFiltersForm = _ref => {
|
|
16
21
|
let {
|
|
17
22
|
customProperties,
|
|
@@ -57,9 +62,7 @@ const CustomPropertyFiltersForm = _ref => {
|
|
|
57
62
|
open: editingFilters,
|
|
58
63
|
size: 'medium'
|
|
59
64
|
},
|
|
60
|
-
mutators: {
|
|
61
|
-
..._finalFormArrays.default
|
|
62
|
-
},
|
|
65
|
+
mutators: _objectSpread({}, _finalFormArrays.default),
|
|
63
66
|
onSubmit: onSubmit,
|
|
64
67
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesFilterFieldArray.default, {
|
|
65
68
|
customProperties: customProperties,
|
|
@@ -7,6 +7,11 @@ var _testResources = require("./testResources");
|
|
|
7
7
|
var _jest = require("../../../../test/jest");
|
|
8
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
15
|
jest.mock('../../hooks');
|
|
11
16
|
jest.mock('./CustomPropertiesFilterFieldArray', () => () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
12
17
|
children: "CustomPropertiesFilterFieldArray"
|
|
@@ -15,10 +20,9 @@ const onSubmit = jest.fn();
|
|
|
15
20
|
describe('CustomPropertyFiltersForm', () => {
|
|
16
21
|
let renderComponent;
|
|
17
22
|
beforeEach(() => {
|
|
18
|
-
renderComponent = (0, _jest.renderWithKintHarness)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesFilterForm.default, {
|
|
19
|
-
onSubmit: onSubmit
|
|
20
|
-
|
|
21
|
-
}));
|
|
23
|
+
renderComponent = (0, _jest.renderWithKintHarness)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesFilterForm.default, _objectSpread({
|
|
24
|
+
onSubmit: onSubmit
|
|
25
|
+
}, _testResources.data)));
|
|
22
26
|
});
|
|
23
27
|
it('renders CustomPropertiesFilterFieldArray component ', () => {
|
|
24
28
|
const {
|
|
@@ -15,6 +15,11 @@ var _useOperators = _interopRequireDefault(require("./useOperators"));
|
|
|
15
15
|
var _hooks = require("../../hooks");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
23
|
const propTypes = {
|
|
19
24
|
ariaLabelledby: _propTypes.default.string.isRequired,
|
|
20
25
|
clearRuleValue: _propTypes.default.func.isRequired,
|
|
@@ -51,7 +56,7 @@ const CustomPropertiesRule = _ref => {
|
|
|
51
56
|
const operators = (0, _useOperators.default)(custPropDefinition.type, passedIntlKey, passedIntlNS, labelOverrides);
|
|
52
57
|
const valueProps = (0, _useValueProps.default)(custPropDefinition, passedIntlKey, passedIntlNS, labelOverrides);
|
|
53
58
|
const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
|
|
54
|
-
const selectedOperator = operators.find(o => o.value === value
|
|
59
|
+
const selectedOperator = operators.find(o => o.value === (value === null || value === void 0 ? void 0 : value.operator));
|
|
55
60
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Row, {
|
|
56
61
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
57
62
|
xs: 2,
|
|
@@ -65,39 +70,37 @@ const CustomPropertiesRule = _ref => {
|
|
|
65
70
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
66
71
|
xs: 4,
|
|
67
72
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
68
|
-
name:
|
|
73
|
+
name: "".concat(name, ".operator"),
|
|
69
74
|
validate: _validators.required,
|
|
70
75
|
children: _ref2 => {
|
|
71
76
|
let {
|
|
72
77
|
input,
|
|
73
78
|
meta
|
|
74
79
|
} = _ref2;
|
|
75
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Select, {
|
|
76
|
-
|
|
77
|
-
"aria-labelledby": `${ariaLabelledby}-rule-column-header-comparator`,
|
|
80
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Select, _objectSpread(_objectSpread({}, input), {}, {
|
|
81
|
+
"aria-labelledby": "".concat(ariaLabelledby, "-rule-column-header-comparator"),
|
|
78
82
|
dataOptions: operators,
|
|
79
|
-
error: meta
|
|
83
|
+
error: (meta === null || meta === void 0 ? void 0 : meta.touched) && (meta === null || meta === void 0 ? void 0 : meta.error),
|
|
80
84
|
onChange: e => {
|
|
81
85
|
input.onChange(e);
|
|
82
86
|
const newlySelectedOperator = operators.find(o => o.value === e.target.value);
|
|
83
|
-
if (newlySelectedOperator
|
|
87
|
+
if (newlySelectedOperator !== null && newlySelectedOperator !== void 0 && newlySelectedOperator.noValueAllowed) {
|
|
84
88
|
clearRuleValue();
|
|
85
89
|
}
|
|
86
90
|
},
|
|
87
91
|
placeholder: " ",
|
|
88
92
|
required: true
|
|
89
|
-
});
|
|
93
|
+
}));
|
|
90
94
|
}
|
|
91
95
|
})
|
|
92
96
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
93
97
|
xs: 4,
|
|
94
|
-
children: selectedOperator
|
|
95
|
-
"aria-labelledby":
|
|
96
|
-
name:
|
|
98
|
+
children: selectedOperator !== null && selectedOperator !== void 0 && selectedOperator.noValueAllowed ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, _objectSpread({
|
|
99
|
+
"aria-labelledby": "".concat(ariaLabelledby, "-rule-column-header-value"),
|
|
100
|
+
name: "".concat(name, ".value"),
|
|
97
101
|
required: true,
|
|
98
|
-
validate: _validators.required
|
|
99
|
-
|
|
100
|
-
})
|
|
102
|
+
validate: _validators.required
|
|
103
|
+
}, valueProps))
|
|
101
104
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
102
105
|
xs: 2,
|
|
103
106
|
children: index ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.filterHandlers = exports.data = exports.activeFilters = void 0;
|
|
7
7
|
var _jest = require("../../../../test/jest");
|
|
8
|
+
var _refdata$find;
|
|
8
9
|
const activeFilters = exports.activeFilters = {
|
|
9
|
-
'customProperties': [
|
|
10
|
+
'customProperties': ["customProperties.AuthorIdentification.value==".concat(_jest.refdata === null || _jest.refdata === void 0 || (_refdata$find = _jest.refdata.find(rdc => rdc.desc === 'AuthIdent')) === null || _refdata$find === void 0 || (_refdata$find = _refdata$find.values) === null || _refdata$find === void 0 || (_refdata$find = _refdata$find.find(rdv => rdv.value === 'email_domain')) === null || _refdata$find === void 0 ? void 0 : _refdata$find.id)]
|
|
10
11
|
};
|
|
11
12
|
const filterHandlers = exports.filterHandlers = {
|
|
12
13
|
'state': () => ({}),
|
|
@@ -13,13 +13,14 @@ const useParseActiveFilterStrings = function (filterStrings, passedIntlKey, pass
|
|
|
13
13
|
const filters = filterStrings.map(filter => {
|
|
14
14
|
let customProperty;
|
|
15
15
|
const rules = filter.split('||').map(ruleString => {
|
|
16
|
+
var _operators$find;
|
|
16
17
|
// ruleString is constructed in this.handleSubmit passed to CustomPropertyFiltersForm
|
|
17
18
|
// and has shape "customProperties.foo.value!=42"
|
|
18
19
|
// OR customProperties.foo.value.id==1234, so make sure to disregard the .id
|
|
19
20
|
const [customPropertyPath, rule] = ruleString.split('.value');
|
|
20
21
|
const idSafeRule = rule.replace('.id', '');
|
|
21
22
|
customProperty = customPropertyPath.replace('customProperties.', '');
|
|
22
|
-
const operator = operators.find(o => idSafeRule.startsWith(o))
|
|
23
|
+
const operator = (_operators$find = operators.find(o => idSafeRule.startsWith(o))) !== null && _operators$find !== void 0 ? _operators$find : '';
|
|
23
24
|
const value = idSafeRule.substring(operator.length);
|
|
24
25
|
numberOfFilters += 1;
|
|
25
26
|
return {
|
|
@@ -26,7 +26,7 @@ const CustomPropertiesView = _ref => {
|
|
|
26
26
|
intlKey: passedIntlKey,
|
|
27
27
|
intlNS: passedIntlNS,
|
|
28
28
|
labelOverrides
|
|
29
|
-
},
|
|
29
|
+
}, "customPropertiesView-".concat(ctx)));
|
|
30
30
|
};
|
|
31
31
|
CustomPropertiesView.propTypes = {
|
|
32
32
|
contexts: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
@@ -11,6 +11,7 @@ var _CustomPropertyCard = _interopRequireDefault(require("./CustomPropertyCard")
|
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
const CustomPropertiesViewCtx = _ref => {
|
|
14
|
+
var _custprops$filter$len, _custprops$filter;
|
|
14
15
|
let {
|
|
15
16
|
ctx,
|
|
16
17
|
customProperties = [],
|
|
@@ -35,7 +36,7 @@ const CustomPropertiesViewCtx = _ref => {
|
|
|
35
36
|
// Chain formatKintMessages together using provided fallbackMessage to
|
|
36
37
|
// allow for "If override or translation exists, use it, else use default"
|
|
37
38
|
return kintIntl.formatKintMessage({
|
|
38
|
-
id:
|
|
39
|
+
id: "customProperties.ctx.".concat(ctx),
|
|
39
40
|
overrideValue: labelOverrides[ctx],
|
|
40
41
|
fallbackMessage: kintIntl.formatKintMessage({
|
|
41
42
|
id: 'customProperties.defaultTitle',
|
|
@@ -79,21 +80,25 @@ const CustomPropertiesViewCtx = _ref => {
|
|
|
79
80
|
closedByDefault: true,
|
|
80
81
|
displayWhenClosed: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {}),
|
|
81
82
|
displayWhenOpen: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {}),
|
|
82
|
-
id:
|
|
83
|
+
id: "".concat(id, "-accordion-").concat(ctx),
|
|
83
84
|
label: getAccordionLabel(),
|
|
84
85
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
|
-
const countSetProperties = primary =>
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
const countSetProperties = primary => {
|
|
89
|
+
var _Object$entries$filte, _Object$entries;
|
|
90
|
+
return (_Object$entries$filte = (_Object$entries = Object.entries(customProperties)) === null || _Object$entries === void 0 || (_Object$entries = _Object$entries.filter(_ref2 => {
|
|
91
|
+
var _cp$, _cp$2, _cp$3;
|
|
92
|
+
let [_key, cp] = _ref2;
|
|
93
|
+
return (((_cp$ = cp[0]) === null || _cp$ === void 0 || (_cp$ = _cp$.type) === null || _cp$ === void 0 ? void 0 : _cp$.ctx) === ctx || ctx === 'isNull' && !((_cp$2 = cp[0]) !== null && _cp$2 !== void 0 && (_cp$2 = _cp$2.type) !== null && _cp$2 !== void 0 && _cp$2.ctx)) &&
|
|
94
|
+
// Either the ctx string matches, or isNull matches blank
|
|
95
|
+
((_cp$3 = cp[0]) === null || _cp$3 === void 0 || (_cp$3 = _cp$3.type) === null || _cp$3 === void 0 ? void 0 : _cp$3.primary) === primary // Only count non-primary set custprops
|
|
96
|
+
;
|
|
97
|
+
})) === null || _Object$entries === void 0 ? void 0 : _Object$entries.length) !== null && _Object$entries$filte !== void 0 ? _Object$entries$filte : 0;
|
|
98
|
+
};
|
|
94
99
|
|
|
95
100
|
// We need to display any set properties, along with any non-set primary properties
|
|
96
|
-
const primaryCount = custprops
|
|
101
|
+
const primaryCount = (_custprops$filter$len = custprops === null || custprops === void 0 || (_custprops$filter = custprops.filter(cp => cp.primary === true)) === null || _custprops$filter === void 0 ? void 0 : _custprops$filter.length) !== null && _custprops$filter$len !== void 0 ? _custprops$filter$len : 0;
|
|
97
102
|
const optionalCount = countSetProperties(false);
|
|
98
103
|
const setPrimaryCount = countSetProperties(true);
|
|
99
104
|
return primaryCount + optionalCount > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Accordion, {
|
|
@@ -104,15 +109,18 @@ const CustomPropertiesViewCtx = _ref => {
|
|
|
104
109
|
displayWhenOpen: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Badge, {
|
|
105
110
|
children: setPrimaryCount + optionalCount
|
|
106
111
|
}),
|
|
107
|
-
id:
|
|
112
|
+
id: "".concat(id, "-accordion-").concat(ctx),
|
|
108
113
|
label: getAccordionLabel(),
|
|
109
|
-
children: custprops.map((cp, index) =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
children: custprops.map((cp, index) => {
|
|
115
|
+
var _customProperties$cp$;
|
|
116
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertyCard.default, {
|
|
117
|
+
ctx: ctx,
|
|
118
|
+
customProperty: customProperties === null || customProperties === void 0 || (_customProperties$cp$ = customProperties[cp.name]) === null || _customProperties$cp$ === void 0 ? void 0 : _customProperties$cp$[0],
|
|
119
|
+
customPropertyDefinition: cp,
|
|
120
|
+
index: index,
|
|
121
|
+
labelOverrides: labelOverrides
|
|
122
|
+
}, "custom-property-card-".concat(ctx, "[").concat(index, "]"));
|
|
123
|
+
})
|
|
116
124
|
});
|
|
117
125
|
};
|
|
118
126
|
CustomPropertiesViewCtx.propTypes = {
|
|
@@ -8,6 +8,11 @@ var _CustomPropertiesViewCtx = _interopRequireDefault(require("./CustomPropertie
|
|
|
8
8
|
var _jest = require("../../../../test/jest");
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
16
|
jest.mock('../../hooks');
|
|
12
17
|
jest.mock('./CustomPropertyCard', () => () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
13
18
|
children: "CustomPropertyCard"
|
|
@@ -16,9 +21,7 @@ describe('CustomPropertiesViewCtx', () => {
|
|
|
16
21
|
let renderComponent;
|
|
17
22
|
beforeEach(() => {
|
|
18
23
|
renderComponent = (0, _jest.renderWithKintHarness)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.MemoryRouter, {
|
|
19
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesViewCtx.default, {
|
|
20
|
-
..._testResources.data
|
|
21
|
-
})
|
|
24
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomPropertiesViewCtx.default, _objectSpread({}, _testResources.data))
|
|
22
25
|
}));
|
|
23
26
|
});
|
|
24
27
|
it('renders CustomPropertyCard component ', () => {
|
|
@@ -29,8 +29,9 @@ const CustomPropertyCard = _ref => {
|
|
|
29
29
|
if (!toDisplay) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
-
const internalFalse = customProperty
|
|
32
|
+
const internalFalse = (customProperty === null || customProperty === void 0 ? void 0 : customProperty.internal) === false || (customProperty === null || customProperty === void 0 ? void 0 : customProperty.internal) === undefined && customPropertyDefinition.defaultInternal === false;
|
|
33
33
|
const renderValue = () => {
|
|
34
|
+
var _customProperty$value, _customProperty$value2, _customProperty$value3, _customProperty$value4;
|
|
34
35
|
if (!customProperty) {
|
|
35
36
|
return kintIntl.formatKintMessage({
|
|
36
37
|
id: 'notSet',
|
|
@@ -40,11 +41,14 @@ const CustomPropertyCard = _ref => {
|
|
|
40
41
|
switch (customPropertyDefinition.type) {
|
|
41
42
|
case CUSTPROP_TYPES.MULTI_REFDATA_CLASS_NAME:
|
|
42
43
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.List, {
|
|
43
|
-
items: customProperty.value
|
|
44
|
+
items: (_customProperty$value = customProperty.value) === null || _customProperty$value === void 0 ? void 0 : _customProperty$value.map(item => {
|
|
45
|
+
var _item$label;
|
|
46
|
+
return (_item$label = item === null || item === void 0 ? void 0 : item.label) !== null && _item$label !== void 0 ? _item$label : item === null || item === void 0 ? void 0 : item.value;
|
|
47
|
+
}),
|
|
44
48
|
listStyle: "bullets"
|
|
45
49
|
});
|
|
46
50
|
case CUSTPROP_TYPES.REFDATA_CLASS_NAME:
|
|
47
|
-
return customProperty.value
|
|
51
|
+
return (_customProperty$value2 = (_customProperty$value3 = customProperty.value) === null || _customProperty$value3 === void 0 ? void 0 : _customProperty$value3.label) !== null && _customProperty$value2 !== void 0 ? _customProperty$value2 : (_customProperty$value4 = customProperty.value) === null || _customProperty$value4 === void 0 ? void 0 : _customProperty$value4.value;
|
|
48
52
|
case CUSTPROP_TYPES.DECIMAL_CLASS_NAME:
|
|
49
53
|
case CUSTPROP_TYPES.INTEGER_CLASS_NAME:
|
|
50
54
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedNumber, {
|
|
@@ -72,7 +76,7 @@ const CustomPropertyCard = _ref => {
|
|
|
72
76
|
content: customPropertyDefinition.description
|
|
73
77
|
}) : null]
|
|
74
78
|
}),
|
|
75
|
-
id:
|
|
79
|
+
id: "customproperty-card-".concat(index),
|
|
76
80
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Row, {
|
|
77
81
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
78
82
|
xs: 6,
|
|
@@ -83,7 +87,7 @@ const CustomPropertyCard = _ref => {
|
|
|
83
87
|
}),
|
|
84
88
|
children: renderValue()
|
|
85
89
|
})
|
|
86
|
-
}), customProperty
|
|
90
|
+
}), customProperty !== null && customProperty !== void 0 && customProperty.note ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Col, {
|
|
87
91
|
xs: 6,
|
|
88
92
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.KeyValue, {
|
|
89
93
|
label: kintIntl.formatKintMessage({
|
|
@@ -118,7 +122,7 @@ const CustomPropertyCard = _ref => {
|
|
|
118
122
|
id: 'customProperties.publicNote',
|
|
119
123
|
overrideValue: labelOverrides.publicNote
|
|
120
124
|
}),
|
|
121
|
-
children: customProperty
|
|
125
|
+
children: customProperty !== null && customProperty !== void 0 && customProperty.publicNote ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
122
126
|
style: {
|
|
123
127
|
whiteSpace: 'pre-wrap'
|
|
124
128
|
},
|
|
@@ -127,7 +131,7 @@ const CustomPropertyCard = _ref => {
|
|
|
127
131
|
})
|
|
128
132
|
})]
|
|
129
133
|
})]
|
|
130
|
-
},
|
|
134
|
+
}, "customPropertyCard-".concat(ctx, "[").concat(index, "]"));
|
|
131
135
|
};
|
|
132
136
|
CustomPropertyCard.propTypes = {
|
|
133
137
|
ctx: _propTypes.default.string,
|