@k-int/stripes-kint-components 1.7.0 → 2.1.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 +36 -0
- package/es/index.js +51 -8
- package/es/lib/ActionList/ActionList.js +48 -28
- package/es/lib/ActionList/ActionListFieldArray.js +56 -16
- package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +198 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +326 -0
- package/es/lib/CustomProperties/Config/CustomPropertiesView.js +166 -0
- package/es/lib/CustomProperties/Config/CustomPropertyForm.js +360 -0
- package/es/lib/CustomProperties/Config/index.js +41 -0
- package/es/lib/EditableRefdataList/EditableRefdataList.js +0 -1
- package/es/lib/FormModal/FormModal.js +126 -0
- package/es/lib/{TypeDown → FormModal}/index.js +2 -2
- package/es/lib/NoResultsMessage/NoResultsMessage.js +1 -1
- package/es/lib/SASQRoute/SASQRoute.js +15 -11
- package/es/lib/SASQViewComponent/SASQViewComponent.js +6 -3
- package/es/lib/Typedown/Typedown.js +50 -18
- package/es/lib/constants/customProperties.js +60 -0
- package/es/lib/hooks/index.js +16 -0
- package/es/lib/hooks/useCustomProperties.js +122 -0
- package/es/lib/hooks/useMutateCustomProperties.js +143 -0
- package/es/lib/utils/generateKiwtQueryParams.js +51 -8
- package/junit.xml +40 -40
- package/package.json +5 -3
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +47 -26
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +122 -8
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +10 -10
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesLookup.js.html +418 -0
- package/src/artifacts/coverage-jest/lcov-report/{TypeDown/TypeDown.js.html → CustomProperties/Config/CustomPropertiesSettings.js.html} +268 -232
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesView.js.html +535 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +973 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +176 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +97 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +2 -5
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/FormModal/FormModal.js.html +298 -0
- package/src/artifacts/coverage-jest/lcov-report/{TypeDown → FormModal}/index.html +14 -14
- package/src/artifacts/coverage-jest/lcov-report/{TypeDown → FormModal}/index.js.html +4 -4
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +43 -16
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +6 -3
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +150 -21
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +7 -7
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +112 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/constants/index.html +18 -3
- package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +35 -5
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +8 -2
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +313 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateCustomProperties.js.html +271 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/index.html +62 -47
- package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +174 -12
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +17 -17
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov.info +841 -348
- package/src/index.js +14 -4
- package/src/lib/ActionList/ActionList.js +30 -23
- package/src/lib/ActionList/ActionListFieldArray.js +40 -2
- package/src/lib/ActionList/README.md +4 -1
- package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +111 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +240 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesView.js +150 -0
- package/src/lib/CustomProperties/Config/CustomPropertyForm.js +296 -0
- package/src/lib/CustomProperties/Config/index.js +4 -0
- package/src/lib/EditableRefdataList/EditableRefdataList.js +0 -1
- 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/SASQRoute/SASQRoute.js +23 -14
- package/src/lib/SASQViewComponent/SASQViewComponent.js +2 -1
- package/src/lib/Typedown/Typedown.js +56 -13
- package/src/lib/constants/customProperties.js +9 -0
- package/src/lib/hooks/index.js +2 -0
- package/src/lib/hooks/useCustomProperties.js +76 -0
- package/src/lib/hooks/useMutateCustomProperties.js +62 -0
- package/src/lib/utils/generateKiwtQueryParams.js +58 -4
- package/styles/TypeDown.css +7 -0
- package/translations/stripes-kint-components/en.json +49 -1
- package/es/lib/TypeDown/TypeDown.js +0 -251
- package/src/lib/TypeDown/README.md +0 -1
- package/src/lib/TypeDown/TypeDown.js +0 -228
- package/src/lib/TypeDown/index.js +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { Col, KeyValue, NoValue, Row } from '@folio/stripes/components';
|
|
4
|
+
|
|
5
|
+
import { REFDATA_CLASS_NAME } from '../../constants/customProperties';
|
|
6
|
+
|
|
7
|
+
// A default option for CustProp view pane, with the ability to override labels for fields
|
|
8
|
+
const CustomPropertiesView = ({
|
|
9
|
+
customProperty,
|
|
10
|
+
labelOverrides
|
|
11
|
+
}) => {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<Row>
|
|
15
|
+
<Col xs={6}>
|
|
16
|
+
<KeyValue
|
|
17
|
+
label={
|
|
18
|
+
labelOverrides?.label ??
|
|
19
|
+
<FormattedMessage id="stripes-kint-components.customProperties.label" />
|
|
20
|
+
}
|
|
21
|
+
value={customProperty?.label}
|
|
22
|
+
/>
|
|
23
|
+
</Col>
|
|
24
|
+
<Col xs={6}>
|
|
25
|
+
<KeyValue
|
|
26
|
+
label={
|
|
27
|
+
labelOverrides?.name ??
|
|
28
|
+
<FormattedMessage id="stripes-kint-components.customProperties.name" />
|
|
29
|
+
}
|
|
30
|
+
value={customProperty?.name}
|
|
31
|
+
/>
|
|
32
|
+
</Col>
|
|
33
|
+
</Row>
|
|
34
|
+
<Row>
|
|
35
|
+
<Col xs={12}>
|
|
36
|
+
<KeyValue
|
|
37
|
+
label={
|
|
38
|
+
labelOverrides?.description ??
|
|
39
|
+
<FormattedMessage id="stripes-kint-components.customProperties.description" />
|
|
40
|
+
}
|
|
41
|
+
value={customProperty?.description}
|
|
42
|
+
/>
|
|
43
|
+
</Col>
|
|
44
|
+
</Row>
|
|
45
|
+
<Row>
|
|
46
|
+
<Col xs={6}>
|
|
47
|
+
<KeyValue
|
|
48
|
+
label={
|
|
49
|
+
labelOverrides?.weight ??
|
|
50
|
+
<FormattedMessage id="stripes-kint-components.customProperties.weight" />
|
|
51
|
+
}
|
|
52
|
+
value={customProperty?.weight}
|
|
53
|
+
/>
|
|
54
|
+
</Col>
|
|
55
|
+
<Col xs={6}>
|
|
56
|
+
<KeyValue
|
|
57
|
+
label={
|
|
58
|
+
labelOverrides?.primary ??
|
|
59
|
+
<FormattedMessage
|
|
60
|
+
id="stripes-kint-components.customProperties.primary"
|
|
61
|
+
/>
|
|
62
|
+
}
|
|
63
|
+
value={
|
|
64
|
+
<FormattedMessage
|
|
65
|
+
id={
|
|
66
|
+
customProperty?.primary
|
|
67
|
+
? 'stripes-kint-components.yes'
|
|
68
|
+
: 'stripes-kint-components.no'
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
}
|
|
72
|
+
/>
|
|
73
|
+
</Col>
|
|
74
|
+
</Row>
|
|
75
|
+
<Row>
|
|
76
|
+
<Col xs={6}>
|
|
77
|
+
<KeyValue
|
|
78
|
+
label={
|
|
79
|
+
labelOverrides?.defaultVisibility ??
|
|
80
|
+
<FormattedMessage id="stripes-kint-components.customProperties.defaultVisibility" />
|
|
81
|
+
}
|
|
82
|
+
value={
|
|
83
|
+
<FormattedMessage
|
|
84
|
+
id={
|
|
85
|
+
customProperty?.defaultInternal
|
|
86
|
+
? 'stripes-kint-components.customProperties.internalTrue'
|
|
87
|
+
: 'stripes-kint-components.customProperties.internalFalse'
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
}
|
|
91
|
+
/>
|
|
92
|
+
</Col>
|
|
93
|
+
<Col xs={6}>
|
|
94
|
+
<KeyValue
|
|
95
|
+
label={
|
|
96
|
+
labelOverrides?.ctx ??
|
|
97
|
+
<FormattedMessage id="stripes-kint-components.customProperties.ctx" />
|
|
98
|
+
}
|
|
99
|
+
value={customProperty?.ctx ?? <NoValue />}
|
|
100
|
+
/>
|
|
101
|
+
</Col>
|
|
102
|
+
</Row>
|
|
103
|
+
<Row>
|
|
104
|
+
<Col xs={6}>
|
|
105
|
+
{customProperty?.type && (
|
|
106
|
+
<KeyValue
|
|
107
|
+
label={
|
|
108
|
+
labelOverrides?.type ??
|
|
109
|
+
<FormattedMessage id="stripes-kint-components.customProperties.type" />
|
|
110
|
+
}
|
|
111
|
+
value={<FormattedMessage id={`stripes-kint-components.customProperties.type.${customProperty?.type}`} />}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
</Col>
|
|
115
|
+
<Col xs={6}>
|
|
116
|
+
{customProperty?.type === REFDATA_CLASS_NAME && (
|
|
117
|
+
<KeyValue
|
|
118
|
+
label={
|
|
119
|
+
labelOverrides?.category ??
|
|
120
|
+
<FormattedMessage id="stripes-kint-components.customProperties.category" />
|
|
121
|
+
}
|
|
122
|
+
value={customProperty?.category?.desc ?? <NoValue />}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
125
|
+
</Col>
|
|
126
|
+
</Row>
|
|
127
|
+
</>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
CustomPropertiesView.propTypes = {
|
|
132
|
+
customProperty: PropTypes.shape({
|
|
133
|
+
id: PropTypes.string,
|
|
134
|
+
label: PropTypes.string,
|
|
135
|
+
name: PropTypes.string,
|
|
136
|
+
description: PropTypes.string,
|
|
137
|
+
weight: PropTypes.number,
|
|
138
|
+
primary: PropTypes.bool,
|
|
139
|
+
defaultInternal: PropTypes.bool,
|
|
140
|
+
ctx: PropTypes.string,
|
|
141
|
+
type: PropTypes.string,
|
|
142
|
+
category: PropTypes.shape({
|
|
143
|
+
desc: PropTypes.string
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
}),
|
|
147
|
+
labelOverrides: PropTypes.object
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default CustomPropertiesView;
|
|
@@ -0,0 +1,296 @@
|
|
|
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
|
+
emptyMessage={intl.formatMessage({ id: 'stripes-kint-components.customProperties.noCtxFound' })}
|
|
202
|
+
label={labelOverrides?.ctx ??
|
|
203
|
+
<FormattedMessage id="stripes-kint-components.customProperties.ctx" />
|
|
204
|
+
}
|
|
205
|
+
name="ctx"
|
|
206
|
+
onChange={(selectedItems) => {
|
|
207
|
+
if (selectedItems.length) {
|
|
208
|
+
change('ctx', [selectedItems?.[selectedItems?.length - 1]]);
|
|
209
|
+
} else {
|
|
210
|
+
change('ctx', undefined);
|
|
211
|
+
}
|
|
212
|
+
}}
|
|
213
|
+
validate={value => (value?.length > 1 ? <FormattedMessage id="stripes-kint-components.customProperties.ctx.error.moreThanOne" /> : null)}
|
|
214
|
+
/>
|
|
215
|
+
</Col>
|
|
216
|
+
</Row>
|
|
217
|
+
{/* Users can only configure the type of a custom property when creating it, not when editing it */}
|
|
218
|
+
{!values?.id && (
|
|
219
|
+
<Row>
|
|
220
|
+
<Col xs={6}>
|
|
221
|
+
<Field
|
|
222
|
+
component={Select}
|
|
223
|
+
dataOptions={[
|
|
224
|
+
{ label: '', value: '' },
|
|
225
|
+
{
|
|
226
|
+
label: intl.formatMessage({
|
|
227
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyDecimal',
|
|
228
|
+
}),
|
|
229
|
+
value: 'Decimal',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
label: intl.formatMessage({
|
|
233
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyInteger',
|
|
234
|
+
}),
|
|
235
|
+
value: 'Integer',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
label: intl.formatMessage({
|
|
239
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyText',
|
|
240
|
+
}),
|
|
241
|
+
value: 'Text',
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
label: intl.formatMessage({
|
|
245
|
+
id: 'stripes-kint-components.customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyRefdata',
|
|
246
|
+
}),
|
|
247
|
+
value: 'Refdata',
|
|
248
|
+
},
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
label={labelOverrides?.type ??
|
|
252
|
+
<FormattedMessage id="stripes-kint-components.customProperties.type" />
|
|
253
|
+
}
|
|
254
|
+
name="type"
|
|
255
|
+
required
|
|
256
|
+
startControl={helpPopovers?.type ?
|
|
257
|
+
<InfoPopover
|
|
258
|
+
content={helpPopovers?.type}
|
|
259
|
+
/> : null
|
|
260
|
+
}
|
|
261
|
+
validate={requiredValidator}
|
|
262
|
+
/>
|
|
263
|
+
</Col>
|
|
264
|
+
<Col xs={6}>
|
|
265
|
+
{values?.type === 'Refdata' && (
|
|
266
|
+
<Field
|
|
267
|
+
component={Select}
|
|
268
|
+
dataOptions={[{ label: '', value: '' }, ...refdata]}
|
|
269
|
+
label={labelOverrides?.category ??
|
|
270
|
+
<FormattedMessage id="stripes-kint-components.customProperties.category" />
|
|
271
|
+
}
|
|
272
|
+
name="category"
|
|
273
|
+
required
|
|
274
|
+
startControl={helpPopovers?.category ?
|
|
275
|
+
<InfoPopover
|
|
276
|
+
content={helpPopovers?.category}
|
|
277
|
+
/> : null
|
|
278
|
+
}
|
|
279
|
+
validate={requiredValidator}
|
|
280
|
+
/>
|
|
281
|
+
)}
|
|
282
|
+
</Col>
|
|
283
|
+
</Row>
|
|
284
|
+
)}
|
|
285
|
+
</>
|
|
286
|
+
);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
CustomPropertyForm.propTypes = {
|
|
290
|
+
contextFilterOptions: PropTypes.arrayOf(PropTypes.string),
|
|
291
|
+
helpPopovers: PropTypes.object,
|
|
292
|
+
labelOverrides: PropTypes.object,
|
|
293
|
+
refdata: PropTypes.arrayOf(PropTypes.object)
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
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';
|
|
@@ -53,7 +53,6 @@ const EditableRefdataList = ({ desc, refdataEndpoint }) => {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// This is the function which will take a row in the table and assign the relevant actions to it
|
|
56
|
-
// TODO make these 'labels' into ARIA labels
|
|
57
56
|
const actionAssigner = () => {
|
|
58
57
|
const actionArray = [
|
|
59
58
|
{ name: 'edit', label: <FormattedMessage id="stripes-kint-components.editableRefdataList.edit" />, icon: 'edit' },
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
3
|
+
import { Form } from 'react-final-form';
|
|
4
|
+
import { FormattedMessage } from 'react-intl';
|
|
5
|
+
import { Button, Modal, ModalFooter } from '@folio/stripes/components';
|
|
6
|
+
|
|
7
|
+
const FormModal = ({ children, modalProps: { onClose, ...modalProps }, onSubmit, ...formProps }) => {
|
|
8
|
+
return (
|
|
9
|
+
<Form
|
|
10
|
+
onSubmit={onSubmit}
|
|
11
|
+
{...formProps}
|
|
12
|
+
>
|
|
13
|
+
{({ handleSubmit, form: { restart } }) => {
|
|
14
|
+
const handleClose = (e) => {
|
|
15
|
+
onClose(e);
|
|
16
|
+
restart();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleSubmitAndClear = () => {
|
|
20
|
+
handleSubmit();
|
|
21
|
+
restart();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const renderFooter = () => (
|
|
25
|
+
<ModalFooter>
|
|
26
|
+
<Button
|
|
27
|
+
buttonStyle="primary"
|
|
28
|
+
onClick={handleSubmitAndClear}
|
|
29
|
+
>
|
|
30
|
+
<FormattedMessage id="stripes-kint-components.save" />
|
|
31
|
+
</Button>
|
|
32
|
+
<Button
|
|
33
|
+
onClick={handleClose}
|
|
34
|
+
>
|
|
35
|
+
<FormattedMessage id="stripes-kint-components.cancel" />
|
|
36
|
+
</Button>
|
|
37
|
+
</ModalFooter>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<form
|
|
42
|
+
onSubmit={handleSubmitAndClear}
|
|
43
|
+
>
|
|
44
|
+
<Modal
|
|
45
|
+
enforceFocus={false}
|
|
46
|
+
footer={renderFooter()}
|
|
47
|
+
onClose={handleClose}
|
|
48
|
+
{...modalProps}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</Modal>
|
|
52
|
+
</form>
|
|
53
|
+
);
|
|
54
|
+
}}
|
|
55
|
+
</Form>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
FormModal.propTypes = {
|
|
60
|
+
children: PropTypes.oneOfType([
|
|
61
|
+
PropTypes.arrayOf(PropTypes.node),
|
|
62
|
+
PropTypes.node,
|
|
63
|
+
PropTypes.func,
|
|
64
|
+
]),
|
|
65
|
+
modalProps: PropTypes.shape({
|
|
66
|
+
onClose: PropTypes.func
|
|
67
|
+
}),
|
|
68
|
+
onSubmit: PropTypes.func
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default FormModal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './FormModal';
|
|
@@ -66,11 +66,11 @@ NoResultsMessage.propTypes = {
|
|
|
66
66
|
icon: PropTypes.string,
|
|
67
67
|
isLoading: PropTypes.bool,
|
|
68
68
|
isError: PropTypes.bool,
|
|
69
|
-
label: PropTypes.oneOfType(
|
|
69
|
+
label: PropTypes.oneOfType([
|
|
70
70
|
PropTypes.string,
|
|
71
71
|
PropTypes.node,
|
|
72
72
|
PropTypes.func
|
|
73
|
-
),
|
|
73
|
+
]),
|
|
74
74
|
searchTerm: PropTypes.string.isRequired,
|
|
75
75
|
toggleFilterPane: PropTypes.func.isRequired,
|
|
76
76
|
};
|
|
@@ -2,13 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
Route
|
|
5
|
+
Route,
|
|
6
|
+
Switch
|
|
6
7
|
} from 'react-router-dom';
|
|
7
8
|
|
|
8
9
|
import SASQLookupComponent from '../SASQLookupComponent';
|
|
9
10
|
import SASQViewComponent from '../SASQViewComponent';
|
|
10
11
|
|
|
11
|
-
const SASQRoute = ({ path, fetchParameters, ...props }) => {
|
|
12
|
+
const SASQRoute = ({ children, path, fetchParameters, ...props }) => {
|
|
12
13
|
// Grab the SASQ_MAP and tweak it
|
|
13
14
|
const { SASQ_MAP = {} } = fetchParameters;
|
|
14
15
|
|
|
@@ -32,18 +33,21 @@ const SASQRoute = ({ path, fetchParameters, ...props }) => {
|
|
|
32
33
|
path={path}
|
|
33
34
|
{...props}
|
|
34
35
|
>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
<Switch>
|
|
37
|
+
{children}
|
|
38
|
+
<Route
|
|
39
|
+
path={`${path}/:id`}
|
|
40
|
+
render={innerProps => (
|
|
41
|
+
<SASQViewComponent
|
|
42
|
+
{...innerProps}
|
|
43
|
+
fetchParameters={fetchParameters}
|
|
44
|
+
path={path}
|
|
45
|
+
ViewComponent={props.ViewComponent}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
/>
|
|
50
|
+
</Switch>
|
|
47
51
|
</SASQLookupComponent>
|
|
48
52
|
);
|
|
49
53
|
}}
|
|
@@ -52,6 +56,11 @@ const SASQRoute = ({ path, fetchParameters, ...props }) => {
|
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
SASQRoute.propTypes = {
|
|
59
|
+
children: PropTypes.oneOfType([
|
|
60
|
+
PropTypes.node,
|
|
61
|
+
PropTypes.element,
|
|
62
|
+
PropTypes.func
|
|
63
|
+
]),
|
|
55
64
|
fetchParameters: PropTypes.object,
|
|
56
65
|
path: PropTypes.string,
|
|
57
66
|
ViewComponent: PropTypes.oneOfType([
|
|
@@ -23,7 +23,7 @@ const SASQViewComponent = ({
|
|
|
23
23
|
const endpoint = fetchParameters?.itemEndpoint ?? fetchParameters?.endpoint;
|
|
24
24
|
|
|
25
25
|
const ky = useOkapiKy();
|
|
26
|
-
const { data = {} } = useQuery(
|
|
26
|
+
const { data = {}, ...rest } = useQuery(
|
|
27
27
|
[namespace, 'data', 'view', match?.params?.id],
|
|
28
28
|
() => ky(`${endpoint}/${match?.params?.id}`).json(),
|
|
29
29
|
{
|
|
@@ -34,6 +34,7 @@ const SASQViewComponent = ({
|
|
|
34
34
|
return (
|
|
35
35
|
<ViewComponent
|
|
36
36
|
onClose={() => history.push(`${path}${location.search}`)}
|
|
37
|
+
queryProps={{ ...rest }}
|
|
37
38
|
resource={data}
|
|
38
39
|
{...props}
|
|
39
40
|
/>
|