@k-int/stripes-kint-components 1.5.0 → 2.0.0
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 +40 -1
- package/es/index.js +80 -25
- package/es/lib/ActionList/ActionList.js +92 -33
- package/es/lib/ActionList/ActionListFieldArray.js +202 -104
- package/es/lib/ActionList/index.js +7 -3
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +198 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +321 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesView.js +166 -0
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +357 -0
- package/es/lib/CustomProperties/Config/index.js +41 -0
- package/es/lib/EditableRefdataList/EditableRefdataList.js +69 -24
- package/es/lib/EditableRefdataList/index.js +7 -3
- package/es/lib/EditableSettingsList/EditableSettingsList.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +90 -0
- package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +181 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +72 -9
- package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +447 -0
- package/es/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +45 -7
- package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +495 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.js +187 -0
- package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +180 -0
- package/es/lib/EditableSettingsList/SettingField/index.js +35 -0
- package/es/lib/EditableSettingsList/index.js +35 -0
- package/es/lib/FormModal/FormModal.js +126 -0
- package/es/lib/FormModal/index.js +19 -0
- package/es/lib/NoResultsMessage/NoResultsMessage.js +65 -32
- package/es/lib/NoResultsMessage/index.js +7 -3
- package/es/lib/QueryTypedown/QueryTypedown.js +48 -9
- package/es/lib/QueryTypedown/index.js +6 -2
- package/es/lib/RefdataButtons/RefdataButtons.js +143 -0
- package/es/lib/RefdataButtons/index.js +19 -0
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +194 -140
- package/es/lib/SASQLookupComponent/index.js +6 -2
- package/es/lib/SASQRoute/SASQRoute.js +55 -18
- package/es/lib/SASQRoute/index.js +6 -2
- package/es/lib/SASQViewComponent/SASQViewComponent.js +50 -11
- package/es/lib/SASQViewComponent/index.js +6 -2
- package/es/lib/SearchField/SearchField.js +48 -13
- package/es/lib/SearchField/index.js +6 -2
- package/es/lib/SettingPage/SettingPage.js +99 -0
- package/es/lib/SettingPage/SettingPagePane.js +83 -0
- package/es/lib/SettingPage/index.js +27 -0
- package/es/lib/Typedown/Typedown.js +174 -99
- package/es/lib/Typedown/index.js +6 -2
- package/es/lib/constants/customProperties.js +60 -0
- package/es/lib/constants/eventCodes.js +31 -1
- package/es/lib/contexts/SettingsContext.js +41 -0
- package/es/lib/contexts/index.js +19 -0
- package/es/lib/hooks/index.js +44 -10
- package/es/lib/hooks/settingsHooks/index.js +27 -0
- package/es/lib/hooks/settingsHooks/useSettingSection.js +74 -0
- package/es/lib/hooks/settingsHooks/useSettings.js +175 -0
- package/es/lib/hooks/typedownHooks/index.js +8 -28
- package/es/lib/hooks/typedownHooks/useTypedown.js +129 -12
- package/es/lib/hooks/typedownHooks/useTypedownData.js +35 -2
- package/es/lib/hooks/typedownHooks/useTypedownToggle.js +39 -6
- package/es/lib/hooks/useActiveElement.js +33 -2
- package/es/lib/hooks/useCustomProperties.js +112 -0
- package/es/lib/hooks/useHelperApp.js +44 -11
- package/es/lib/hooks/useKiwtFieldArray.js +37 -4
- package/es/lib/hooks/useKiwtSASQuery.js +43 -9
- package/es/lib/hooks/useLocalStorageState.js +37 -4
- package/es/lib/hooks/useMutateCustomProperties.js +143 -0
- package/es/lib/hooks/useMutateRefdataValue.js +42 -9
- package/es/lib/hooks/useQIndex.js +42 -9
- package/es/lib/hooks/useRefdata.js +43 -16
- package/es/lib/hooks/useTemplates.js +36 -3
- package/es/lib/utils/buildUrl.js +43 -10
- package/es/lib/utils/generateKiwtQuery.js +33 -4
- package/es/lib/utils/generateKiwtQueryParams.js +31 -2
- package/es/lib/utils/index.js +41 -5
- package/es/lib/utils/refdataOptions.js +43 -0
- package/es/lib/utils/renderHelpText.js +109 -0
- package/es/lib/utils/selectorSafe.js +31 -2
- package/es/lib/utils/sortByLabel.js +55 -0
- package/es/lib/utils/toCamelCase.js +48 -0
- package/jest.config.js +15 -1
- package/package.json +19 -10
- package/src/index.js +25 -10
- package/src/lib/ActionList/ActionList.js +32 -22
- package/src/lib/ActionList/ActionListFieldArray.js +56 -10
- package/src/lib/ActionList/README.md +5 -1
- package/src/lib/ActionList/index.js +1 -1
- package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +111 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +237 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesView.js +150 -0
- package/src/lib/CustomProperties/Config/CustomPropertyForm.js +295 -0
- package/src/lib/CustomProperties/Config/index.js +4 -0
- package/src/lib/EditableRefdataList/EditableRefdataList.js +10 -5
- package/src/lib/EditableRefdataList/index.js +1 -1
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsList.js +0 -0
- package/src/lib/{Settings → EditableSettingsList}/EditableSettingsListFieldArray.js +2 -2
- package/src/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +111 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/EditSettingValue.js +24 -1
- package/src/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +379 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/RenderSettingValue.js +2 -1
- package/src/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +368 -0
- package/src/lib/{Settings → EditableSettingsList/SettingField}/SettingField.js +7 -7
- package/src/lib/EditableSettingsList/SettingField/SettingField.test.js +80 -0
- package/src/lib/EditableSettingsList/SettingField/index.js +3 -0
- package/src/lib/EditableSettingsList/index.js +3 -0
- package/src/lib/FormModal/FormModal.js +71 -0
- package/src/lib/FormModal/index.js +1 -0
- package/src/lib/NoResultsMessage/NoResultsMessage.js +2 -2
- package/src/lib/NoResultsMessage/index.js +1 -1
- package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
- package/src/lib/RefdataButtons/index.js +1 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +7 -1
- package/src/lib/{Settings → SettingPage}/SettingPage.js +5 -5
- package/src/lib/{Settings → SettingPage}/SettingPagePane.js +12 -2
- package/src/lib/SettingPage/index.js +2 -0
- package/src/lib/Typedown/Typedown.js +52 -9
- package/src/lib/constants/customProperties.js +9 -0
- package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
- package/src/lib/contexts/index.js +2 -0
- package/src/lib/hooks/index.js +3 -0
- package/src/lib/hooks/settingsHooks/index.js +2 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettingSection.js +0 -0
- package/src/lib/{Settings → hooks/settingsHooks}/useSettings.js +14 -6
- package/src/lib/hooks/typedownHooks/index.js +0 -3
- package/src/lib/hooks/typedownHooks/useTypedown.js +93 -11
- package/src/lib/hooks/useCustomProperties.js +73 -0
- package/src/lib/hooks/useMutateCustomProperties.js +62 -0
- package/src/lib/hooks/useRefdata.js +2 -8
- package/src/lib/utils/index.js +7 -0
- package/src/lib/utils/refdataOptions.js +7 -0
- package/src/lib/{Settings/utils → utils}/renderHelpText.js +1 -1
- package/src/lib/{Settings/utils → utils}/sortByLabel.js +1 -1
- package/src/lib/{Settings/utils → utils}/toCamelCase.js +0 -0
- package/test/helpers/index.js +1 -0
- package/test/helpers/translationsProperties.js +40 -0
- package/test/jest/helpers/KintHarness.js +36 -0
- package/test/jest/helpers/index.js +2 -0
- package/test/jest/helpers/renderWithKintHarness.js +15 -0
- package/test/jest/jest-transformer.js +4 -0
- package/test/jest/setupTests.js +1 -0
- package/translations/stripes-kint-components/en.json +48 -1
- package/yarn-error.log +14118 -0
- package/babelOptions.js +0 -30
- package/es/lib/Settings/EditableSettingsList.js +0 -57
- package/es/lib/Settings/EditableSettingsListFieldArray.js +0 -59
- package/es/lib/Settings/RefdataButtons.js +0 -100
- package/es/lib/Settings/SettingField.js +0 -144
- package/es/lib/Settings/SettingPage.js +0 -64
- package/es/lib/Settings/SettingPagePane.js +0 -43
- package/es/lib/Settings/SettingsContext.js +0 -18
- package/es/lib/Settings/index.js +0 -71
- package/es/lib/Settings/useSettingSection.js +0 -41
- package/es/lib/Settings/useSettings.js +0 -126
- package/es/lib/Settings/utils/index.js +0 -31
- package/es/lib/Settings/utils/renderHelpText.js +0 -57
- package/es/lib/Settings/utils/sortByLabel.js +0 -26
- package/es/lib/Settings/utils/toCamelCase.js +0 -19
- package/es/lib/TypeDown/TypeDown.js +0 -209
- package/es/lib/TypeDown/index.js +0 -15
- package/es/lib/hooks/typedownHooks/useTypedownFooter.js +0 -47
- package/es/lib/hooks/typedownHooks/useTypedownList.js +0 -45
- package/es/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -47
- package/es/lib/utils/getFocusableElements.js +0 -132
- package/src/lib/Settings/index.js +0 -8
- package/src/lib/Settings/utils/index.js +0 -3
- package/src/lib/TypeDown/README.md +0 -1
- package/src/lib/TypeDown/TypeDown.js +0 -226
- package/src/lib/TypeDown/index.js +0 -1
- package/src/lib/hooks/typedownHooks/useTypedownFooter.js +0 -43
- package/src/lib/hooks/typedownHooks/useTypedownList.js +0 -36
- package/src/lib/hooks/typedownHooks/useTypedownSearchField.js +0 -39
- package/src/lib/utils/getFocusableElements.js +0 -99
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
4
|
+
import { Field, useFormState, useForm } from 'react-final-form';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Col,
|
|
8
|
+
InfoPopover,
|
|
9
|
+
MultiSelection,
|
|
10
|
+
Row,
|
|
11
|
+
Select,
|
|
12
|
+
TextArea,
|
|
13
|
+
TextField
|
|
14
|
+
} from '@folio/stripes/components';
|
|
15
|
+
import { requiredValidator } from '@folio/stripes-erm-components';
|
|
16
|
+
|
|
17
|
+
const CustomPropertyForm = ({
|
|
18
|
+
contextFilterOptions,
|
|
19
|
+
helpPopovers,
|
|
20
|
+
labelOverrides,
|
|
21
|
+
refdata
|
|
22
|
+
}) => {
|
|
23
|
+
const { values } = useFormState();
|
|
24
|
+
const { change } = useForm();
|
|
25
|
+
const intl = useIntl();
|
|
26
|
+
|
|
27
|
+
const booleanToString = booleanValue => booleanValue?.toString();
|
|
28
|
+
const stringToBoolean = stringValue => stringValue === 'true';
|
|
29
|
+
|
|
30
|
+
const [contextOptions, setContextOptions] = useState(contextFilterOptions?.filter(ctx => ctx.value !== '' && ctx?.value !== 'isNull'));
|
|
31
|
+
|
|
32
|
+
const addCtx = ({ _r, _e, filterText }) => {
|
|
33
|
+
const newOption = { value: filterText, label: filterText };
|
|
34
|
+
setContextOptions([newOption, ...contextOptions]);
|
|
35
|
+
change('ctx', [newOption]);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const renderAddCtx = ({ filterValue, exactMatch }) => {
|
|
39
|
+
if (!filterValue || exactMatch) {
|
|
40
|
+
return null;
|
|
41
|
+
} else {
|
|
42
|
+
return <FormattedMessage id="stripes-kint-components.customProperties.ctx.addContext" values={{ value: filterValue }} />;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<Row>
|
|
49
|
+
<Col xs={6}>
|
|
50
|
+
<Field
|
|
51
|
+
component={TextField}
|
|
52
|
+
label={labelOverrides?.label ??
|
|
53
|
+
<FormattedMessage id="stripes-kint-components.customProperties.label" />
|
|
54
|
+
}
|
|
55
|
+
name="label"
|
|
56
|
+
required
|
|
57
|
+
startControl={helpPopovers?.label ?
|
|
58
|
+
<InfoPopover
|
|
59
|
+
content={helpPopovers?.label}
|
|
60
|
+
/> : null
|
|
61
|
+
}
|
|
62
|
+
validate={requiredValidator}
|
|
63
|
+
/>
|
|
64
|
+
</Col>
|
|
65
|
+
<Col xs={6}>
|
|
66
|
+
<Field
|
|
67
|
+
component={TextField}
|
|
68
|
+
label={labelOverrides?.name ??
|
|
69
|
+
<FormattedMessage id="stripes-kint-components.customProperties.name" />
|
|
70
|
+
}
|
|
71
|
+
name="name"
|
|
72
|
+
required
|
|
73
|
+
startControl={helpPopovers?.name ?
|
|
74
|
+
<InfoPopover
|
|
75
|
+
content={helpPopovers?.name}
|
|
76
|
+
/> : null
|
|
77
|
+
}
|
|
78
|
+
validate={v => {
|
|
79
|
+
if (v && v.length) {
|
|
80
|
+
return /^[a-z][a-z0-9]*$/i.test(v) ? (
|
|
81
|
+
undefined
|
|
82
|
+
) : (
|
|
83
|
+
<FormattedMessage id="stripes-kint-components.errors.hasNonAlphaName" />
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return requiredValidator(v);
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
</Col>
|
|
91
|
+
</Row>
|
|
92
|
+
<Row>
|
|
93
|
+
<Col xs={12}>
|
|
94
|
+
<Field
|
|
95
|
+
component={TextArea}
|
|
96
|
+
label={labelOverrides?.description ??
|
|
97
|
+
<FormattedMessage id="stripes-kint-components.customProperties.description" />
|
|
98
|
+
}
|
|
99
|
+
name="description"
|
|
100
|
+
required
|
|
101
|
+
startControl={helpPopovers?.description ?
|
|
102
|
+
<InfoPopover
|
|
103
|
+
content={helpPopovers?.description}
|
|
104
|
+
/> : null
|
|
105
|
+
}
|
|
106
|
+
validate={requiredValidator}
|
|
107
|
+
/>
|
|
108
|
+
</Col>
|
|
109
|
+
</Row>
|
|
110
|
+
<Row>
|
|
111
|
+
<Col xs={3}>
|
|
112
|
+
<Field
|
|
113
|
+
component={TextField}
|
|
114
|
+
label={labelOverrides?.weight ??
|
|
115
|
+
<FormattedMessage id="stripes-kint-components.customProperties.weight" />
|
|
116
|
+
}
|
|
117
|
+
name="weight"
|
|
118
|
+
required
|
|
119
|
+
startControl={helpPopovers?.weight ?
|
|
120
|
+
<InfoPopover
|
|
121
|
+
content={helpPopovers?.weight}
|
|
122
|
+
/> : null
|
|
123
|
+
}
|
|
124
|
+
type="number"
|
|
125
|
+
validate={requiredValidator}
|
|
126
|
+
/>
|
|
127
|
+
</Col>
|
|
128
|
+
<Col xs={3}>
|
|
129
|
+
<Field
|
|
130
|
+
component={Select}
|
|
131
|
+
dataOptions={[
|
|
132
|
+
{
|
|
133
|
+
label: intl.formatMessage({
|
|
134
|
+
id: 'stripes-kint-components.yes',
|
|
135
|
+
}),
|
|
136
|
+
value: 'true',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: intl.formatMessage({
|
|
140
|
+
id: 'stripes-kint-components.no',
|
|
141
|
+
}),
|
|
142
|
+
value: 'false',
|
|
143
|
+
},
|
|
144
|
+
]}
|
|
145
|
+
format={booleanToString}
|
|
146
|
+
label={labelOverrides?.primary ??
|
|
147
|
+
<FormattedMessage
|
|
148
|
+
id="stripes-kint-components.customProperties.primary"
|
|
149
|
+
/>
|
|
150
|
+
}
|
|
151
|
+
name="primary"
|
|
152
|
+
parse={stringToBoolean}
|
|
153
|
+
required
|
|
154
|
+
startControl={helpPopovers?.primary ?
|
|
155
|
+
<InfoPopover
|
|
156
|
+
content={helpPopovers?.primary}
|
|
157
|
+
/> : null
|
|
158
|
+
}
|
|
159
|
+
validate={requiredValidator}
|
|
160
|
+
/>
|
|
161
|
+
</Col>
|
|
162
|
+
<Col xs={3}>
|
|
163
|
+
<Field
|
|
164
|
+
component={Select}
|
|
165
|
+
dataOptions={[
|
|
166
|
+
{
|
|
167
|
+
label: intl.formatMessage({
|
|
168
|
+
id:
|
|
169
|
+
'stripes-kint-components.customProperties.internalTrue',
|
|
170
|
+
}),
|
|
171
|
+
value: 'true',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: intl.formatMessage({
|
|
175
|
+
id:
|
|
176
|
+
'stripes-kint-components.customProperties.internalFalse',
|
|
177
|
+
}),
|
|
178
|
+
value: 'false',
|
|
179
|
+
},
|
|
180
|
+
]}
|
|
181
|
+
format={booleanToString}
|
|
182
|
+
label={labelOverrides?.defaultVisibility ??
|
|
183
|
+
<FormattedMessage id="stripes-kint-components.customProperties.defaultVisibility" />
|
|
184
|
+
}
|
|
185
|
+
name="defaultInternal"
|
|
186
|
+
parse={stringToBoolean}
|
|
187
|
+
required
|
|
188
|
+
startControl={helpPopovers?.defaultVisibility ?
|
|
189
|
+
<InfoPopover
|
|
190
|
+
content={helpPopovers?.defaultVisibility}
|
|
191
|
+
/> : null
|
|
192
|
+
}
|
|
193
|
+
validate={requiredValidator}
|
|
194
|
+
/>
|
|
195
|
+
</Col>
|
|
196
|
+
<Col xs={3}>
|
|
197
|
+
<Field
|
|
198
|
+
actions={[{ onSelect: addCtx, render: renderAddCtx }]}
|
|
199
|
+
component={MultiSelection}
|
|
200
|
+
dataOptions={contextOptions}
|
|
201
|
+
label={labelOverrides?.ctx ??
|
|
202
|
+
<FormattedMessage id="stripes-kint-components.customProperties.ctx" />
|
|
203
|
+
}
|
|
204
|
+
name="ctx"
|
|
205
|
+
onChange={(selectedItems) => {
|
|
206
|
+
if (selectedItems.length) {
|
|
207
|
+
change('ctx', [selectedItems?.[selectedItems?.length - 1]]);
|
|
208
|
+
} else {
|
|
209
|
+
change('ctx', undefined);
|
|
210
|
+
}
|
|
211
|
+
}}
|
|
212
|
+
validate={value => (value?.length > 1 ? <FormattedMessage id="stripes-kint-components.customProperties.ctx.error.moreThanOne" /> : null)}
|
|
213
|
+
/>
|
|
214
|
+
</Col>
|
|
215
|
+
</Row>
|
|
216
|
+
{/* Users can only configure the type of a custom property when creating it, not when editing it */}
|
|
217
|
+
{!values?.id && (
|
|
218
|
+
<Row>
|
|
219
|
+
<Col xs={6}>
|
|
220
|
+
<Field
|
|
221
|
+
component={Select}
|
|
222
|
+
dataOptions={[
|
|
223
|
+
{ label: '', value: '' },
|
|
224
|
+
{
|
|
225
|
+
label: intl.formatMessage({
|
|
226
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyDecimal',
|
|
227
|
+
}),
|
|
228
|
+
value: 'Decimal',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
label: intl.formatMessage({
|
|
232
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyInteger',
|
|
233
|
+
}),
|
|
234
|
+
value: 'Integer',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
label: intl.formatMessage({
|
|
238
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyText',
|
|
239
|
+
}),
|
|
240
|
+
value: 'Text',
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
label: intl.formatMessage({
|
|
244
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyRefdata',
|
|
245
|
+
}),
|
|
246
|
+
value: 'Refdata',
|
|
247
|
+
},
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
label={labelOverrides?.type ??
|
|
251
|
+
<FormattedMessage id="stripes-kint-components.customProperties.type" />
|
|
252
|
+
}
|
|
253
|
+
name="type"
|
|
254
|
+
required
|
|
255
|
+
startControl={helpPopovers?.type ?
|
|
256
|
+
<InfoPopover
|
|
257
|
+
content={helpPopovers?.type}
|
|
258
|
+
/> : null
|
|
259
|
+
}
|
|
260
|
+
validate={requiredValidator}
|
|
261
|
+
/>
|
|
262
|
+
</Col>
|
|
263
|
+
<Col xs={6}>
|
|
264
|
+
{values?.type === 'Refdata' && (
|
|
265
|
+
<Field
|
|
266
|
+
component={Select}
|
|
267
|
+
dataOptions={[{ label: '', value: '' }, ...refdata]}
|
|
268
|
+
label={labelOverrides?.category ??
|
|
269
|
+
<FormattedMessage id="stripes-kint-components.customProperties.category" />
|
|
270
|
+
}
|
|
271
|
+
name="category"
|
|
272
|
+
required
|
|
273
|
+
startControl={helpPopovers?.category ?
|
|
274
|
+
<InfoPopover
|
|
275
|
+
content={helpPopovers?.category}
|
|
276
|
+
/> : null
|
|
277
|
+
}
|
|
278
|
+
validate={requiredValidator}
|
|
279
|
+
/>
|
|
280
|
+
)}
|
|
281
|
+
</Col>
|
|
282
|
+
</Row>
|
|
283
|
+
)}
|
|
284
|
+
</>
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
CustomPropertyForm.propTypes = {
|
|
289
|
+
contextFilterOptions: PropTypes.arrayOf(PropTypes.string),
|
|
290
|
+
helpPopovers: PropTypes.object,
|
|
291
|
+
labelOverrides: PropTypes.object,
|
|
292
|
+
refdata: PropTypes.arrayOf(PropTypes.object)
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export default CustomPropertyForm;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as CustomPropertiesLookup } from './CustomPropertiesLookup';
|
|
2
|
+
export { default as CustomPropertiesView } from './CustomPropertiesLookup';
|
|
3
|
+
export { default as CustomPropertiesSettings } from './CustomPropertiesSettings';
|
|
4
|
+
export { default as CustomPropertyForm } from './CustomPropertyForm';
|
|
@@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { FormattedMessage } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { useMutateRefdataValue, useRefdata } from '../hooks';
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import ActionList from '../ActionList';
|
|
7
8
|
|
|
8
9
|
const propTypes = {
|
|
9
10
|
desc: PropTypes.string,
|
|
@@ -21,18 +22,19 @@ const EditableRefdataList = ({ desc, refdataEndpoint }) => {
|
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
const [contentData, setContentData] = useState([]);
|
|
25
|
+
const sortByLabel = (a, b) => (a.label.localeCompare(b.label));
|
|
24
26
|
|
|
25
27
|
useEffect(() => {
|
|
26
28
|
if (!isRefdataLoading) {
|
|
27
|
-
setContentData(refdata?.values ?? []);
|
|
29
|
+
setContentData(refdata?.values?.sort(sortByLabel) ?? []);
|
|
28
30
|
}
|
|
29
31
|
}, [isRefdataLoading, refdata]);
|
|
30
32
|
|
|
31
33
|
// Edit and Create will use the same PUT mutation
|
|
32
34
|
const { delete: deleteRefdataValue, put: editRefdataValue } = useMutateRefdataValue({
|
|
33
35
|
afterQueryCalls: {
|
|
34
|
-
delete: json => setContentData(json?.values ?? []),
|
|
35
|
-
put: json => setContentData(json?.values ?? [])
|
|
36
|
+
delete: json => setContentData(json?.values?.sort(sortByLabel) ?? []),
|
|
37
|
+
put: json => setContentData(json?.values?.sort(sortByLabel) ?? [])
|
|
36
38
|
},
|
|
37
39
|
endpoint: refdataEndpoint,
|
|
38
40
|
id: refdata?.id,
|
|
@@ -78,8 +80,11 @@ const EditableRefdataList = ({ desc, refdataEndpoint }) => {
|
|
|
78
80
|
value: <FormattedMessage id="stripes-kint-components.editableRefdataList.value" />
|
|
79
81
|
}}
|
|
80
82
|
contentData={contentData}
|
|
83
|
+
creatableFields={{
|
|
84
|
+
value: () => false
|
|
85
|
+
}}
|
|
81
86
|
editableFields={{
|
|
82
|
-
value: () =>
|
|
87
|
+
value: () => false
|
|
83
88
|
}}
|
|
84
89
|
visibleFields={['label', 'value']}
|
|
85
90
|
// TODO add a field validator/fieldType as options?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default
|
|
1
|
+
export { default } from './EditableRefdataList';
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Field } from 'react-final-form';
|
|
4
4
|
|
|
5
|
-
import SettingField from './SettingField';
|
|
5
|
+
import { SettingField } from './SettingField';
|
|
6
6
|
|
|
7
7
|
const EditableSettingsListFieldArray = ({ data, fields, onSave }) => {
|
|
8
8
|
const handleSave = (index) => {
|
|
@@ -16,6 +16,7 @@ const EditableSettingsListFieldArray = ({ data, fields, onSave }) => {
|
|
|
16
16
|
<Field
|
|
17
17
|
key={setting}
|
|
18
18
|
component={SettingField}
|
|
19
|
+
data-testid={`editableSettingsListFieldArray[${i}]`}
|
|
19
20
|
name={setting}
|
|
20
21
|
onSave={() => handleSave(i)}
|
|
21
22
|
settingData={{
|
|
@@ -26,7 +27,6 @@ const EditableSettingsListFieldArray = ({ data, fields, onSave }) => {
|
|
|
26
27
|
);
|
|
27
28
|
})
|
|
28
29
|
);
|
|
29
|
-
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
EditableSettingsListFieldArray.propTypes = {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@folio/stripes-erm-components/test/jest/__mock__';
|
|
3
|
+
import { TestForm } from '@folio/stripes-erm-components/test/jest/helpers';
|
|
4
|
+
import { FieldArray } from 'react-final-form-arrays';
|
|
5
|
+
import EditableSettingsListFieldArray from './EditableSettingsListFieldArray';
|
|
6
|
+
|
|
7
|
+
import { renderWithKintHarness } from '../../../test/jest/helpers';
|
|
8
|
+
|
|
9
|
+
const onSubmit = jest.fn();
|
|
10
|
+
jest.mock('./SettingField', () => ({ SettingField: () => <div>SettingField</div> }));
|
|
11
|
+
|
|
12
|
+
const settings = [{
|
|
13
|
+
id: 'ff8081817d94374a017d94449a660049',
|
|
14
|
+
key: 'S3BucketName',
|
|
15
|
+
section: 'fileStorage',
|
|
16
|
+
settingType: 'String',
|
|
17
|
+
value: 'diku-shared'
|
|
18
|
+
}];
|
|
19
|
+
|
|
20
|
+
const multipleSettings = [{
|
|
21
|
+
id: '2c91809c7da2041f017da20b99000045',
|
|
22
|
+
vocab: 'FileStorageEngines',
|
|
23
|
+
section: 'fileStorage',
|
|
24
|
+
value: 'DB',
|
|
25
|
+
settingType: 'String',
|
|
26
|
+
key: 'storageEngine'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: '2c91809c7da2041f017da20b99080046',
|
|
30
|
+
section: 'fileStorage',
|
|
31
|
+
value: 'http://s3_endpoint_host.domain:9000',
|
|
32
|
+
settingType: 'String',
|
|
33
|
+
key: 'S3Endpoint'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: '2c91809c7da2041f017da20b990d0047',
|
|
37
|
+
section: 'fileStorage',
|
|
38
|
+
value: 'ACCESS_KEY',
|
|
39
|
+
settingType: 'String',
|
|
40
|
+
key: 'S3AccessKey'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
describe('EditableSettingsListFieldArray', () => {
|
|
46
|
+
describe('with empty initial values', () => {
|
|
47
|
+
let renderComponent;
|
|
48
|
+
beforeEach(async () => {
|
|
49
|
+
renderComponent = renderWithKintHarness(
|
|
50
|
+
<TestForm
|
|
51
|
+
initialValues={{}}
|
|
52
|
+
onSubmit={onSubmit}
|
|
53
|
+
>
|
|
54
|
+
<FieldArray
|
|
55
|
+
component={EditableSettingsListFieldArray}
|
|
56
|
+
name="settings"
|
|
57
|
+
/>
|
|
58
|
+
</TestForm>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('renders empty field', () => {
|
|
63
|
+
const { queryAllByTestId } = renderComponent;
|
|
64
|
+
expect(queryAllByTestId(/editableSettingsListFieldArray\[.*\]/).length).toEqual(0);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('with initial value set', () => {
|
|
69
|
+
let renderComponent;
|
|
70
|
+
beforeEach(async () => {
|
|
71
|
+
renderComponent = renderWithKintHarness(
|
|
72
|
+
<TestForm
|
|
73
|
+
initialValues={{ settings }}
|
|
74
|
+
onSubmit={onSubmit}
|
|
75
|
+
>
|
|
76
|
+
<FieldArray
|
|
77
|
+
component={EditableSettingsListFieldArray}
|
|
78
|
+
name="settings"
|
|
79
|
+
/>
|
|
80
|
+
</TestForm>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('renders the SettingField component', () => {
|
|
85
|
+
const { getByText } = renderComponent;
|
|
86
|
+
expect(getByText('SettingField')).toBeInTheDocument();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('with multiple initial values set', () => {
|
|
91
|
+
let renderComponent;
|
|
92
|
+
beforeEach(async () => {
|
|
93
|
+
renderComponent = renderWithKintHarness(
|
|
94
|
+
<TestForm
|
|
95
|
+
initialValues={{ settings: multipleSettings }}
|
|
96
|
+
onSubmit={onSubmit}
|
|
97
|
+
>
|
|
98
|
+
<FieldArray
|
|
99
|
+
component={EditableSettingsListFieldArray}
|
|
100
|
+
name="settings"
|
|
101
|
+
/>
|
|
102
|
+
</TestForm>
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('renders the correct number of SettingField components', () => {
|
|
107
|
+
const { getAllByText } = renderComponent;
|
|
108
|
+
expect(getAllByText('SettingField').length).toEqual(multipleSettings.length);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
|
|
2
5
|
import { Field } from 'react-final-form';
|
|
3
6
|
import {
|
|
4
7
|
Select,
|
|
5
8
|
TextField,
|
|
6
9
|
} from '@folio/stripes/components';
|
|
7
|
-
import RefdataButtons from '
|
|
10
|
+
import RefdataButtons from '../../RefdataButtons';
|
|
8
11
|
|
|
9
12
|
const EditSettingValue = (props) => {
|
|
10
13
|
const {
|
|
@@ -13,6 +16,8 @@ const EditSettingValue = (props) => {
|
|
|
13
16
|
refdata,
|
|
14
17
|
templates
|
|
15
18
|
} = props;
|
|
19
|
+
const intl = useIntl();
|
|
20
|
+
const fieldLabel = intl.formatMessage({ id: 'stripes-kint-components.settings.valueFor', values: { name: setting.key } });
|
|
16
21
|
|
|
17
22
|
switch (setting.settingType) {
|
|
18
23
|
case 'Refdata':
|
|
@@ -25,6 +30,7 @@ const EditSettingValue = (props) => {
|
|
|
25
30
|
|
|
26
31
|
return (
|
|
27
32
|
<Field
|
|
33
|
+
aria-label={fieldLabel}
|
|
28
34
|
component={RefdataComponent}
|
|
29
35
|
dataOptions={refdata}
|
|
30
36
|
name={`${input.name}.value`}
|
|
@@ -34,6 +40,7 @@ const EditSettingValue = (props) => {
|
|
|
34
40
|
case 'Password':
|
|
35
41
|
return (
|
|
36
42
|
<Field
|
|
43
|
+
aria-label={fieldLabel}
|
|
37
44
|
autoFocus
|
|
38
45
|
component={TextField}
|
|
39
46
|
name={`${input.name}.value`}
|
|
@@ -51,6 +58,7 @@ const EditSettingValue = (props) => {
|
|
|
51
58
|
|
|
52
59
|
return (
|
|
53
60
|
<Field
|
|
61
|
+
aria-label={fieldLabel}
|
|
54
62
|
component={Select}
|
|
55
63
|
dataOptions={selectTemplateValues}
|
|
56
64
|
name={`${input.name}.value`}
|
|
@@ -62,6 +70,7 @@ const EditSettingValue = (props) => {
|
|
|
62
70
|
// If in doubt, go with String
|
|
63
71
|
return (
|
|
64
72
|
<Field
|
|
73
|
+
aria-label={fieldLabel}
|
|
65
74
|
autoFocus
|
|
66
75
|
component={TextField}
|
|
67
76
|
name={`${input.name}.value`}
|
|
@@ -71,4 +80,18 @@ const EditSettingValue = (props) => {
|
|
|
71
80
|
}
|
|
72
81
|
};
|
|
73
82
|
|
|
83
|
+
EditSettingValue.propTypes = {
|
|
84
|
+
currentSetting: PropTypes.shape({
|
|
85
|
+
settingType: PropTypes.string
|
|
86
|
+
}),
|
|
87
|
+
input: PropTypes.shape({
|
|
88
|
+
name: PropTypes.string
|
|
89
|
+
}),
|
|
90
|
+
refdata: PropTypes.arrayOf(PropTypes.object),
|
|
91
|
+
templates: PropTypes.arrayOf(PropTypes.shape({
|
|
92
|
+
name: PropTypes.string,
|
|
93
|
+
id: PropTypes.string
|
|
94
|
+
}))
|
|
95
|
+
};
|
|
96
|
+
|
|
74
97
|
export default EditSettingValue;
|