@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
|
@@ -10,28 +10,36 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
10
10
|
var _components = require("@folio/stripes/components");
|
|
11
11
|
var _CycleButton = _interopRequireDefault(require("../../../styles/CycleButton.css"));
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
const _excluded = ["className", "onClick"];
|
|
13
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
14
22
|
const CycleButton = _ref => {
|
|
15
23
|
let {
|
|
16
24
|
buttons,
|
|
17
25
|
startIndex = 0
|
|
18
26
|
} = _ref;
|
|
19
27
|
const [index, setIndex] = (0, _react.useState)(startIndex);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
const _buttons$index = buttons[index],
|
|
29
|
+
{
|
|
30
|
+
className,
|
|
31
|
+
onClick
|
|
32
|
+
} = _buttons$index,
|
|
33
|
+
buttonProps = _objectWithoutProperties(_buttons$index, _excluded);
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
27
35
|
className: (0, _classnames.default)(className, _CycleButton.default.buttonStyle),
|
|
28
36
|
onClick: e => {
|
|
29
37
|
if (onClick) {
|
|
30
38
|
onClick(e);
|
|
31
39
|
}
|
|
32
|
-
setIndex(index !== buttons
|
|
40
|
+
setIndex(index !== (buttons === null || buttons === void 0 ? void 0 : buttons.length) - 1 ? index + 1 : 0);
|
|
33
41
|
}
|
|
34
|
-
});
|
|
42
|
+
}));
|
|
35
43
|
};
|
|
36
44
|
CycleButton.propTypes = {
|
|
37
45
|
buttons: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -16,6 +16,11 @@ var _utils = require("../utils");
|
|
|
16
16
|
var _CustomProperties = _interopRequireDefault(require("../../../styles/CustomProperties.css"));
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
23
|
+
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); }
|
|
19
24
|
const propTypes = {
|
|
20
25
|
afterQueryCalls: _propTypes.default.object,
|
|
21
26
|
catchQueryCalls: _propTypes.default.object,
|
|
@@ -35,6 +40,7 @@ const propTypes = {
|
|
|
35
40
|
refdataEndpoint: _propTypes.default.string
|
|
36
41
|
};
|
|
37
42
|
const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
43
|
+
var _deleteModal$refdata2;
|
|
38
44
|
let {
|
|
39
45
|
afterQueryCalls,
|
|
40
46
|
catchQueryCalls,
|
|
@@ -88,10 +94,12 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
88
94
|
(0, _react.useEffect)(() => {
|
|
89
95
|
if (!isRefdataLoading) {
|
|
90
96
|
if (searchTerm) {
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
var _filteredRefdata$sort;
|
|
98
|
+
const filteredRefdata = refdata === null || refdata === void 0 ? void 0 : refdata.filter(rd => rd.desc.toLowerCase().includes(searchTerm.toLowerCase()));
|
|
99
|
+
setContentData((_filteredRefdata$sort = filteredRefdata === null || filteredRefdata === void 0 ? void 0 : filteredRefdata.sort(sortByDesc)) !== null && _filteredRefdata$sort !== void 0 ? _filteredRefdata$sort : []);
|
|
93
100
|
} else {
|
|
94
|
-
|
|
101
|
+
var _refdata$sort;
|
|
102
|
+
setContentData((_refdata$sort = refdata === null || refdata === void 0 ? void 0 : refdata.sort(sortByDesc)) !== null && _refdata$sort !== void 0 ? _refdata$sort : []);
|
|
95
103
|
}
|
|
96
104
|
}
|
|
97
105
|
}, [isRefdataLoading, refdata, searchTerm]);
|
|
@@ -103,36 +111,36 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
103
111
|
} = (0, _hooks.useMutateRefdataCategory)({
|
|
104
112
|
afterQueryCalls: {
|
|
105
113
|
delete: json => {
|
|
106
|
-
if (afterQueryCalls
|
|
114
|
+
if (afterQueryCalls !== null && afterQueryCalls !== void 0 && afterQueryCalls.delete) {
|
|
107
115
|
afterQueryCalls.delete(json);
|
|
108
116
|
}
|
|
109
117
|
},
|
|
110
118
|
post: json => {
|
|
111
|
-
if (afterQueryCalls
|
|
119
|
+
if (afterQueryCalls !== null && afterQueryCalls !== void 0 && afterQueryCalls.post) {
|
|
112
120
|
afterQueryCalls.post(json);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
123
|
},
|
|
116
|
-
catchQueryCalls: {
|
|
124
|
+
catchQueryCalls: _objectSpread({
|
|
117
125
|
// Default delete behaviour is to fire a callout, either with kint-components default message
|
|
118
126
|
// or one provided in labelOverrides, which is passed the error message and refdata in question
|
|
119
127
|
delete: async err => {
|
|
128
|
+
var _deleteModal$refdata;
|
|
120
129
|
const errorResp = await (0, _utils.parseErrorResponse)(err.response);
|
|
121
130
|
callout.sendCallout({
|
|
122
131
|
message: kintIntl.formatKintMessage({
|
|
123
132
|
id: 'refdataCategory.deleteRefdataCategory.errorMessage',
|
|
124
|
-
overrideValue: labelOverrides
|
|
133
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteError
|
|
125
134
|
}, {
|
|
126
|
-
label: deleteModal
|
|
127
|
-
error: errorResp
|
|
135
|
+
label: deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata = deleteModal.refdata) === null || _deleteModal$refdata === void 0 ? void 0 : _deleteModal$refdata.label,
|
|
136
|
+
error: errorResp === null || errorResp === void 0 ? void 0 : errorResp.message
|
|
128
137
|
}),
|
|
129
138
|
type: 'error'
|
|
130
139
|
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
},
|
|
140
|
+
}
|
|
141
|
+
}, catchQueryCalls),
|
|
134
142
|
endpoint: refdataEndpoint,
|
|
135
|
-
id: refdata
|
|
143
|
+
id: refdata === null || refdata === void 0 ? void 0 : refdata.id,
|
|
136
144
|
queryParams: {
|
|
137
145
|
delete: {
|
|
138
146
|
enabled: !!refdata
|
|
@@ -148,13 +156,14 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
148
156
|
|
|
149
157
|
// This is the function which will take a row in the table and assign the relevant actions to it
|
|
150
158
|
const actionAssigner = rowData => {
|
|
159
|
+
var _rowData$values;
|
|
151
160
|
const actionArray = [];
|
|
152
|
-
if (!rowData
|
|
161
|
+
if (!(rowData !== null && rowData !== void 0 && (_rowData$values = rowData.values) !== null && _rowData$values !== void 0 && _rowData$values.length) && deleteCondition) {
|
|
153
162
|
actionArray.push({
|
|
154
163
|
name: 'delete',
|
|
155
164
|
label: kintIntl.formatKintMessage({
|
|
156
165
|
id: 'delete',
|
|
157
|
-
overrideValue: labelOverrides
|
|
166
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.delete
|
|
158
167
|
}),
|
|
159
168
|
icon: 'trash',
|
|
160
169
|
callback: data => setDeleteModal({
|
|
@@ -163,9 +172,9 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
163
172
|
}),
|
|
164
173
|
ariaLabel: data => kintIntl.formatKintMessage({
|
|
165
174
|
id: 'refdataCategory.deleteAriaLabel',
|
|
166
|
-
overrideValue: labelOverrides
|
|
175
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteAriaLabel
|
|
167
176
|
}, {
|
|
168
|
-
label: data
|
|
177
|
+
label: data === null || data === void 0 ? void 0 : data.label
|
|
169
178
|
})
|
|
170
179
|
});
|
|
171
180
|
}
|
|
@@ -191,11 +200,11 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
191
200
|
columnMapping: {
|
|
192
201
|
desc: kintIntl.formatKintMessage({
|
|
193
202
|
id: 'refdataCategory.refdataCategory',
|
|
194
|
-
overrideValue: labelOverrides
|
|
203
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.refdataCategory
|
|
195
204
|
}),
|
|
196
205
|
values: kintIntl.formatKintMessage({
|
|
197
206
|
id: 'refdataCategory.noOfValues',
|
|
198
|
-
overrideValue: labelOverrides
|
|
207
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.noOfValues
|
|
199
208
|
})
|
|
200
209
|
},
|
|
201
210
|
contentData: contentData,
|
|
@@ -209,15 +218,21 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
209
218
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
210
219
|
buttonStyle: "link",
|
|
211
220
|
onClick: () => handleRefdataCategoryClick(rowData),
|
|
212
|
-
children: rowData
|
|
221
|
+
children: rowData === null || rowData === void 0 ? void 0 : rowData.desc
|
|
213
222
|
});
|
|
214
223
|
}
|
|
215
|
-
return rowData
|
|
224
|
+
return rowData === null || rowData === void 0 ? void 0 : rowData.desc;
|
|
216
225
|
},
|
|
217
|
-
values: rowData =>
|
|
226
|
+
values: rowData => {
|
|
227
|
+
var _rowData$values2;
|
|
228
|
+
return rowData === null || rowData === void 0 || (_rowData$values2 = rowData.values) === null || _rowData$values2 === void 0 ? void 0 : _rowData$values2.length;
|
|
229
|
+
}
|
|
218
230
|
}
|
|
219
231
|
/* Hide actions column when no permissions, or no deletable refdata categories */,
|
|
220
|
-
hideActionsColumn: !createCondition && !deleteCondition || !contentData
|
|
232
|
+
hideActionsColumn: !createCondition && !deleteCondition || !(contentData !== null && contentData !== void 0 && contentData.find(cd => {
|
|
233
|
+
var _cd$values;
|
|
234
|
+
return (cd === null || cd === void 0 || (_cd$values = cd.values) === null || _cd$values === void 0 ? void 0 : _cd$values.length) === 0;
|
|
235
|
+
})),
|
|
221
236
|
hideCreateButton: hideCreateButton,
|
|
222
237
|
label: label,
|
|
223
238
|
validateFields: {
|
|
@@ -227,31 +242,32 @@ const EditableRefdataCategoryList = /*#__PURE__*/(0, _react.forwardRef)((_ref, r
|
|
|
227
242
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ConfirmationModal, {
|
|
228
243
|
confirmLabel: kintIntl.formatKintMessage({
|
|
229
244
|
id: 'delete',
|
|
230
|
-
overrideValue: labelOverrides
|
|
245
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.delete
|
|
231
246
|
}),
|
|
232
247
|
heading: kintIntl.formatKintMessage({
|
|
233
248
|
id: 'refdataCategory.deleteRefdataCategory',
|
|
234
|
-
overrideValue: labelOverrides
|
|
249
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteRefdataCategory
|
|
235
250
|
}),
|
|
236
251
|
message: kintIntl.formatKintMessage({
|
|
237
252
|
id: 'refdataCategory.deleteRefdataCategory.confirmMessage',
|
|
238
|
-
overrideValue: labelOverrides
|
|
253
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteRefdataCategoryMessage
|
|
239
254
|
}, {
|
|
240
|
-
name: deleteModal
|
|
255
|
+
name: deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata2 = deleteModal.refdata) === null || _deleteModal$refdata2 === void 0 ? void 0 : _deleteModal$refdata2.desc
|
|
241
256
|
}),
|
|
242
257
|
onCancel: () => setDeleteModal({
|
|
243
258
|
visible: false,
|
|
244
259
|
refdata: null
|
|
245
260
|
}),
|
|
246
261
|
onConfirm: () => {
|
|
247
|
-
|
|
248
|
-
|
|
262
|
+
var _deleteModal$refdata3, _deleteModal$refdata4;
|
|
263
|
+
deleteRefdataCategory(deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata3 = deleteModal.refdata) === null || _deleteModal$refdata3 === void 0 ? void 0 : _deleteModal$refdata3.id);
|
|
264
|
+
onConfirmDelete(deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata4 = deleteModal.refdata) === null || _deleteModal$refdata4 === void 0 ? void 0 : _deleteModal$refdata4.id);
|
|
249
265
|
setDeleteModal({
|
|
250
266
|
visible: false,
|
|
251
267
|
refdata: null
|
|
252
268
|
});
|
|
253
269
|
},
|
|
254
|
-
open: deleteModal
|
|
270
|
+
open: deleteModal === null || deleteModal === void 0 ? void 0 : deleteModal.visible
|
|
255
271
|
})]
|
|
256
272
|
});
|
|
257
273
|
});
|
|
@@ -15,6 +15,11 @@ var _utils = require("../utils");
|
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
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
|
afterQueryCalls: _propTypes.default.object,
|
|
20
25
|
allowSpecial: _propTypes.default.bool,
|
|
@@ -32,6 +37,7 @@ const propTypes = {
|
|
|
32
37
|
refdataEndpoint: _propTypes.default.string
|
|
33
38
|
};
|
|
34
39
|
const EditableRefdataList = _ref => {
|
|
40
|
+
var _deleteModal$refdata2;
|
|
35
41
|
let {
|
|
36
42
|
afterQueryCalls,
|
|
37
43
|
allowSpecial = false,
|
|
@@ -86,7 +92,8 @@ const EditableRefdataList = _ref => {
|
|
|
86
92
|
const sortByLabel = (a, b) => a.label.localeCompare(b.label);
|
|
87
93
|
(0, _react.useEffect)(() => {
|
|
88
94
|
if (!isRefdataLoading) {
|
|
89
|
-
|
|
95
|
+
var _refdata$values$sort, _refdata$values;
|
|
96
|
+
setContentData((_refdata$values$sort = refdata === null || refdata === void 0 || (_refdata$values = refdata.values) === null || _refdata$values === void 0 ? void 0 : _refdata$values.sort(sortByLabel)) !== null && _refdata$values$sort !== void 0 ? _refdata$values$sort : []);
|
|
90
97
|
}
|
|
91
98
|
}, [isRefdataLoading, refdata]);
|
|
92
99
|
|
|
@@ -98,39 +105,41 @@ const EditableRefdataList = _ref => {
|
|
|
98
105
|
} = (0, _hooks.useMutateRefdataValue)({
|
|
99
106
|
afterQueryCalls: {
|
|
100
107
|
delete: json => {
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
var _json$values$sort, _json$values;
|
|
109
|
+
setContentData((_json$values$sort = json === null || json === void 0 || (_json$values = json.values) === null || _json$values === void 0 ? void 0 : _json$values.sort(sortByLabel)) !== null && _json$values$sort !== void 0 ? _json$values$sort : []);
|
|
110
|
+
if (afterQueryCalls !== null && afterQueryCalls !== void 0 && afterQueryCalls.delete) {
|
|
103
111
|
afterQueryCalls.delete(json);
|
|
104
112
|
}
|
|
105
113
|
},
|
|
106
114
|
put: json => {
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
var _json$values$sort2, _json$values2;
|
|
116
|
+
setContentData((_json$values$sort2 = json === null || json === void 0 || (_json$values2 = json.values) === null || _json$values2 === void 0 ? void 0 : _json$values2.sort(sortByLabel)) !== null && _json$values$sort2 !== void 0 ? _json$values$sort2 : []);
|
|
117
|
+
if (afterQueryCalls !== null && afterQueryCalls !== void 0 && afterQueryCalls.put) {
|
|
109
118
|
afterQueryCalls.put(json);
|
|
110
119
|
}
|
|
111
120
|
}
|
|
112
121
|
},
|
|
113
|
-
catchQueryCalls: {
|
|
122
|
+
catchQueryCalls: _objectSpread({
|
|
114
123
|
// Default delete behaviour is to fire a callout, either with kint-components default message
|
|
115
124
|
// or one provided in labelOverrides, which is passed the error message and refdata in question
|
|
116
125
|
delete: async err => {
|
|
126
|
+
var _deleteModal$refdata;
|
|
117
127
|
const errorResp = await (0, _utils.parseErrorResponse)(err.response);
|
|
118
128
|
// console.log('ERRORRESP: %o', errorResp);
|
|
119
129
|
callout.sendCallout({
|
|
120
130
|
message: kintIntl.formatKintMessage({
|
|
121
131
|
id: 'refdata.deleteRefdataValue.errorMessage',
|
|
122
|
-
overrideValue: labelOverrides
|
|
132
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteError
|
|
123
133
|
}, {
|
|
124
|
-
label: deleteModal
|
|
125
|
-
error: errorResp
|
|
134
|
+
label: deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata = deleteModal.refdata) === null || _deleteModal$refdata === void 0 ? void 0 : _deleteModal$refdata.label,
|
|
135
|
+
error: errorResp === null || errorResp === void 0 ? void 0 : errorResp.message
|
|
126
136
|
}),
|
|
127
137
|
type: 'error'
|
|
128
138
|
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
},
|
|
139
|
+
}
|
|
140
|
+
}, catchQueryCalls),
|
|
132
141
|
endpoint: refdataEndpoint,
|
|
133
|
-
id: refdata
|
|
142
|
+
id: refdata === null || refdata === void 0 ? void 0 : refdata.id,
|
|
134
143
|
queryParams: {
|
|
135
144
|
delete: {
|
|
136
145
|
enabled: !!refdata
|
|
@@ -152,24 +161,24 @@ const EditableRefdataList = _ref => {
|
|
|
152
161
|
name: 'edit',
|
|
153
162
|
label: kintIntl.formatKintMessage({
|
|
154
163
|
id: 'edit',
|
|
155
|
-
overrideValue: labelOverrides
|
|
164
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.edit
|
|
156
165
|
}),
|
|
157
166
|
icon: 'edit',
|
|
158
167
|
callback: data => editRefdataValue(data),
|
|
159
168
|
ariaLabel: data => kintIntl.formatKintMessage({
|
|
160
169
|
id: 'refdata.editAriaLabel',
|
|
161
|
-
overrideValue: labelOverrides
|
|
170
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.editAriaLabel
|
|
162
171
|
}, {
|
|
163
|
-
label: data
|
|
172
|
+
label: data === null || data === void 0 ? void 0 : data.label
|
|
164
173
|
})
|
|
165
174
|
});
|
|
166
175
|
}
|
|
167
|
-
if (!refdata
|
|
176
|
+
if (!(refdata !== null && refdata !== void 0 && refdata.internal) && deleteCondition) {
|
|
168
177
|
actionArray.push({
|
|
169
178
|
name: 'delete',
|
|
170
179
|
label: kintIntl.formatKintMessage({
|
|
171
180
|
id: 'delete',
|
|
172
|
-
overrideValue: labelOverrides
|
|
181
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.delete
|
|
173
182
|
}),
|
|
174
183
|
icon: 'trash',
|
|
175
184
|
callback: data => setDeleteModal({
|
|
@@ -178,9 +187,9 @@ const EditableRefdataList = _ref => {
|
|
|
178
187
|
}),
|
|
179
188
|
ariaLabel: data => kintIntl.formatKintMessage({
|
|
180
189
|
id: 'refdata.deleteAriaLabel',
|
|
181
|
-
overrideValue: labelOverrides
|
|
190
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteAriaLabel
|
|
182
191
|
}, {
|
|
183
|
-
label: data
|
|
192
|
+
label: data === null || data === void 0 ? void 0 : data.label
|
|
184
193
|
})
|
|
185
194
|
});
|
|
186
195
|
}
|
|
@@ -192,25 +201,25 @@ const EditableRefdataList = _ref => {
|
|
|
192
201
|
columnMapping: {
|
|
193
202
|
label: kintIntl.formatKintMessage({
|
|
194
203
|
id: 'refdata.label',
|
|
195
|
-
overrideValue: labelOverrides
|
|
204
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.label
|
|
196
205
|
}),
|
|
197
206
|
value: kintIntl.formatKintMessage({
|
|
198
207
|
id: 'refdata.value',
|
|
199
|
-
overrideValue: labelOverrides
|
|
208
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.value
|
|
200
209
|
})
|
|
201
210
|
},
|
|
202
211
|
contentData: contentData,
|
|
203
212
|
creatableFields: {
|
|
204
213
|
value: () => false
|
|
205
214
|
},
|
|
206
|
-
createCallback: !createCondition || refdata
|
|
215
|
+
createCallback: !createCondition || refdata !== null && refdata !== void 0 && refdata.internal ? null : data => {
|
|
207
216
|
if (allowSpecial) {
|
|
208
217
|
editRefdataValue(data);
|
|
209
218
|
} else {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
value: (0, _utils.selectorSafe)(data
|
|
213
|
-
});
|
|
219
|
+
var _selectorSafe;
|
|
220
|
+
editRefdataValue(_objectSpread(_objectSpread({}, data), {}, {
|
|
221
|
+
value: (_selectorSafe = (0, _utils.selectorSafe)(data === null || data === void 0 ? void 0 : data.label)) === null || _selectorSafe === void 0 ? void 0 : _selectorSafe.replaceAll('%20', ' ')
|
|
222
|
+
}));
|
|
214
223
|
}
|
|
215
224
|
},
|
|
216
225
|
editableFields: {
|
|
@@ -226,30 +235,31 @@ const EditableRefdataList = _ref => {
|
|
|
226
235
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ConfirmationModal, {
|
|
227
236
|
confirmLabel: kintIntl.formatKintMessage({
|
|
228
237
|
id: 'delete',
|
|
229
|
-
overrideValue: labelOverrides
|
|
238
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.delete
|
|
230
239
|
}),
|
|
231
240
|
heading: kintIntl.formatKintMessage({
|
|
232
241
|
id: 'refdata.deleteRefdataValue',
|
|
233
|
-
overrideValue: labelOverrides
|
|
242
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteRefdataValue
|
|
234
243
|
}),
|
|
235
244
|
message: kintIntl.formatKintMessage({
|
|
236
245
|
id: 'refdata.deleteRefdataValue.confirmMessage',
|
|
237
|
-
overrideValue: labelOverrides
|
|
246
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.deleteRefdataValueMessage
|
|
238
247
|
}, {
|
|
239
|
-
name: deleteModal
|
|
248
|
+
name: deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata2 = deleteModal.refdata) === null || _deleteModal$refdata2 === void 0 ? void 0 : _deleteModal$refdata2.label
|
|
240
249
|
}),
|
|
241
250
|
onCancel: () => setDeleteModal({
|
|
242
251
|
visible: false,
|
|
243
252
|
refdata: null
|
|
244
253
|
}),
|
|
245
254
|
onConfirm: () => {
|
|
246
|
-
|
|
255
|
+
var _deleteModal$refdata3;
|
|
256
|
+
deleteRefdataValue(deleteModal === null || deleteModal === void 0 || (_deleteModal$refdata3 = deleteModal.refdata) === null || _deleteModal$refdata3 === void 0 ? void 0 : _deleteModal$refdata3.id);
|
|
247
257
|
setDeleteModal({
|
|
248
258
|
visible: false,
|
|
249
259
|
refdata: null
|
|
250
260
|
});
|
|
251
261
|
},
|
|
252
|
-
open: deleteModal
|
|
262
|
+
open: deleteModal === null || deleteModal === void 0 ? void 0 : deleteModal.visible
|
|
253
263
|
})]
|
|
254
264
|
});
|
|
255
265
|
};
|
package/es/lib/EditableSettingsList/EditableSettingsListFieldArray/EditableSettingsListFieldArray.js
CHANGED
|
@@ -10,6 +10,11 @@ var _reactFinalForm = require("react-final-form");
|
|
|
10
10
|
var _SettingField = require("../SettingField");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
+
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); }
|
|
13
18
|
const EditableSettingsListField = _ref => {
|
|
14
19
|
let {
|
|
15
20
|
allowEdit,
|
|
@@ -25,15 +30,14 @@ const EditableSettingsListField = _ref => {
|
|
|
25
30
|
} = _ref;
|
|
26
31
|
// Handle editing or not at this level
|
|
27
32
|
const [editing, setEditing] = (0, _react.useState)(false);
|
|
28
|
-
const settingData = (0, _react.useMemo)(() => ({
|
|
29
|
-
currentSetting: fields.value[index]
|
|
30
|
-
|
|
31
|
-
}), [fields, index]);
|
|
33
|
+
const settingData = (0, _react.useMemo)(() => _objectSpread({
|
|
34
|
+
currentSetting: fields.value[index]
|
|
35
|
+
}, fields), [fields, index]);
|
|
32
36
|
const DefaultField = (0, _react.useCallback)(() => {
|
|
33
37
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
34
38
|
allowEdit: allowEdit,
|
|
35
39
|
component: _SettingField.SettingField,
|
|
36
|
-
"data-testid":
|
|
40
|
+
"data-testid": "editableSettingsListFieldArray[".concat(index, "]"),
|
|
37
41
|
editing: editing,
|
|
38
42
|
intlKey: intlKey,
|
|
39
43
|
intlNS: intlNS,
|
|
@@ -25,14 +25,14 @@ const EditSettingValue = props => {
|
|
|
25
25
|
const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
|
|
26
26
|
const fieldLabel = kintIntl.formatKintMessage({
|
|
27
27
|
id: 'settings.valueFor',
|
|
28
|
-
overrideValue: labelOverrides
|
|
28
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.valueFor
|
|
29
29
|
}, {
|
|
30
30
|
name: setting.key
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// Adding default sort to refdata object in ascending order by label
|
|
34
34
|
const sortByLabel = (a, b) => a.label.localeCompare(b.label);
|
|
35
|
-
const sortedRefdata = refdata
|
|
35
|
+
const sortedRefdata = refdata === null || refdata === void 0 ? void 0 : refdata.sort(sortByLabel);
|
|
36
36
|
switch (setting.settingType) {
|
|
37
37
|
case 'Refdata':
|
|
38
38
|
// Grab refdata values corresponding to setting
|
|
@@ -45,14 +45,14 @@ const EditSettingValue = props => {
|
|
|
45
45
|
"aria-label": fieldLabel,
|
|
46
46
|
component: RefdataComponent,
|
|
47
47
|
dataOptions: sortedRefdata,
|
|
48
|
-
name:
|
|
48
|
+
name: "".concat(input.name, ".value")
|
|
49
49
|
});
|
|
50
50
|
case 'Password':
|
|
51
51
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
52
52
|
"aria-label": fieldLabel,
|
|
53
53
|
autoFocus: true,
|
|
54
54
|
component: _components.TextField,
|
|
55
|
-
name:
|
|
55
|
+
name: "".concat(input.name, ".value"),
|
|
56
56
|
parse: v => v // Lets us send an empty string instead of 'undefined'
|
|
57
57
|
,
|
|
58
58
|
type: "password"
|
|
@@ -72,7 +72,7 @@ const EditSettingValue = props => {
|
|
|
72
72
|
"aria-label": fieldLabel,
|
|
73
73
|
component: _components.Select,
|
|
74
74
|
dataOptions: selectTemplateValues,
|
|
75
|
-
name:
|
|
75
|
+
name: "".concat(input.name, ".value"),
|
|
76
76
|
parse: v => v
|
|
77
77
|
});
|
|
78
78
|
}
|
|
@@ -82,7 +82,7 @@ const EditSettingValue = props => {
|
|
|
82
82
|
"aria-label": fieldLabel,
|
|
83
83
|
autoFocus: true,
|
|
84
84
|
component: _components.TextField,
|
|
85
|
-
name:
|
|
85
|
+
name: "".concat(input.name, ".value"),
|
|
86
86
|
parse: v => v // Lets us send an empty string instead of 'undefined'
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -20,21 +20,23 @@ const RenderSettingValue = props => {
|
|
|
20
20
|
const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
|
|
21
21
|
const NoCurrentValue = kintIntl.formatKintMessage({
|
|
22
22
|
id: 'settings.noCurrentValue',
|
|
23
|
-
overrideValue: labelOverrides
|
|
23
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.noCurrentValue
|
|
24
24
|
});
|
|
25
|
-
const defaultText =
|
|
25
|
+
const defaultText = "[".concat(kintIntl.formatKintMessage({
|
|
26
26
|
id: 'settings.default',
|
|
27
|
-
overrideValue: labelOverrides
|
|
28
|
-
})
|
|
27
|
+
overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.default
|
|
28
|
+
}), "]");
|
|
29
29
|
switch (setting.settingType) {
|
|
30
30
|
case 'Refdata':
|
|
31
31
|
{
|
|
32
32
|
if (setting.value) {
|
|
33
|
-
|
|
33
|
+
var _refdata$filter$0$lab, _refdata$filter$;
|
|
34
|
+
return (_refdata$filter$0$lab = refdata === null || refdata === void 0 || (_refdata$filter$ = refdata.filter(obj => obj.value === setting.value)[0]) === null || _refdata$filter$ === void 0 ? void 0 : _refdata$filter$.label) !== null && _refdata$filter$0$lab !== void 0 ? _refdata$filter$0$lab : null;
|
|
34
35
|
}
|
|
35
36
|
if (setting.defValue) {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
var _refdata$filter$2;
|
|
38
|
+
const defValue = refdata === null || refdata === void 0 || (_refdata$filter$2 = refdata.filter(obj => obj.value === setting.defValue)[0]) === null || _refdata$filter$2 === void 0 ? void 0 : _refdata$filter$2.label;
|
|
39
|
+
return "".concat(defaultText, " ").concat(defValue);
|
|
38
40
|
}
|
|
39
41
|
return NoCurrentValue;
|
|
40
42
|
}
|
|
@@ -44,7 +46,7 @@ const RenderSettingValue = props => {
|
|
|
44
46
|
return '********';
|
|
45
47
|
}
|
|
46
48
|
if (setting.defValue) {
|
|
47
|
-
return
|
|
49
|
+
return "".concat(defaultText, " ********");
|
|
48
50
|
}
|
|
49
51
|
return NoCurrentValue;
|
|
50
52
|
}
|
|
@@ -54,7 +56,7 @@ const RenderSettingValue = props => {
|
|
|
54
56
|
const settingId = setting.value || setting.defValue;
|
|
55
57
|
return obj.id === settingId;
|
|
56
58
|
})[0];
|
|
57
|
-
return templateValue
|
|
59
|
+
return (templateValue === null || templateValue === void 0 ? void 0 : templateValue.name) || NoCurrentValue;
|
|
58
60
|
}
|
|
59
61
|
default:
|
|
60
62
|
{
|
|
@@ -62,7 +64,7 @@ const RenderSettingValue = props => {
|
|
|
62
64
|
return setting.value;
|
|
63
65
|
}
|
|
64
66
|
if (setting.defValue) {
|
|
65
|
-
return
|
|
67
|
+
return "".concat(defaultText, " ").concat(setting.defValue);
|
|
66
68
|
}
|
|
67
69
|
return NoCurrentValue;
|
|
68
70
|
}
|
|
@@ -15,6 +15,11 @@ var _utils = require("../../utils");
|
|
|
15
15
|
var _renderHelpText = _interopRequireDefault(require("../../../../styles/renderHelpText.css"));
|
|
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 SettingField = settingFieldProps => {
|
|
19
24
|
const {
|
|
20
25
|
allowEdit = true,
|
|
@@ -41,7 +46,7 @@ const SettingField = settingFieldProps => {
|
|
|
41
46
|
endpoint: refdataEndpoint,
|
|
42
47
|
desc: currentSetting.vocab,
|
|
43
48
|
queryParams: {
|
|
44
|
-
enabled: !!currentSetting
|
|
49
|
+
enabled: !!(currentSetting !== null && currentSetting !== void 0 && currentSetting.vocab) && currentSetting.settingType === 'Refdata',
|
|
45
50
|
staleTime: 1000 * 60 * 2 // 2 minutes staletime for refdata in settings?
|
|
46
51
|
}
|
|
47
52
|
});
|
|
@@ -49,7 +54,7 @@ const SettingField = settingFieldProps => {
|
|
|
49
54
|
context: currentSetting.vocab,
|
|
50
55
|
endpoint: templateEndpoint,
|
|
51
56
|
queryParams: {
|
|
52
|
-
enabled: !!currentSetting
|
|
57
|
+
enabled: !!(currentSetting !== null && currentSetting !== void 0 && currentSetting.vocab) && currentSetting.settingType === 'Template'
|
|
53
58
|
}
|
|
54
59
|
});
|
|
55
60
|
const renderHelpText = helpTextId => {
|
|
@@ -115,10 +120,10 @@ const SettingField = settingFieldProps => {
|
|
|
115
120
|
} else {
|
|
116
121
|
RenderFunction = _EditSettingValue.default;
|
|
117
122
|
}
|
|
118
|
-
const id =
|
|
123
|
+
const id = "settings.".concat((0, _utils.toCamelCase)(currentSetting.section), ".").concat((0, _utils.toCamelCase)(currentSetting.key), ".help");
|
|
119
124
|
const renderHeaderStart = () => {
|
|
120
125
|
const settingName = Object.keys(currentSetting).length > 0 ? kintIntl.formatKintMessage({
|
|
121
|
-
id:
|
|
126
|
+
id: "settings.".concat((0, _utils.toCamelCase)(currentSetting.section), ".").concat((0, _utils.toCamelCase)(currentSetting.key))
|
|
122
127
|
}) : kintIntl.formatKintMessage({
|
|
123
128
|
id: 'loading'
|
|
124
129
|
});
|
|
@@ -132,15 +137,14 @@ const SettingField = settingFieldProps => {
|
|
|
132
137
|
headerEnd: renderEditButton(),
|
|
133
138
|
headerStart: renderHeaderStart(),
|
|
134
139
|
roundedBorder: true,
|
|
135
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderFunction, {
|
|
140
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderFunction, _objectSpread({
|
|
136
141
|
currentSetting: currentSetting,
|
|
137
142
|
intlKey: passedIntlKey,
|
|
138
143
|
intlNS: passedIntlNS,
|
|
139
144
|
labelOverrides: labelOverrides,
|
|
140
145
|
refdata: refdata,
|
|
141
|
-
templates: templates
|
|
142
|
-
|
|
143
|
-
})
|
|
146
|
+
templates: templates
|
|
147
|
+
}, settingFieldProps))
|
|
144
148
|
});
|
|
145
149
|
};
|
|
146
150
|
SettingField.propTypes = {
|