@k-int/stripes-kint-components 2.3.3 → 2.5.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 +21 -7
- package/README.md +14 -1
- package/es/index.js +26 -2
- package/es/lib/ActionList/ActionList.js +20 -7
- package/es/lib/ActionList/ActionListFieldArray.js +86 -85
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +1 -3
- package/es/lib/CustomProperties/View/CustomPropertyCard.js +2 -2
- package/es/lib/EditableRefdataList/EditableRefdataList.js +3 -0
- package/es/lib/EditableSettingsList/EditableSettingsList.js +4 -1
- package/es/lib/FormModal/FormModal.js +10 -1
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +62 -105
- package/es/lib/SASQLookupComponent/TableBody/TableBody.js +146 -0
- package/es/lib/SASQLookupComponent/TableBody/index.js +19 -0
- package/es/lib/SASQLookupComponent/index.js +9 -1
- package/es/lib/SASQRoute/SASQRoute.js +2 -2
- package/es/lib/Typedown/Typedown.js +5 -7
- package/es/lib/hooks/settingsHooks/useSettingSection.js +16 -3
- package/es/lib/hooks/settingsHooks/useSettings.js +14 -7
- package/es/lib/utils/generateKiwtQueryParams.js +21 -4
- package/es/lib/utils/highlightString.js +94 -0
- package/es/lib/utils/index.js +23 -1
- package/es/lib/utils/matchString.js +59 -0
- package/junit.xml +37 -37
- package/package.json +1 -2
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +42 -12
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +222 -93
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +12 -12
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertiesSettings.js.html +20 -17
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyForm.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/CustomPropertyView.js.html +601 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.html +15 -15
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Config/index.js.html +2 -2
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEdit.js.html +190 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesEditCtx.js.html +340 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertiesListField.js.html +667 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyField.js.html +982 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/CustomPropertyFormCard.js.html +478 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.html +191 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Edit/index.js.html +100 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilter.js.html +460 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterField.js.html +529 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js.html +424 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesFilterForm.js.html +307 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/CustomPropertiesRule.js.html +451 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.html +236 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/index.js.html +103 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useOperators.js.html +250 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useParseActiveFilterStrings.js.html +190 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/Filter/useValueProps.js.html +220 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesView.js.html +193 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertiesViewCtx.js.html +436 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/CustomPropertyCard.js.html +616 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/View/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/index.html +116 -0
- package/src/artifacts/coverage-jest/lcov-report/CustomProperties/index.js.html +175 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +33 -18
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +5 -5
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +8 -2
- 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 +102 -24
- package/src/artifacts/coverage-jest/lcov-report/FormModal/index.html +9 -9
- package/src/artifacts/coverage-jest/lcov-report/FormModal/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +1 -1
- 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 +14 -8
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +11 -11
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +1 -1
- 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 +60 -153
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/TableBody.js.html +373 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/TableBody/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +9 -9
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +6 -3
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +2 -2
- 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 +1 -1
- 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 +7 -25
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +3 -3
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/constants/customProperties.js.html +7 -4
- package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/constants/index.html +5 -5
- 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 +39 -9
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +8 -2
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +5 -5
- 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 +57 -6
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +29 -8
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +7 -7
- 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 +26 -8
- 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/useAvailableCustomProperties.js.html +205 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useCustomProperties.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useInvalidateRefdata.js.html +118 -0
- 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 +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +21 -9
- package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +6 -9
- package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/index.html +126 -51
- 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 +36 -9
- package/src/artifacts/coverage-jest/lcov-report/utils/groupCustomPropertiesByCtx.js.html +124 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/highlightString.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +95 -20
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +29 -2
- package/src/artifacts/coverage-jest/lcov-report/utils/matchString.js.html +127 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +1 -1
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataQueryKey.js.html +112 -0
- 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-report/utils/typedownQueryKey.js.html +112 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/validators.js.html +126 -6
- package/src/artifacts/coverage-jest/lcov.info +2043 -718
- package/src/index.js +6 -1
- package/src/lib/ActionList/ActionList.js +12 -5
- package/src/lib/ActionList/ActionListFieldArray.js +86 -65
- package/src/lib/ActionList/README.md +19 -0
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +1 -3
- package/src/lib/CustomProperties/View/CustomPropertyCard.js +2 -2
- package/src/lib/EditableRefdataList/EditableRefdataList.js +3 -1
- package/src/lib/EditableSettingsList/EditableSettingsList.js +8 -1
- package/src/lib/FormModal/FormModal.js +6 -2
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +46 -77
- package/src/lib/SASQLookupComponent/TableBody/TableBody.js +96 -0
- package/src/lib/SASQLookupComponent/TableBody/index.js +1 -0
- package/src/lib/SASQLookupComponent/index.js +2 -1
- package/src/lib/SASQRoute/SASQRoute.js +1 -1
- package/src/lib/Typedown/Typedown.js +4 -10
- package/src/lib/hooks/settingsHooks/useSettingSection.js +19 -2
- package/src/lib/hooks/settingsHooks/useSettings.js +12 -5
- package/src/lib/utils/generateKiwtQueryParams.js +10 -1
- package/src/lib/utils/highlightString.js +42 -0
- package/src/lib/utils/index.js +4 -0
- package/src/lib/utils/matchString.js +14 -0
- package/styles/ActionListFieldArray.css +10 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
|
|
3
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
MultiColumnList,
|
|
7
|
+
} from '@folio/stripes/components';
|
|
8
|
+
import NoResultsMessage from '../../NoResultsMessage';
|
|
9
|
+
|
|
10
|
+
const TableBody = ({
|
|
11
|
+
data,
|
|
12
|
+
error,
|
|
13
|
+
fetchNextPage,
|
|
14
|
+
filterPaneVisible,
|
|
15
|
+
isError,
|
|
16
|
+
isLoading,
|
|
17
|
+
match,
|
|
18
|
+
mclProps,
|
|
19
|
+
onSort,
|
|
20
|
+
path,
|
|
21
|
+
resultColumns,
|
|
22
|
+
toggleFilterPane,
|
|
23
|
+
query,
|
|
24
|
+
}) => {
|
|
25
|
+
const sortOrder = query.sort ?? '';
|
|
26
|
+
const history = useHistory();
|
|
27
|
+
const location = useLocation();
|
|
28
|
+
|
|
29
|
+
const onNeedMoreData = (_askAmount, index) => {
|
|
30
|
+
fetchNextPage({ pageParam: index });
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Build the map of column definitions
|
|
34
|
+
const columnMapping = Object.fromEntries(
|
|
35
|
+
resultColumns.map(e => [e.propertyPath, e.label])
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Build the list of visible columns
|
|
39
|
+
const visibleColumns = resultColumns.map(e => e.propertyPath);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<MultiColumnList
|
|
43
|
+
autosize
|
|
44
|
+
columnMapping={columnMapping}
|
|
45
|
+
contentData={data?.results}
|
|
46
|
+
hasMargin
|
|
47
|
+
isEmptyMessage={
|
|
48
|
+
<NoResultsMessage
|
|
49
|
+
{...{
|
|
50
|
+
error,
|
|
51
|
+
isError,
|
|
52
|
+
isLoading,
|
|
53
|
+
filterPaneIsVisible: filterPaneVisible,
|
|
54
|
+
searchTerm: query.query,
|
|
55
|
+
toggleFilterPane
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
}
|
|
59
|
+
isSelected={({ item }) => item.id === match?.params?.id}
|
|
60
|
+
onHeaderClick={onSort}
|
|
61
|
+
onNeedMoreData={onNeedMoreData}
|
|
62
|
+
onRowClick={(_e, rowData) => {
|
|
63
|
+
history.push(`${path}/${rowData?.id}${location?.search}`);
|
|
64
|
+
}}
|
|
65
|
+
pagingType="click"
|
|
66
|
+
sortDirection={sortOrder.startsWith('-') ? 'descending' : 'ascending'}
|
|
67
|
+
sortOrder={sortOrder.replace(/^-/, '').replace(/,.*/, '')}
|
|
68
|
+
totalCount={data.totalRecords}
|
|
69
|
+
visibleColumns={visibleColumns}
|
|
70
|
+
{...mclProps}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
TableBody.propTypes = {
|
|
76
|
+
data: PropTypes.shape({
|
|
77
|
+
totalRecords: PropTypes.number,
|
|
78
|
+
results: PropTypes.arrayOf(PropTypes.object)
|
|
79
|
+
}),
|
|
80
|
+
error: PropTypes.object,
|
|
81
|
+
fetchNextPage: PropTypes.func,
|
|
82
|
+
filterPaneVisible: PropTypes.bool,
|
|
83
|
+
history: PropTypes.object,
|
|
84
|
+
isError: PropTypes.bool,
|
|
85
|
+
isLoading: PropTypes.bool,
|
|
86
|
+
location: PropTypes.object,
|
|
87
|
+
match: PropTypes.object,
|
|
88
|
+
mclProps: PropTypes.object,
|
|
89
|
+
onSort: PropTypes.func,
|
|
90
|
+
path: PropTypes.string.isRequired,
|
|
91
|
+
query: PropTypes.object,
|
|
92
|
+
resultColumns: PropTypes.arrayOf(PropTypes.object),
|
|
93
|
+
toggleFilterPane: PropTypes.func
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default TableBody;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './TableBody';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from './SASQLookupComponent';
|
|
1
|
+
export { default as SASQLookupComponent } from './SASQLookupComponent';
|
|
2
|
+
export { default as TableBody } from './TableBody';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Switch
|
|
7
7
|
} from 'react-router-dom';
|
|
8
8
|
|
|
9
|
-
import SASQLookupComponent from '../SASQLookupComponent';
|
|
9
|
+
import { SASQLookupComponent } from '../SASQLookupComponent';
|
|
10
10
|
import SASQViewComponent from '../SASQViewComponent';
|
|
11
11
|
|
|
12
12
|
const SASQRoute = ({ children, path, fetchParameters, ...props }) => {
|
|
@@ -4,7 +4,7 @@ import classnames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import get from 'lodash/get';
|
|
6
6
|
|
|
7
|
-
import { EndOfList, IconButton,
|
|
7
|
+
import { EndOfList, IconButton, Popper } from '@folio/stripes/components';
|
|
8
8
|
|
|
9
9
|
import SearchField from '../SearchField';
|
|
10
10
|
import css from '../../../styles/TypeDown.css';
|
|
@@ -179,10 +179,12 @@ const Typedown = ({
|
|
|
179
179
|
<SearchField
|
|
180
180
|
// Pass meta through so correct styling gets applied to the TextField
|
|
181
181
|
id={`typedown-searchField-${selectorSafe(input.name)}`}
|
|
182
|
+
label={label}
|
|
182
183
|
marginBottom0
|
|
183
184
|
meta={meta}
|
|
184
185
|
onChange={handleType}
|
|
185
186
|
onKeyDown={searchFieldKeyDownHandler}
|
|
187
|
+
required={required}
|
|
186
188
|
/>
|
|
187
189
|
</div>
|
|
188
190
|
);
|
|
@@ -195,16 +197,8 @@ const Typedown = ({
|
|
|
195
197
|
css.typedown,
|
|
196
198
|
className
|
|
197
199
|
)}
|
|
200
|
+
id={`typedown-id-${id}`}
|
|
198
201
|
>
|
|
199
|
-
{label &&
|
|
200
|
-
<Label
|
|
201
|
-
htmlFor={id}
|
|
202
|
-
id={`${id}-label`}
|
|
203
|
-
required={required}
|
|
204
|
-
>
|
|
205
|
-
{label}
|
|
206
|
-
</Label>
|
|
207
|
-
}
|
|
208
202
|
{renderSearchField()}
|
|
209
203
|
<Popper
|
|
210
204
|
key="typedown-menu-toggle"
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useMutation, useQuery } from 'react-query';
|
|
3
3
|
import { useOkapiKy } from '@folio/stripes/core';
|
|
4
|
+
import { generateKiwtQueryParams } from '../../utils';
|
|
4
5
|
|
|
5
6
|
const useSettingSection = ({
|
|
6
7
|
sectionName,
|
|
7
8
|
settingEndpoint
|
|
8
9
|
}) => {
|
|
9
10
|
const ky = useOkapiKy();
|
|
11
|
+
const queryParams = generateKiwtQueryParams({
|
|
12
|
+
filters: [
|
|
13
|
+
{
|
|
14
|
+
path: 'section',
|
|
15
|
+
value: sectionName
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
sort: [
|
|
19
|
+
{
|
|
20
|
+
path: 'key'
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
perPage: 100,
|
|
24
|
+
stats: false
|
|
25
|
+
}, {});
|
|
26
|
+
|
|
10
27
|
const { data: settings = [] } = useQuery(
|
|
11
|
-
['stripes-kint-components', 'useSetting', 'appSettings', sectionName],
|
|
12
|
-
() => ky(`${settingEndpoint}
|
|
28
|
+
['stripes-kint-components', 'useSetting', 'appSettings', queryParams, sectionName],
|
|
29
|
+
() => ky(`${settingEndpoint}?${queryParams?.join('&')}`).json()
|
|
13
30
|
);
|
|
14
31
|
|
|
15
32
|
const { mutateAsync: putSetting } = useMutation(
|
|
@@ -10,7 +10,7 @@ import { Settings } from '@folio/stripes/smart-components';
|
|
|
10
10
|
import { SettingPage, SettingPagePane } from '../../SettingPage';
|
|
11
11
|
import { SettingsContext } from '../../contexts';
|
|
12
12
|
|
|
13
|
-
import { sortByLabel, toCamelCase } from '../../utils';
|
|
13
|
+
import { generateKiwtQueryParams, sortByLabel, toCamelCase } from '../../utils';
|
|
14
14
|
|
|
15
15
|
const useSettings = ({
|
|
16
16
|
dynamicPageExclusions,
|
|
@@ -22,12 +22,19 @@ const useSettings = ({
|
|
|
22
22
|
}) => {
|
|
23
23
|
const ky = useOkapiKy();
|
|
24
24
|
const intl = useIntl();
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const queryParams = generateKiwtQueryParams({
|
|
26
|
+
filters: dynamicPageExclusions?.map(dpe => ({
|
|
27
|
+
path: 'section',
|
|
28
|
+
comparator: '!=',
|
|
29
|
+
value: dpe
|
|
30
|
+
})),
|
|
31
|
+
perPage: 100,
|
|
32
|
+
stats: false
|
|
33
|
+
}, {});
|
|
27
34
|
|
|
28
35
|
const { data: appSettings = [], isLoading } = useQuery(
|
|
29
|
-
['stripes-kint-components', 'useSettings', 'appSettings', settingEndpoint],
|
|
30
|
-
() => ky(`${settingEndpoint}?${
|
|
36
|
+
['stripes-kint-components', 'useSettings', 'appSettings', settingEndpoint, queryParams],
|
|
37
|
+
() => ky(`${settingEndpoint}?${queryParams?.join('&')}`).json()
|
|
31
38
|
);
|
|
32
39
|
|
|
33
40
|
const sections = [...new Set(appSettings.map(s => s.section))];
|
|
@@ -2,6 +2,7 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
2
2
|
const { qindex, query, filters, sort } = nsValues;
|
|
3
3
|
const {
|
|
4
4
|
searchKey = '',
|
|
5
|
+
filterConfig = [],
|
|
5
6
|
/* Assumtion made that if no filterKey is provided then the given filterValues for that key are standalaone, ie require no comparator or key */
|
|
6
7
|
filterKeys = {},
|
|
7
8
|
sortKeys = {},
|
|
@@ -74,9 +75,17 @@ const generateKiwtQueryParams = (options, nsValues) => {
|
|
|
74
75
|
|
|
75
76
|
// We now have a filterMap of shape { status: ['active', 'cancelled'], type: ['local'] }
|
|
76
77
|
Object.entries(filterMap).forEach(([filterName, filterValues]) => {
|
|
78
|
+
const filterConfigEntry = filterConfig.find(conf => conf.name === filterName);
|
|
77
79
|
const filterKey = filterKeys[filterName];
|
|
80
|
+
if (filterConfigEntry) {
|
|
81
|
+
// We have a direct mapping instruction, use it
|
|
82
|
+
const filterString = filterValues.map(v => {
|
|
83
|
+
const fceValue = filterConfigEntry?.values?.find(fce => fce.name === v)?.value;
|
|
84
|
+
return `${filterName}==${fceValue ?? v}`;
|
|
85
|
+
}).join('||');
|
|
78
86
|
|
|
79
|
-
|
|
87
|
+
paramsArray.push(`filters=${filterString}`);
|
|
88
|
+
} else if (!filterKey) {
|
|
80
89
|
// These filters have no key mapping so we just pass the values to the backend as-is.
|
|
81
90
|
paramsArray.push(...filterValues?.map(f => `filters=${f}`));
|
|
82
91
|
} else {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import matchString from './matchString';
|
|
2
|
+
|
|
3
|
+
const highlightString = (match, str, ignoreNull = true) => {
|
|
4
|
+
const [parts, regex] = matchString(match, str, ignoreNull);
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
parts.filter(part => part).map((part, i) => (
|
|
8
|
+
regex.test(part) ?
|
|
9
|
+
<mark
|
|
10
|
+
key={i}
|
|
11
|
+
>
|
|
12
|
+
{part}
|
|
13
|
+
</mark> :
|
|
14
|
+
<span key={i}>
|
|
15
|
+
{part}
|
|
16
|
+
</span>
|
|
17
|
+
))
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const boldString = (match, str, ignoreNull = true) => {
|
|
22
|
+
const [parts, regex] = matchString(match, str, ignoreNull);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
parts.filter(part => part).map((part, i) => (
|
|
26
|
+
regex.test(part) ?
|
|
27
|
+
<strong
|
|
28
|
+
key={i}
|
|
29
|
+
>
|
|
30
|
+
{part}
|
|
31
|
+
</strong> :
|
|
32
|
+
<span key={i}>
|
|
33
|
+
{part}
|
|
34
|
+
</span>
|
|
35
|
+
))
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
boldString,
|
|
41
|
+
highlightString
|
|
42
|
+
};
|
package/src/lib/utils/index.js
CHANGED
|
@@ -15,3 +15,7 @@ export { default as groupCustomPropertiesByCtx } from './groupCustomPropertiesBy
|
|
|
15
15
|
export { default as renderHelpText } from './renderHelpText';
|
|
16
16
|
export { default as sortByLabel } from './sortByLabel';
|
|
17
17
|
export { default as toCamelCase } from './toCamelCase'; // I hate that this exists
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export { default as matchString } from './matchString';
|
|
21
|
+
export { boldString, highlightString } from './highlightString';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import escapeRegExp from 'lodash/escapeRegExp';
|
|
2
|
+
|
|
3
|
+
const matchString = (match, str, ignoreNull = true) => {
|
|
4
|
+
const regex = new RegExp(`${match.split(/(\s+)/).filter(h => h.trim()).map(hl => '(' + escapeRegExp(hl) + ')').join('|')}`, 'gi');
|
|
5
|
+
if (ignoreNull && !match) {
|
|
6
|
+
const nullRegex = /a^/gi; // Should match nothing
|
|
7
|
+
|
|
8
|
+
return [[str], nullRegex];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return [str.split(regex), regex];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default matchString;
|