@k-int/stripes-kint-components 2.6.3 → 2.6.6
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 +9 -0
- package/es/lib/ActionList/ActionListFieldArray.js +14 -1
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +3 -1
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +5 -5
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +7 -7
- package/es/lib/CustomProperties/Config/CustomPropertyView.js +2 -2
- package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +3 -0
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +4 -1
- package/es/lib/hooks/useCustomProperties.js +2 -0
- package/package.json +1 -1
- package/src/lib/ActionList/ActionListFieldArray.js +13 -1
- package/src/lib/ActionList/README.md +1 -1
- package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +1 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -3
- package/src/lib/CustomProperties/Config/CustomPropertyForm.js +6 -6
- package/src/lib/CustomProperties/Config/CustomPropertyView.js +1 -1
- package/src/lib/CustomProperties/Config/README.md +35 -0
- package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +1 -0
- package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +3 -1
- package/src/lib/hooks/useCustomProperties.js +2 -3
- package/translations/stripes-kint-components/en.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 2.6.6 2022-06-23
|
|
2
|
+
* Fix aria label null safety in ActionList
|
|
3
|
+
|
|
4
|
+
## 2.6.5 2022-06-22
|
|
5
|
+
* Added label override ability for custom property types. Also documentation
|
|
6
|
+
|
|
7
|
+
## 2.6.4 2022-06-21
|
|
8
|
+
* Custom property weight sorting not working as expected
|
|
9
|
+
|
|
1
10
|
## 2.6.3 2022-06-21
|
|
2
11
|
* Null safety issue
|
|
3
12
|
|
|
@@ -255,12 +255,24 @@ var ActionListFieldArray = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
|
255
255
|
actionFunction = function actionFunction() {
|
|
256
256
|
return toggleEditing(data.id);
|
|
257
257
|
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var ariaLabel = "action-".concat(action.name, "[").concat(data.rowIndex, "]");
|
|
261
|
+
|
|
262
|
+
if (action !== null && action !== void 0 && action.ariaLabel) {
|
|
263
|
+
if (typeof action.ariaLabel === 'function') {
|
|
264
|
+
ariaLabel = action.ariaLabel(data);
|
|
265
|
+
} else if (typeof action.ariaLabel === 'string') {
|
|
266
|
+
ariaLabel = action.ariaLabel;
|
|
267
|
+
} else {
|
|
268
|
+
throw new Error("Provided ariaLabel for action \"".concat(action.name, "\" must be a function or a string."));
|
|
269
|
+
}
|
|
258
270
|
} // If we're handed an icon, use that for the action button
|
|
259
271
|
|
|
260
272
|
|
|
261
273
|
if (action.icon) {
|
|
262
274
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
263
|
-
ariaLabel:
|
|
275
|
+
ariaLabel: ariaLabel,
|
|
264
276
|
disabled: editing,
|
|
265
277
|
icon: action.icon,
|
|
266
278
|
onClick: function onClick() {
|
|
@@ -274,6 +286,7 @@ var ActionListFieldArray = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
|
274
286
|
|
|
275
287
|
|
|
276
288
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
289
|
+
ariaLabel: ariaLabel,
|
|
277
290
|
disabled: editing,
|
|
278
291
|
marginBottom0: true,
|
|
279
292
|
onClick: function onClick() {
|
|
@@ -175,7 +175,9 @@ var CustomPropertiesLookup = function CustomPropertiesLookup(_ref) {
|
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
177
|
type: function type(data) {
|
|
178
|
-
|
|
178
|
+
var _labelOverrides$data$;
|
|
179
|
+
|
|
180
|
+
return (_labelOverrides$data$ = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[data === null || data === void 0 ? void 0 : data.type]) !== null && _labelOverrides$data$ !== void 0 ? _labelOverrides$data$ : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
179
181
|
id: "stripes-kint-components.customProperties.type.".concat(data === null || data === void 0 ? void 0 : data.type)
|
|
180
182
|
});
|
|
181
183
|
},
|
|
@@ -64,7 +64,7 @@ var CREATING = 'create';
|
|
|
64
64
|
var VIEWING = 'view'; // A default option for setting up panes manually
|
|
65
65
|
|
|
66
66
|
var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
|
|
67
|
-
var _labelOverrides$paneT, _ref3, _renderViewPaneTitle, _customProperty$categ, _labelOverrides$modal, _labelOverrides$modal2, _labelOverrides$confi
|
|
67
|
+
var _labelOverrides$paneT, _ref3, _renderViewPaneTitle, _customProperty$categ, _labelOverrides$modal, _labelOverrides$modal2, _labelOverrides$confi;
|
|
68
68
|
|
|
69
69
|
var afterQueryCalls = _ref.afterQueryCalls,
|
|
70
70
|
catchQueryCalls = _ref.catchQueryCalls,
|
|
@@ -326,14 +326,14 @@ var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
|
|
|
326
326
|
})
|
|
327
327
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ConfirmationModal, {
|
|
328
328
|
buttonStyle: "danger",
|
|
329
|
-
confirmLabel:
|
|
330
|
-
id: "stripes-kint-components.
|
|
329
|
+
confirmLabel: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
330
|
+
id: "stripes-kint-components.delete"
|
|
331
331
|
}),
|
|
332
|
-
heading: (_labelOverrides$
|
|
332
|
+
heading: (_labelOverrides$confi = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.confirmHeading) !== null && _labelOverrides$confi !== void 0 ? _labelOverrides$confi : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
333
333
|
id: "stripes-kint-components.customProperties.delete.confirmHeading"
|
|
334
334
|
}),
|
|
335
335
|
id: "delete-job-confirmation",
|
|
336
|
-
message:
|
|
336
|
+
message: labelOverrides !== null && labelOverrides !== void 0 && labelOverrides.confirmMessage ? labelOverrides.confirmMessage(customProperty) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
337
337
|
id: "stripes-kint-components.customProperties.delete.confirmMessage",
|
|
338
338
|
values: {
|
|
339
339
|
name: customProperty === null || customProperty === void 0 ? void 0 : customProperty.name
|
|
@@ -44,7 +44,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
44
44
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
45
|
|
|
46
46
|
var CustomPropertyForm = function CustomPropertyForm(_ref) {
|
|
47
|
-
var _labelOverrides$type, _labelOverrides$categ, _labelOverrides$label, _labelOverrides$name, _labelOverrides$descr, _labelOverrides$ctx, _labelOverrides$weigh, _labelOverrides$prima2, _labelOverrides$retir, _labelOverrides$defau;
|
|
47
|
+
var _labelOverrides$DECIM, _labelOverrides$INTEG, _labelOverrides$TEXT_, _labelOverrides$REFDA, _labelOverrides$MULTI, _labelOverrides$DATE_, _labelOverrides$type, _labelOverrides$categ, _labelOverrides$label, _labelOverrides$name, _labelOverrides$descr, _labelOverrides$ctx, _labelOverrides$weigh, _labelOverrides$prima2, _labelOverrides$retir, _labelOverrides$defau;
|
|
48
48
|
|
|
49
49
|
var contextFilterOptions = _ref.contextFilterOptions,
|
|
50
50
|
helpPopovers = _ref.helpPopovers,
|
|
@@ -124,32 +124,32 @@ var CustomPropertyForm = function CustomPropertyForm(_ref) {
|
|
|
124
124
|
label: '',
|
|
125
125
|
value: ''
|
|
126
126
|
}, {
|
|
127
|
-
label: intl.formatMessage({
|
|
127
|
+
label: (_labelOverrides$DECIM = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[_customProperties.DECIMAL_CLASS_NAME]) !== null && _labelOverrides$DECIM !== void 0 ? _labelOverrides$DECIM : intl.formatMessage({
|
|
128
128
|
id: "stripes-kint-components.customProperties.type.".concat(_customProperties.DECIMAL_CLASS_NAME)
|
|
129
129
|
}),
|
|
130
130
|
value: _customProperties.DECIMAL_CLASS_NAME
|
|
131
131
|
}, {
|
|
132
|
-
label: intl.formatMessage({
|
|
132
|
+
label: (_labelOverrides$INTEG = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[_customProperties.INTEGER_CLASS_NAME]) !== null && _labelOverrides$INTEG !== void 0 ? _labelOverrides$INTEG : intl.formatMessage({
|
|
133
133
|
id: "stripes-kint-components.customProperties.type.".concat(_customProperties.INTEGER_CLASS_NAME)
|
|
134
134
|
}),
|
|
135
135
|
value: _customProperties.INTEGER_CLASS_NAME
|
|
136
136
|
}, {
|
|
137
|
-
label: intl.formatMessage({
|
|
137
|
+
label: (_labelOverrides$TEXT_ = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[_customProperties.TEXT_CLASS_NAME]) !== null && _labelOverrides$TEXT_ !== void 0 ? _labelOverrides$TEXT_ : intl.formatMessage({
|
|
138
138
|
id: "stripes-kint-components.customProperties.type.".concat(_customProperties.TEXT_CLASS_NAME)
|
|
139
139
|
}),
|
|
140
140
|
value: _customProperties.TEXT_CLASS_NAME
|
|
141
141
|
}, {
|
|
142
|
-
label: intl.formatMessage({
|
|
142
|
+
label: (_labelOverrides$REFDA = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[_customProperties.REFDATA_CLASS_NAME]) !== null && _labelOverrides$REFDA !== void 0 ? _labelOverrides$REFDA : intl.formatMessage({
|
|
143
143
|
id: "stripes-kint-components.customProperties.type.".concat(_customProperties.REFDATA_CLASS_NAME)
|
|
144
144
|
}),
|
|
145
145
|
value: _customProperties.REFDATA_CLASS_NAME
|
|
146
146
|
}, {
|
|
147
|
-
label: intl.formatMessage({
|
|
147
|
+
label: (_labelOverrides$MULTI = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[_customProperties.MULTI_REFDATA_CLASS_NAME]) !== null && _labelOverrides$MULTI !== void 0 ? _labelOverrides$MULTI : intl.formatMessage({
|
|
148
148
|
id: "stripes-kint-components.customProperties.type.".concat(_customProperties.MULTI_REFDATA_CLASS_NAME)
|
|
149
149
|
}),
|
|
150
150
|
value: _customProperties.MULTI_REFDATA_CLASS_NAME
|
|
151
151
|
}, {
|
|
152
|
-
label: intl.formatMessage({
|
|
152
|
+
label: (_labelOverrides$DATE_ = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[_customProperties.DATE_CLASS_NAME]) !== null && _labelOverrides$DATE_ !== void 0 ? _labelOverrides$DATE_ : intl.formatMessage({
|
|
153
153
|
id: "stripes-kint-components.customProperties.type.".concat(_customProperties.DATE_CLASS_NAME)
|
|
154
154
|
}),
|
|
155
155
|
value: _customProperties.DATE_CLASS_NAME
|
|
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
19
19
|
|
|
20
20
|
// A default option for CustProp view pane, with the ability to override labels for fields
|
|
21
21
|
var CustomPropertyView = function CustomPropertyView(_ref) {
|
|
22
|
-
var _labelOverrides$label, _labelOverrides$name, _labelOverrides$descr, _labelOverrides$prima, _labelOverrides$retir, _labelOverrides$weigh, _labelOverrides$defau, _labelOverrides$ctx, _customProperty$ctx, _labelOverrides$type, _labelOverrides$categ, _customProperty$categ, _customProperty$categ2;
|
|
22
|
+
var _labelOverrides$label, _labelOverrides$name, _labelOverrides$descr, _labelOverrides$prima, _labelOverrides$retir, _labelOverrides$weigh, _labelOverrides$defau, _labelOverrides$ctx, _customProperty$ctx, _labelOverrides$type, _labelOverrides$custo, _labelOverrides$categ, _customProperty$categ, _customProperty$categ2;
|
|
23
23
|
|
|
24
24
|
var customProperty = _ref.customProperty,
|
|
25
25
|
helpPopovers = _ref.helpPopovers,
|
|
@@ -124,7 +124,7 @@ var CustomPropertyView = function CustomPropertyView(_ref) {
|
|
|
124
124
|
label: (_labelOverrides$type = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.type) !== null && _labelOverrides$type !== void 0 ? _labelOverrides$type : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
125
125
|
id: "stripes-kint-components.customProperties.type"
|
|
126
126
|
}),
|
|
127
|
-
value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
127
|
+
value: (_labelOverrides$custo = labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides[customProperty === null || customProperty === void 0 ? void 0 : customProperty.type]) !== null && _labelOverrides$custo !== void 0 ? _labelOverrides$custo : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
128
128
|
id: "stripes-kint-components.customProperties.type.".concat(customProperty === null || customProperty === void 0 ? void 0 : customProperty.type)
|
|
129
129
|
})
|
|
130
130
|
})
|
|
@@ -82,6 +82,9 @@ var CustomPropertiesFilter = function CustomPropertiesFilter(_ref) {
|
|
|
82
82
|
{
|
|
83
83
|
path: 'retired'
|
|
84
84
|
}, // Place retired custprops at the end
|
|
85
|
+
{
|
|
86
|
+
path: 'weight'
|
|
87
|
+
}, // Within those groups, sort by weight first
|
|
85
88
|
{
|
|
86
89
|
path: 'label'
|
|
87
90
|
} // Within those groups, sort by label
|
|
@@ -85,9 +85,12 @@ var CustomPropertiesViewCtx = function CustomPropertiesViewCtx(_ref) {
|
|
|
85
85
|
path: 'primary',
|
|
86
86
|
direction: 'desc'
|
|
87
87
|
}, // Primary properties should display before optional
|
|
88
|
+
{
|
|
89
|
+
path: 'weight'
|
|
90
|
+
}, // Within those groups, sort by weight
|
|
88
91
|
{
|
|
89
92
|
path: 'label'
|
|
90
|
-
} //
|
|
93
|
+
} // For those with the same weight, sort by label
|
|
91
94
|
]
|
|
92
95
|
}
|
|
93
96
|
}),
|
package/package.json
CHANGED
|
@@ -183,12 +183,23 @@ const ActionListFieldArray = forwardRef(({
|
|
|
183
183
|
actionFunction = () => toggleEditing(data.id);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
let ariaLabel = `action-${action.name}[${data.rowIndex}]`;
|
|
187
|
+
if (action?.ariaLabel) {
|
|
188
|
+
if (typeof action.ariaLabel === 'function') {
|
|
189
|
+
ariaLabel = action.ariaLabel(data);
|
|
190
|
+
} else if (typeof action.ariaLabel === 'string') {
|
|
191
|
+
ariaLabel = action.ariaLabel;
|
|
192
|
+
} else {
|
|
193
|
+
throw new Error(`Provided ariaLabel for action "${action.name}" must be a function or a string.`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
186
197
|
// If we're handed an icon, use that for the action button
|
|
187
198
|
if (action.icon) {
|
|
188
199
|
return (
|
|
189
200
|
<IconButton
|
|
190
201
|
key={`action-${action.name}[${data.rowIndex}]`}
|
|
191
|
-
ariaLabel={
|
|
202
|
+
ariaLabel={ariaLabel}
|
|
192
203
|
disabled={editing}
|
|
193
204
|
icon={action.icon}
|
|
194
205
|
onClick={() => (actionFunction ? actionFunction() : () => null)}
|
|
@@ -201,6 +212,7 @@ const ActionListFieldArray = forwardRef(({
|
|
|
201
212
|
return (
|
|
202
213
|
<Button
|
|
203
214
|
key={`action-${action.name}[${data.rowIndex}]`}
|
|
215
|
+
ariaLabel={ariaLabel}
|
|
204
216
|
disabled={editing}
|
|
205
217
|
marginBottom0
|
|
206
218
|
onClick={() => (actionFunction ? actionFunction() : () => null)}
|
|
@@ -89,7 +89,7 @@ const myRef = useRef();
|
|
|
89
89
|
|
|
90
90
|
Name | Type | Description | default | required
|
|
91
91
|
--- | --- | --- | --- | ---
|
|
92
|
-
actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject, ariaLabel: () => null }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. The `ariaLabel` prop will give the associated icon button an aria-label
|
|
92
|
+
actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject, ariaLabel: () => null }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. The `ariaLabel` prop, which can be either a static string or a function accepting the row data and returning a string, will give the associated icon button an aria-label. If a `to` prop is passed, then the resulting button will be rendered as a <Link/> element, as per Stripes Button/IconButton.| | ✓ |
|
|
93
93
|
actionCalls (DEPRECATED) | object<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. THESE CAN NOW BE PASSED AS "callback" in the actionAssigner. | {} | ✕ |
|
|
94
94
|
columnMapping | object | An object which will act on the rendered MultiColumnList headers to map the labels for each `visibleField` | | ✕ |
|
|
95
95
|
contentData | array | An array of objects to render along with their actions | | ✓ |
|
|
@@ -242,8 +242,7 @@ const CustomPropertiesSettings = ({
|
|
|
242
242
|
<ConfirmationModal
|
|
243
243
|
buttonStyle="danger"
|
|
244
244
|
confirmLabel={
|
|
245
|
-
|
|
246
|
-
<FormattedMessage id="stripes-kint-components.customProperties.delete.confirmLabel" />
|
|
245
|
+
<FormattedMessage id="stripes-kint-components.delete" />
|
|
247
246
|
}
|
|
248
247
|
heading={
|
|
249
248
|
labelOverrides?.confirmHeading ??
|
|
@@ -251,7 +250,7 @@ const CustomPropertiesSettings = ({
|
|
|
251
250
|
}
|
|
252
251
|
id="delete-job-confirmation"
|
|
253
252
|
message={
|
|
254
|
-
labelOverrides?.confirmMessage
|
|
253
|
+
labelOverrides?.confirmMessage ? labelOverrides.confirmMessage(customProperty) :
|
|
255
254
|
<FormattedMessage id="stripes-kint-components.customProperties.delete.confirmMessage" values={{ name: customProperty?.name }} />
|
|
256
255
|
}
|
|
257
256
|
onCancel={() => setDeleteModal(false)}
|
|
@@ -70,37 +70,37 @@ const CustomPropertyForm = ({
|
|
|
70
70
|
dataOptions={[
|
|
71
71
|
{ label: '', value: '' },
|
|
72
72
|
{
|
|
73
|
-
label: intl.formatMessage({
|
|
73
|
+
label: labelOverrides?.[DECIMAL_CLASS_NAME] ?? intl.formatMessage({
|
|
74
74
|
id: `stripes-kint-components.customProperties.type.${DECIMAL_CLASS_NAME}`,
|
|
75
75
|
}),
|
|
76
76
|
value: DECIMAL_CLASS_NAME,
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
|
-
label: intl.formatMessage({
|
|
79
|
+
label: labelOverrides?.[INTEGER_CLASS_NAME] ?? intl.formatMessage({
|
|
80
80
|
id: `stripes-kint-components.customProperties.type.${INTEGER_CLASS_NAME}`,
|
|
81
81
|
}),
|
|
82
82
|
value: INTEGER_CLASS_NAME,
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
label: intl.formatMessage({
|
|
85
|
+
label: labelOverrides?.[TEXT_CLASS_NAME] ?? intl.formatMessage({
|
|
86
86
|
id: `stripes-kint-components.customProperties.type.${TEXT_CLASS_NAME}`,
|
|
87
87
|
}),
|
|
88
88
|
value: TEXT_CLASS_NAME,
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
|
-
label: intl.formatMessage({
|
|
91
|
+
label: labelOverrides?.[REFDATA_CLASS_NAME] ?? intl.formatMessage({
|
|
92
92
|
id: `stripes-kint-components.customProperties.type.${REFDATA_CLASS_NAME}`,
|
|
93
93
|
}),
|
|
94
94
|
value: REFDATA_CLASS_NAME,
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
|
-
label: intl.formatMessage({
|
|
97
|
+
label: labelOverrides?.[MULTI_REFDATA_CLASS_NAME] ?? intl.formatMessage({
|
|
98
98
|
id: `stripes-kint-components.customProperties.type.${MULTI_REFDATA_CLASS_NAME}`,
|
|
99
99
|
}),
|
|
100
100
|
value: MULTI_REFDATA_CLASS_NAME,
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
|
-
label: intl.formatMessage({
|
|
103
|
+
label: labelOverrides?.[DATE_CLASS_NAME] ?? intl.formatMessage({
|
|
104
104
|
id: `stripes-kint-components.customProperties.type.${DATE_CLASS_NAME}`,
|
|
105
105
|
}),
|
|
106
106
|
value: DATE_CLASS_NAME,
|
|
@@ -148,7 +148,7 @@ const CustomPropertyView = ({
|
|
|
148
148
|
labelOverrides?.type ??
|
|
149
149
|
<FormattedMessage id="stripes-kint-components.customProperties.type" />
|
|
150
150
|
}
|
|
151
|
-
value={<FormattedMessage id={`stripes-kint-components.customProperties.type.${customProperty?.type}`} />}
|
|
151
|
+
value={labelOverrides?.[customProperty?.type] ?? <FormattedMessage id={`stripes-kint-components.customProperties.type.${customProperty?.type}`} />}
|
|
152
152
|
/>
|
|
153
153
|
)}
|
|
154
154
|
</Col>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# CustomProperties Config components
|
|
2
|
+
|
|
3
|
+
## Motivation
|
|
4
|
+
These components, namely CustomPropertiesSettings, and its constituent components CustomPropertiesLookup, CustomPropertiesForm and CustomPropertyView are designed for use in a FOLIO settings context, as a way to search through, view, create and edit custom properties.
|
|
5
|
+
|
|
6
|
+
## LabelOverrides
|
|
7
|
+
These components can all be provided with a prop `labelOverrides` which allows the overriding of certain translation defaults provided by kint-components. These values must take a certain shape, which differs by translation key. A table is provided below.
|
|
8
|
+
|
|
9
|
+
Key | Type | Description | default
|
|
10
|
+
--- | --- | --- | ---
|
|
11
|
+
category | node/string | Override for the display of field "category" | "Category" |
|
|
12
|
+
confirmHeading | node/string | Override for the title of the confirmation modal which pops up on attempting to delete a custom property | "Delete custom property" |
|
|
13
|
+
com.k_int.web.toolkit.custprops.types.CustomPropertyDate (See customPropertyConstants) | string | Override for the "Date" type custom property display. Must be string in order to support display within the Select. | "Date" |
|
|
14
|
+
com.k_int.web.toolkit.custprops.types.CustomPropertyDecimal (See customPropertyConstants) | string | Override for the "Decimal" type custom property display. Must be string in order to support display within the Select. | "Decimal" |
|
|
15
|
+
com.k_int.web.toolkit.custprops.types.CustomPropertyInteger (See customPropertyConstants) | string | Override for the "Integer" type custom property display. Must be string in order to support display within the Select. | "Integer" |
|
|
16
|
+
com.k_int.web.toolkit.custprops.types.CustomPropertyMultiRefdata (See customPropertyConstants) | string | Override for the "MultiRefdata" type custom property display. Must be string in order to support display within the Select. | "Refdata (multi-select)" |
|
|
17
|
+
com.k_int.web.toolkit.custprops.types.CustomPropertyRefdata (See customPropertyConstants) | string | Override for the "Refdata" type custom property display. Must be string in order to support display within the Select. | "Refdata" |
|
|
18
|
+
com.k_int.web.toolkit.custprops.types.CustomPropertyText (See customPropertyConstants) | string | Override for the "Text" type custom property display. Must be string in order to support display within the Select. | "Text" |
|
|
19
|
+
confirmMessage | function | Override for the message displayed in the confirmation modal on trying to delete a custom property. Accepts a function which will be provided the custom property object in question. | "Custom property <strong>{name}</strong> will be <strong>deleted</strong>." |
|
|
20
|
+
ctx | node/string | Override for the display of field "ctx" | "Context" |
|
|
21
|
+
deleteError | function | Override for the default callout message shown when a custom property fails to delete. Accepts a function to which it will provide the error message and the customProperty in question. | "<strong>Error: {label}</strong> was not deleted. {error}" |
|
|
22
|
+
defaultVisibility | node/string | Override for the display of field "defaultVisibility" | "Default visibility" |
|
|
23
|
+
description | node/string | Override for the display of field "description" | "Description" |
|
|
24
|
+
label | node/string | Override for the display of field "label" | "Label" |
|
|
25
|
+
modalTitleEdit | node/string | Override for the modal header on editing a custom property | "New custom property" |
|
|
26
|
+
modalTitleNew | node/string | Override for the modal header on attempting to create a custom property | "Edit custom property" |
|
|
27
|
+
name | node/string | Override for the display of field "name" | "Name" |
|
|
28
|
+
paneTitle | node/string | Override for the pane title displayed in the main lookup section. | "Custom properties" |
|
|
29
|
+
primary | node/string | Override for the display of field "primary" | "Primary" |
|
|
30
|
+
primaryRetired | node/string | Override for the warning message on validation, preventing a custom property being set both as primary AND as retired | "A custom property cannot be both primary and retired" |
|
|
31
|
+
retired | node/string | Override for the display of field "retired" | "Retired" |
|
|
32
|
+
searchAriaLabel | string | Override for the aria label provided by the search field in the main custom property lookup section | 'custom-property-search-field' |
|
|
33
|
+
type | node/string | Override for the display of field "type" | "Type" |
|
|
34
|
+
viewPaneTitle | node/string/function | Label override for the title of the custom property view pane once one has been selected. This override accepts any shape, if a function is provided it will provide the customProperty and expect a string/node in return: `(customProperty) => ("${customProperty.name}-example")` | customProperty label if exists, falls back to customProperty name |
|
|
35
|
+
weight | node/string | Override for the display of field "weight" | ""Order weight" |
|
|
@@ -33,6 +33,7 @@ const CustomPropertiesFilter = ({
|
|
|
33
33
|
sort: [
|
|
34
34
|
{ path: 'ctx' }, // Group by ctx
|
|
35
35
|
{ path: 'retired' }, // Place retired custprops at the end
|
|
36
|
+
{ path: 'weight' }, // Within those groups, sort by weight first
|
|
36
37
|
{ path: 'label' } // Within those groups, sort by label
|
|
37
38
|
],
|
|
38
39
|
}
|
|
@@ -50,7 +50,9 @@ const CustomPropertiesViewCtx = ({
|
|
|
50
50
|
sort: [
|
|
51
51
|
{ path: 'retired' }, // Place retired custprops at the end
|
|
52
52
|
{ path: 'primary', direction: 'desc' }, // Primary properties should display before optional
|
|
53
|
-
{ path: '
|
|
53
|
+
{ path: 'weight' }, // Within those groups, sort by weight
|
|
54
|
+
{ path: 'label' } // For those with the same weight, sort by label
|
|
55
|
+
|
|
54
56
|
]
|
|
55
57
|
}
|
|
56
58
|
});
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyLocalDate": "Date",
|
|
73
73
|
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyMultiRefdata": "Refdata (multi-select)",
|
|
74
74
|
|
|
75
|
-
"customProperties.delete.confirmLabel": "Delete",
|
|
76
75
|
"customProperties.delete.confirmHeading": "Delete custom property",
|
|
77
76
|
"customProperties.delete.confirmMessage": "Custom property <strong>{name}</strong> will be <strong>deleted</strong>.",
|
|
78
77
|
"customPropertiesSettings.deleteCustomProperty.errorMessage": "<strong>Error: {label}</strong> was not deleted. {error}",
|