@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
|
@@ -4,10 +4,7 @@ import classnames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import get from 'lodash/get';
|
|
6
6
|
|
|
7
|
-
import { EndOfList, IconButton, Popper } from '@folio/stripes/components';
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
10
|
-
import { interactionStyles } from '@folio/stripes-components/lib/sharedStyles/interactionStyles.css';
|
|
7
|
+
import { EndOfList, IconButton, Label, Popper } from '@folio/stripes/components';
|
|
11
8
|
|
|
12
9
|
import SearchField from '../SearchField';
|
|
13
10
|
import css from '../../../styles/TypeDown.css';
|
|
@@ -16,20 +13,31 @@ import { useTypedown } from '../hooks/typedownHooks';
|
|
|
16
13
|
import selectorSafe from '../utils/selectorSafe';
|
|
17
14
|
|
|
18
15
|
const Typedown = ({
|
|
16
|
+
className,
|
|
19
17
|
dataOptions,
|
|
18
|
+
endOfList,
|
|
19
|
+
id,
|
|
20
20
|
input,
|
|
21
|
+
isSelected,
|
|
21
22
|
filterPath,
|
|
23
|
+
label,
|
|
22
24
|
meta,
|
|
23
25
|
onChange,
|
|
24
26
|
onType,
|
|
25
27
|
renderFooter = null,
|
|
26
28
|
renderListItem = null,
|
|
29
|
+
required,
|
|
27
30
|
uniqueIdentificationPath = 'id'
|
|
28
31
|
}) => {
|
|
29
32
|
const selectedUniqueId = get(input.value, uniqueIdentificationPath);
|
|
30
33
|
|
|
31
34
|
// Display data needs to be in line with data options but also able to react to default handleType
|
|
32
35
|
const [displayData, setDisplayData] = useState(dataOptions);
|
|
36
|
+
|
|
37
|
+
// keep track of what we've typed and whether we've typed an exact match or not
|
|
38
|
+
const [currentlyTyped, setCurrentlyTyped] = useState('');
|
|
39
|
+
const [exactMatch, setExactMatch] = useState(false);
|
|
40
|
+
|
|
33
41
|
useEffect(() => {
|
|
34
42
|
setDisplayData(dataOptions);
|
|
35
43
|
}, [dataOptions]);
|
|
@@ -46,6 +54,14 @@ const Typedown = ({
|
|
|
46
54
|
} else {
|
|
47
55
|
setDisplayData(dataOptions);
|
|
48
56
|
}
|
|
57
|
+
|
|
58
|
+
setCurrentlyTyped(e.target.value);
|
|
59
|
+
|
|
60
|
+
if (displayData.length === 1 && get(displayData[0], filterPath) === e.target.value) {
|
|
61
|
+
setExactMatch(true);
|
|
62
|
+
} else {
|
|
63
|
+
setExactMatch(false);
|
|
64
|
+
}
|
|
49
65
|
};
|
|
50
66
|
|
|
51
67
|
// Hook to set up all the essentials
|
|
@@ -74,11 +90,11 @@ const Typedown = ({
|
|
|
74
90
|
className={css.listItem}
|
|
75
91
|
>
|
|
76
92
|
{renderListItem ?
|
|
77
|
-
renderListItem(option) :
|
|
93
|
+
renderListItem(option, currentlyTyped, exactMatch) :
|
|
78
94
|
get(option, uniqueIdentificationPath)
|
|
79
95
|
}
|
|
80
96
|
</div>
|
|
81
|
-
), [renderListItem, uniqueIdentificationPath]);
|
|
97
|
+
), [currentlyTyped, exactMatch, renderListItem, uniqueIdentificationPath]);
|
|
82
98
|
|
|
83
99
|
const handleChange = useCallback(value => {
|
|
84
100
|
input.onChange(value);
|
|
@@ -101,16 +117,15 @@ const Typedown = ({
|
|
|
101
117
|
id="typedown-list"
|
|
102
118
|
>
|
|
103
119
|
{displayData?.length ? displayData?.map((d, index) => {
|
|
104
|
-
const
|
|
120
|
+
const isSelectedEval = isSelected ? isSelected(input.value, d) : get(input.value, uniqueIdentificationPath) === get(d, uniqueIdentificationPath);
|
|
105
121
|
return (
|
|
106
122
|
<button
|
|
107
123
|
key={`typedown-button-[${index}]`}
|
|
108
124
|
className={classnames(
|
|
109
|
-
interactionStyles,
|
|
110
125
|
css.fullWidth,
|
|
111
126
|
css.menuButton
|
|
112
127
|
)}
|
|
113
|
-
data-selected={
|
|
128
|
+
data-selected={isSelectedEval}
|
|
114
129
|
id={`typedown-button-[${index}]`}
|
|
115
130
|
onClick={() => {
|
|
116
131
|
handleChange(d);
|
|
@@ -123,8 +138,7 @@ const Typedown = ({
|
|
|
123
138
|
</button>
|
|
124
139
|
);
|
|
125
140
|
}) :
|
|
126
|
-
|
|
127
|
-
<EndOfList />
|
|
141
|
+
endOfList || <EndOfList />
|
|
128
142
|
}
|
|
129
143
|
</div>
|
|
130
144
|
{renderFooter &&
|
|
@@ -133,17 +147,21 @@ const Typedown = ({
|
|
|
133
147
|
className={css.footer}
|
|
134
148
|
id={`typedown-footer-${selectorSafe(input.name)}`}
|
|
135
149
|
>
|
|
136
|
-
{renderFooter()}
|
|
150
|
+
{renderFooter(displayData, currentlyTyped, exactMatch)}
|
|
137
151
|
</div>
|
|
138
152
|
}
|
|
139
153
|
</div>
|
|
140
154
|
);
|
|
141
155
|
}, [
|
|
156
|
+
currentlyTyped,
|
|
142
157
|
displayData,
|
|
158
|
+
endOfList,
|
|
159
|
+
exactMatch,
|
|
143
160
|
footerRef,
|
|
144
161
|
handleChange,
|
|
145
162
|
handleNextFocus,
|
|
146
163
|
input,
|
|
164
|
+
isSelected,
|
|
147
165
|
listKeyDownHandler,
|
|
148
166
|
listRef,
|
|
149
167
|
renderFooter,
|
|
@@ -173,7 +191,20 @@ const Typedown = ({
|
|
|
173
191
|
return (
|
|
174
192
|
<div
|
|
175
193
|
ref={resizeRef}
|
|
194
|
+
className={classnames(
|
|
195
|
+
css.typedown,
|
|
196
|
+
className
|
|
197
|
+
)}
|
|
176
198
|
>
|
|
199
|
+
{label &&
|
|
200
|
+
<Label
|
|
201
|
+
htmlFor={id}
|
|
202
|
+
id={`${id}-label`}
|
|
203
|
+
required={required}
|
|
204
|
+
>
|
|
205
|
+
{label}
|
|
206
|
+
</Label>
|
|
207
|
+
}
|
|
177
208
|
{renderSearchField()}
|
|
178
209
|
<Popper
|
|
179
210
|
key="typedown-menu-toggle"
|
|
@@ -200,7 +231,6 @@ const Typedown = ({
|
|
|
200
231
|
{selectedUniqueId && !open &&
|
|
201
232
|
<div
|
|
202
233
|
className={classnames(
|
|
203
|
-
css.selected,
|
|
204
234
|
css.selectedDisplay
|
|
205
235
|
)}
|
|
206
236
|
>
|
|
@@ -221,14 +251,27 @@ const Typedown = ({
|
|
|
221
251
|
};
|
|
222
252
|
|
|
223
253
|
Typedown.propTypes = {
|
|
254
|
+
className: PropTypes.string,
|
|
224
255
|
dataOptions: PropTypes.arrayOf(PropTypes.object),
|
|
256
|
+
endOfList: PropTypes.oneOfType([
|
|
257
|
+
PropTypes.func,
|
|
258
|
+
PropTypes.node,
|
|
259
|
+
PropTypes.element
|
|
260
|
+
]),
|
|
225
261
|
filterPath: PropTypes.string,
|
|
262
|
+
id: PropTypes.string,
|
|
226
263
|
input: PropTypes.object,
|
|
264
|
+
isSelected: PropTypes.func,
|
|
265
|
+
label: PropTypes.oneOfType([
|
|
266
|
+
PropTypes.string,
|
|
267
|
+
PropTypes.element
|
|
268
|
+
]),
|
|
227
269
|
meta: PropTypes.object,
|
|
228
270
|
onChange: PropTypes.func,
|
|
229
271
|
onType: PropTypes.func,
|
|
230
272
|
renderFooter: PropTypes.func,
|
|
231
273
|
renderListItem: PropTypes.func,
|
|
274
|
+
required: PropTypes.bool,
|
|
232
275
|
uniqueIdentificationPath: PropTypes.string
|
|
233
276
|
};
|
|
234
277
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const TYPE_CLASS_PREFIX = 'com.k_int.web.toolkit.custprops.types.CustomProperty';
|
|
2
|
+
export const BLOB_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyBlob';
|
|
3
|
+
export const BOOLEAN_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyBoolean';
|
|
4
|
+
export const CONTAINER_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyContainer';
|
|
5
|
+
export const DECIMAL_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyDecimal';
|
|
6
|
+
export const INTEGER_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyInteger';
|
|
7
|
+
export const REFDATA_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyRefdata';
|
|
8
|
+
export const REFDATA_DEFINITION_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyRefdataDefinition';
|
|
9
|
+
export const TEXT_CLASS_NAME = 'com.k_int.web.toolkit.custprops.types.CustomPropertyText';
|
package/src/lib/hooks/index.js
CHANGED
|
@@ -8,3 +8,5 @@ export { default as useLocalStorageState } from './useLocalStorageState';
|
|
|
8
8
|
export { default as useQIndex } from './useQIndex';
|
|
9
9
|
export { useSettings, useSettingSection } from './settingsHooks';
|
|
10
10
|
export { default as useKiwtFieldArray } from './useKiwtFieldArray';
|
|
11
|
+
export { default as useCustomProperties } from './useCustomProperties';
|
|
12
|
+
export { default as useMutateCustomProperties } from './useMutateCustomProperties';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
3
|
+
import { useQuery } from 'react-query';
|
|
4
|
+
import { useOkapiKy } from '@folio/stripes/core';
|
|
5
|
+
|
|
6
|
+
import { generateKiwtQuery } from '../utils';
|
|
7
|
+
|
|
8
|
+
const useCustomProperties = ({
|
|
9
|
+
endpoint,
|
|
10
|
+
ctx,
|
|
11
|
+
nsValues = {
|
|
12
|
+
sort: 'id'
|
|
13
|
+
},
|
|
14
|
+
options = {},
|
|
15
|
+
queryParams,
|
|
16
|
+
returnQueryObject = false,
|
|
17
|
+
}) => {
|
|
18
|
+
const ky = useOkapiKy();
|
|
19
|
+
|
|
20
|
+
const custPropOptions = {
|
|
21
|
+
searchKey: 'label,name,description',
|
|
22
|
+
filterKeys: {
|
|
23
|
+
ContextKey: 'ctx'
|
|
24
|
+
},
|
|
25
|
+
filters: [],
|
|
26
|
+
stats: false,
|
|
27
|
+
max: 100,
|
|
28
|
+
...options
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (Array.isArray(ctx)) {
|
|
32
|
+
// If we have an array, append a context filter for each ctx given
|
|
33
|
+
|
|
34
|
+
// Special case if one is isNull
|
|
35
|
+
custPropOptions.filters.push({
|
|
36
|
+
values: ctx.map(c => (c === 'isNull' ? 'ctx isNull' : `ctx==${c}`))
|
|
37
|
+
});
|
|
38
|
+
} else if (ctx === 'isNull') { // isNull is a special case
|
|
39
|
+
custPropOptions.filters.push({
|
|
40
|
+
value: 'ctx isNull'
|
|
41
|
+
});
|
|
42
|
+
} else if (ctx) {
|
|
43
|
+
custPropOptions.filters.push({
|
|
44
|
+
path: 'ctx',
|
|
45
|
+
value: ctx
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const query = generateKiwtQuery(custPropOptions, nsValues);
|
|
50
|
+
const path = `${endpoint}${query}`;
|
|
51
|
+
|
|
52
|
+
const queryObject = useQuery(
|
|
53
|
+
['stripes-kint-components', 'useCustomProperties', 'custprops', ctx, path],
|
|
54
|
+
() => ky(path).json(),
|
|
55
|
+
queryParams
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (returnQueryObject) {
|
|
59
|
+
return queryObject || {};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const { data: custprops } = queryObject;
|
|
63
|
+
return custprops || [];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
useCustomProperties.propTypes = {
|
|
67
|
+
endpoint: PropTypes.string,
|
|
68
|
+
ctx: PropTypes.oneOfType([
|
|
69
|
+
PropTypes.string,
|
|
70
|
+
PropTypes.arrayOf(PropTypes.string)
|
|
71
|
+
]),
|
|
72
|
+
queryParams: PropTypes.object,
|
|
73
|
+
returnQueryObject: PropTypes.bool
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default useCustomProperties;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useMutation } from 'react-query';
|
|
2
|
+
|
|
3
|
+
import { useOkapiKy } from '@folio/stripes/core';
|
|
4
|
+
|
|
5
|
+
const useMutateCustomProperties = ({
|
|
6
|
+
afterQueryCalls,
|
|
7
|
+
endpoint,
|
|
8
|
+
id,
|
|
9
|
+
queryParams,
|
|
10
|
+
returnQueryObject = {
|
|
11
|
+
post: false,
|
|
12
|
+
put: false,
|
|
13
|
+
delete: false
|
|
14
|
+
}
|
|
15
|
+
}) => {
|
|
16
|
+
const returnObj = {};
|
|
17
|
+
|
|
18
|
+
const ky = useOkapiKy();
|
|
19
|
+
|
|
20
|
+
const deleteQueryObject = useMutation(
|
|
21
|
+
['stripes-kint-components', 'useMutateCustomProperties', 'delete', id],
|
|
22
|
+
async () => ky.delete(`${endpoint}/${id}`).json()
|
|
23
|
+
.then(afterQueryCalls?.delete),
|
|
24
|
+
queryParams?.delete
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const putQueryObject = useMutation(
|
|
28
|
+
['stripes-kint-components', 'useMutateCustomProperties', 'put', id],
|
|
29
|
+
async (data) => ky.put(`${endpoint}/${id}`, { json: data }).json()
|
|
30
|
+
.then(afterQueryCalls?.put),
|
|
31
|
+
queryParams?.put
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const postQueryObject = useMutation(
|
|
35
|
+
['stripes-kint-components', 'useMutateCustomProperties', 'post'],
|
|
36
|
+
async (data) => ky.post(`${endpoint}`, { json: data }).json()
|
|
37
|
+
.then(afterQueryCalls?.post),
|
|
38
|
+
queryParams?.post
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (returnQueryObject?.delete) {
|
|
42
|
+
returnObj.delete = deleteQueryObject;
|
|
43
|
+
} else {
|
|
44
|
+
returnObj.delete = deleteQueryObject.mutateAsync;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (returnQueryObject?.put) {
|
|
48
|
+
returnObj.put = putQueryObject;
|
|
49
|
+
} else {
|
|
50
|
+
returnObj.put = putQueryObject.mutateAsync;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (returnQueryObject?.post) {
|
|
54
|
+
returnObj.post = postQueryObject;
|
|
55
|
+
} else {
|
|
56
|
+
returnObj.post = postQueryObject.mutateAsync;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return returnObj;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default useMutateCustomProperties;
|
|
@@ -6,6 +6,31 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
6
6
|
filterKeys = {},
|
|
7
7
|
sortKeys = {},
|
|
8
8
|
stats = true,
|
|
9
|
+
/* Assumption made that if a direct sort array is passed in options, it overrides the nsValues
|
|
10
|
+
* Of the form [{ path: 'this.is.some.path', direction: 'asc'/'desc', value: 'someOverrideValue'}, ...]
|
|
11
|
+
* If only path is passed then assume asc.
|
|
12
|
+
* If value is passed then we ignore path/direction and append "sort=${value}" directly
|
|
13
|
+
*/
|
|
14
|
+
sort: optionsSort,
|
|
15
|
+
/* Assumption made that if a direct filters array is passed in options, it overrides the nsValues
|
|
16
|
+
* Of the form
|
|
17
|
+
[
|
|
18
|
+
{
|
|
19
|
+
path: 'this.is.some.path'
|
|
20
|
+
comparator: '=='
|
|
21
|
+
value: 'this is a value' //OR
|
|
22
|
+
values: ['value1', 'value2']
|
|
23
|
+
},
|
|
24
|
+
...
|
|
25
|
+
]
|
|
26
|
+
* This (with value instead of values) will construct a query param: "filters=this.is.some.path==this is a value"
|
|
27
|
+
* If only value is passed, then it will construct directly: "filters=value"
|
|
28
|
+
* If no comparator is passed, it assumes '=='
|
|
29
|
+
* Values overwrites value and will construct "filters=this.is.some.path==value1||this.is.some.path==value2"
|
|
30
|
+
* Values WITHOUT path will construct "filters=value1||value2"
|
|
31
|
+
* If more complex query building is desired, this should be done externally and passed in as a standalone 'value'
|
|
32
|
+
*/
|
|
33
|
+
filters: optionsFilters,
|
|
9
34
|
...rest
|
|
10
35
|
} = options;
|
|
11
36
|
|
|
@@ -16,10 +41,31 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
16
41
|
paramsArray.push(`term=${query}`);
|
|
17
42
|
}
|
|
18
43
|
|
|
19
|
-
if (
|
|
44
|
+
if (optionsFilters) {
|
|
45
|
+
optionsFilters.forEach(opf => {
|
|
46
|
+
if (opf?.values) {
|
|
47
|
+
// Build the values filter block
|
|
48
|
+
const innerFilters = [];
|
|
49
|
+
opf.values.forEach(opfv => {
|
|
50
|
+
if (opf.path) {
|
|
51
|
+
innerFilters.push(`${opf.path}${opf.comparator ?? '=='}${opfv}`);
|
|
52
|
+
} else {
|
|
53
|
+
innerFilters.push(opfv);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
paramsArray.push(`filters=${innerFilters.join('||')}`);
|
|
57
|
+
} else if (opf?.value) { // If no value OR values, then ignore
|
|
58
|
+
if (opf.path) {
|
|
59
|
+
paramsArray.push(`filters=${opf.path}${opf.comparator ?? '=='}${opf.value}`);
|
|
60
|
+
} else {
|
|
61
|
+
paramsArray.push(`filters=${opf.value}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} else if (filters) {
|
|
20
66
|
const filterMap = {};
|
|
21
67
|
filters.split(',').forEach(filter => {
|
|
22
|
-
const [filterName, ...filterRest] = filter.split('.');
|
|
68
|
+
const [filterName, ...filterRest] = filter.trim()?.split('.');
|
|
23
69
|
const filterValue = filterRest.join('.');
|
|
24
70
|
|
|
25
71
|
if (filterMap[filterName] === undefined) filterMap[filterName] = [];
|
|
@@ -40,8 +86,16 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
40
86
|
});
|
|
41
87
|
}
|
|
42
88
|
|
|
43
|
-
if (
|
|
44
|
-
|
|
89
|
+
if (optionsSort && optionsSort.length > 0) {
|
|
90
|
+
optionsSort.forEach(os => {
|
|
91
|
+
if (os.value) {
|
|
92
|
+
paramsArray.push(`sort=${os.value}`);
|
|
93
|
+
} else if (os.path) { // If no path then ignore
|
|
94
|
+
paramsArray.push(`sort=${os.path};${os.direction ?? 'asc'}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
} else if (sort) {
|
|
98
|
+
paramsArray.push(...sort.trim()?.split(',').map(sortKey => {
|
|
45
99
|
const descending = sortKey.startsWith('-');
|
|
46
100
|
let term = sortKey.replace('-', '');
|
|
47
101
|
|
package/styles/TypeDown.css
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
@import '@folio/stripes-components/lib/variables.css';
|
|
2
2
|
|
|
3
|
+
.typedown {
|
|
4
|
+
margin-bottom: var(--gutter);
|
|
5
|
+
}
|
|
6
|
+
|
|
3
7
|
.fullWidth {
|
|
4
8
|
width: 100%;
|
|
5
9
|
}
|
|
@@ -24,6 +28,7 @@
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
.menuButton {
|
|
31
|
+
composes: interactionStyles from "@folio/stripes-components/lib/sharedStyles/interactionStyles.css";
|
|
27
32
|
margin-bottom: 0;
|
|
28
33
|
border: none;
|
|
29
34
|
border-radius: 0;
|
|
@@ -57,6 +62,8 @@
|
|
|
57
62
|
|
|
58
63
|
.selectedDisplay {
|
|
59
64
|
border-radius: 0 0 var(--radius) var(--radius);
|
|
65
|
+
border: 1px solid #ccc;
|
|
66
|
+
border-top: 0;
|
|
60
67
|
display: flex;
|
|
61
68
|
}
|
|
62
69
|
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
+
|
|
3
|
+
"create": "Create",
|
|
4
|
+
"edit": "Edit",
|
|
5
|
+
"save": "Save",
|
|
6
|
+
"cancel": "Cancel",
|
|
7
|
+
"delete": "Delete",
|
|
8
|
+
|
|
9
|
+
"errors.hasNonAlphaName": "The name can only contain Latin alphabetical characters (a-z) and non-leading numeric characters.",
|
|
10
|
+
|
|
2
11
|
"settings.noCurrentValue": "No current value",
|
|
3
12
|
"settings.default": "default",
|
|
4
13
|
"settings.edit": "Edit",
|
|
@@ -18,5 +27,44 @@
|
|
|
18
27
|
|
|
19
28
|
"sasqLookupComponent.mainPane.found": "{total} records found",
|
|
20
29
|
|
|
21
|
-
"noResultsMessage.showFilters": "Show filters"
|
|
30
|
+
"noResultsMessage.showFilters": "Show filters",
|
|
31
|
+
|
|
32
|
+
"customProperties": "Custom properties",
|
|
33
|
+
|
|
34
|
+
"customProperties.all": "All",
|
|
35
|
+
"customProperties.none": "None",
|
|
36
|
+
|
|
37
|
+
"customProperties.label": "Label",
|
|
38
|
+
"customProperties.primary": "Primary",
|
|
39
|
+
"customProperties.ctx": "Context",
|
|
40
|
+
"customProperties.ctx.addContext": "Add context {value}",
|
|
41
|
+
"customProperties.weight": "Order weight",
|
|
42
|
+
"customProperties.type": "Type",
|
|
43
|
+
"customProperties.internalFalse": "Public",
|
|
44
|
+
"customProperties.internalNote": "Internal note",
|
|
45
|
+
"customProperties.internalTrue": "Internal",
|
|
46
|
+
"customProperties.publicNote": "Public note",
|
|
47
|
+
"customProperties.name": "Name",
|
|
48
|
+
"customProperties.description": "Description",
|
|
49
|
+
"customProperties.category": "Picklist",
|
|
50
|
+
"customProperties.defaultVisibility": "Default visibility",
|
|
51
|
+
|
|
52
|
+
"customProperties.noCtxFound": "No matching context found",
|
|
53
|
+
|
|
54
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyBlob": "Blob",
|
|
55
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyBoolean": "Boolean",
|
|
56
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyContainer": "Container",
|
|
57
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyDecimal": "Decimal",
|
|
58
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyInteger": "Integer",
|
|
59
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyRefdata": "Refdata",
|
|
60
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyRefdataDefinition": "Refdata definition",
|
|
61
|
+
"customProperties.type.com.k_int.web.toolkit.custprops.types.CustomPropertyText": "Text",
|
|
62
|
+
|
|
63
|
+
"customProperties.delete.confirmLabel": "Delete",
|
|
64
|
+
"customProperties.delete.confirmHeading": "Delete custom property",
|
|
65
|
+
"customProperties.delete.confirmMessage": "Custom property <strong>{name}</strong> will be <strong>deleted</strong>.",
|
|
66
|
+
|
|
67
|
+
"search": "Search",
|
|
68
|
+
"yes": "Yes",
|
|
69
|
+
"no": "No"
|
|
22
70
|
}
|