@k-int/stripes-kint-components 1.3.0 → 1.7.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 +34 -2
- package/es/artifacts/coverage-jest/lcov-report/block-navigation.js +109 -0
- package/es/artifacts/coverage-jest/lcov-report/prettify.js +998 -0
- package/es/artifacts/coverage-jest/lcov-report/sorter.js +238 -0
- package/es/index.js +69 -17
- package/es/lib/ActionList/ActionList.js +63 -24
- package/es/lib/ActionList/ActionListFieldArray.js +158 -96
- package/es/lib/ActionList/index.js +7 -3
- 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/NoResultsMessage/NoResultsMessage.js +122 -0
- package/es/lib/NoResultsMessage/index.js +19 -0
- 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 +202 -131
- 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 +143 -101
- package/es/lib/TypeDown/index.js +6 -2
- package/es/lib/Typedown/Typedown.js +140 -96
- package/es/lib/Typedown/index.js +6 -2
- 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 +42 -8
- 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/useHelperApp.js +51 -12
- package/es/lib/hooks/useKiwtFieldArray.js +142 -0
- package/es/lib/hooks/useKiwtSASQuery.js +62 -7
- package/es/lib/hooks/useLocalStorageState.js +37 -4
- package/es/lib/hooks/useMutateRefdataValue.js +42 -9
- package/es/lib/hooks/useQIndex.js +108 -0
- package/es/lib/hooks/useRefdata.js +56 -12
- package/es/lib/hooks/useTemplates.js +36 -3
- package/es/lib/utils/buildUrl.js +43 -10
- package/es/lib/utils/generateKiwtQuery.js +31 -108
- package/es/lib/utils/generateKiwtQueryParams.js +154 -0
- package/es/lib/utils/index.js +55 -3
- 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/junit.xml +79 -0
- package/package.json +17 -10
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionList.js.html +256 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/ActionListFieldArray.js.html +799 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/ActionList/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/EditableRefdataList.js.html +376 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableRefdataList/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsList.js.html +223 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/EditableSettingsListFieldArray.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/EditSettingValue.js.html +376 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/RenderSettingValue.js.html +262 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/SettingField.js.html +436 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/SettingField/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/EditableSettingsList/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/NoResultsMessage.js.html +319 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/NoResultsMessage/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/QueryTypedown.js.html +184 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/QueryTypedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/RefdataButtons.js.html +370 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/RefdataButtons/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/SASQLookupComponent.js.html +949 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQLookupComponent/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/SASQRoute.js.html +274 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQRoute/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/SASQViewComponent.js.html +250 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SASQViewComponent/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/SearchField.js.html +214 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/SearchField/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPage.js.html +211 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/SettingPagePane.js.html +178 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/SettingPage/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/TypeDown.js.html +769 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/TypeDown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/Typedown.js.html +790 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/Typedown/index.js.html +88 -0
- package/src/artifacts/coverage-jest/lcov-report/base.css +224 -0
- package/src/artifacts/coverage-jest/lcov-report/block-navigation.js +87 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/eventCodes.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/constants/index.html +116 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/SettingsContext.js.html +97 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.html +131 -0
- package/src/artifacts/coverage-jest/lcov-report/contexts/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/favicon.png +0 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.html +251 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/index.js.html +115 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.html +146 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/index.js.html +91 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettingSection.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/settingsHooks/useSettings.js.html +403 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.html +161 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/index.js.html +94 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedown.js.html +520 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownData.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/typedownHooks/useTypedownToggle.js.html +163 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useActiveElement.js.html +157 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useHelperApp.js.html +283 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtFieldArray.js.html +274 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useKiwtSASQuery.js.html +178 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useLocalStorageState.js.html +136 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useMutateRefdataValue.js.html +301 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useQIndex.js.html +208 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useRefdata.js.html +268 -0
- package/src/artifacts/coverage-jest/lcov-report/hooks/useTemplates.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/index.html +401 -0
- package/src/artifacts/coverage-jest/lcov-report/prettify.css +1 -0
- package/src/artifacts/coverage-jest/lcov-report/prettify.js +2 -0
- package/src/artifacts/coverage-jest/lcov-report/sort-arrow-sprite.png +0 -0
- package/src/artifacts/coverage-jest/lcov-report/sorter.js +196 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/buildUrl.js.html +193 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQuery.js.html +109 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/generateKiwtQueryParams.js.html +286 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.html +236 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/index.js.html +121 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/refdataOptions.js.html +106 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/renderHelpText.js.html +166 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/selectorSafe.js.html +103 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/sortByLabel.js.html +130 -0
- package/src/artifacts/coverage-jest/lcov-report/utils/toCamelCase.js.html +127 -0
- package/src/artifacts/coverage-jest/lcov.info +1999 -0
- package/src/index.js +21 -6
- package/src/lib/ActionList/ActionList.js +5 -2
- package/src/lib/ActionList/ActionListFieldArray.js +20 -8
- package/src/lib/ActionList/README.md +1 -0
- package/src/lib/ActionList/index.js +1 -1
- 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/NoResultsMessage/NoResultsMessage.js +78 -0
- package/src/lib/NoResultsMessage/index.js +1 -0
- package/src/lib/{Settings → RefdataButtons}/RefdataButtons.js +1 -1
- package/src/lib/RefdataButtons/index.js +1 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +36 -8
- package/src/lib/SASQRoute/README.md +1 -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/README.md +1 -115
- package/src/lib/TypeDown/TypeDown.js +4 -2
- package/src/lib/Typedown/Typedown.js +2 -1
- package/src/lib/{Settings → contexts}/SettingsContext.js +1 -1
- package/src/lib/contexts/index.js +2 -0
- package/src/lib/hooks/README.md +107 -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/useHelperApp.js +5 -1
- package/src/lib/hooks/useKiwtFieldArray.js +63 -0
- package/src/lib/hooks/useKiwtSASQuery.js +9 -1
- package/src/lib/hooks/useQIndex.js +41 -0
- package/src/lib/hooks/useRefdata.js +17 -6
- package/src/lib/utils/README.md +39 -1
- package/src/lib/utils/generateKiwtQuery.js +3 -62
- package/src/lib/utils/generateKiwtQueryParams.js +67 -0
- package/src/lib/utils/index.js +10 -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/styles/NoResultsMessage.css +38 -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 +4 -1
- 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/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/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
package/src/index.js
CHANGED
|
@@ -2,29 +2,38 @@
|
|
|
2
2
|
export {
|
|
3
3
|
useActiveElement,
|
|
4
4
|
useHelperApp,
|
|
5
|
+
useKiwtFieldArray,
|
|
5
6
|
useKiwtSASQuery,
|
|
6
7
|
useLocalStorageState,
|
|
7
8
|
useMutateRefdataValue,
|
|
9
|
+
useQIndex,
|
|
8
10
|
useRefdata,
|
|
9
11
|
useTemplates,
|
|
12
|
+
useSettings
|
|
10
13
|
} from './lib/hooks';
|
|
11
14
|
|
|
12
15
|
// Useful utility functions
|
|
13
16
|
export {
|
|
14
|
-
generateKiwtQuery
|
|
17
|
+
generateKiwtQuery,
|
|
18
|
+
generateKiwtQueryParams,
|
|
19
|
+
refdataOptions,
|
|
20
|
+
selectorSafe
|
|
15
21
|
} from './lib/utils';
|
|
16
22
|
|
|
17
|
-
//
|
|
23
|
+
// Contexts
|
|
18
24
|
export {
|
|
19
25
|
SettingsContext,
|
|
26
|
+
} from './lib/contexts';
|
|
27
|
+
|
|
28
|
+
// Setting Page Components
|
|
29
|
+
export {
|
|
20
30
|
SettingPage,
|
|
21
31
|
SettingPagePane,
|
|
22
|
-
|
|
23
|
-
} from './lib/Settings';
|
|
32
|
+
} from './lib/SettingPage';
|
|
24
33
|
|
|
25
34
|
// ActionList & RefdataEditor components
|
|
26
|
-
export { ActionList } from './lib/ActionList';
|
|
27
|
-
export { EditableRefdataList } from './lib/EditableRefdataList';
|
|
35
|
+
export { default as ActionList } from './lib/ActionList';
|
|
36
|
+
export { default as EditableRefdataList } from './lib/EditableRefdataList';
|
|
28
37
|
|
|
29
38
|
// Typedown
|
|
30
39
|
export {
|
|
@@ -58,3 +67,9 @@ export {
|
|
|
58
67
|
export {
|
|
59
68
|
default as SASQViewComponent
|
|
60
69
|
} from './lib/SASQViewComponent';
|
|
70
|
+
|
|
71
|
+
// NoResultsMessage
|
|
72
|
+
export { default as NoResultsMessage } from './lib/NoResultsMessage';
|
|
73
|
+
|
|
74
|
+
// RefdataButtons
|
|
75
|
+
export { default as RefdataButtons } from './lib/RefdataButtons';
|
|
@@ -12,6 +12,7 @@ const propTypes = {
|
|
|
12
12
|
actionCalls: PropTypes.object,
|
|
13
13
|
columnMapping: PropTypes.object,
|
|
14
14
|
contentData: PropTypes.arrayOf(PropTypes.object),
|
|
15
|
+
creatableFields: PropTypes.object,
|
|
15
16
|
editableFields: PropTypes.object,
|
|
16
17
|
visibleFields: PropTypes.arrayOf(PropTypes.string)
|
|
17
18
|
};
|
|
@@ -21,6 +22,7 @@ const ActionList = ({
|
|
|
21
22
|
actionCalls = {},
|
|
22
23
|
columnMapping,
|
|
23
24
|
contentData,
|
|
25
|
+
creatableFields = {},
|
|
24
26
|
editableFields = {},
|
|
25
27
|
visibleFields
|
|
26
28
|
}) => {
|
|
@@ -32,13 +34,14 @@ const ActionList = ({
|
|
|
32
34
|
onSubmit={actionCalls.edit}
|
|
33
35
|
subscription={{ contentData: true }}
|
|
34
36
|
>
|
|
35
|
-
{(
|
|
36
|
-
<form onSubmit={
|
|
37
|
+
{() => (
|
|
38
|
+
<form onSubmit={e => { e.preventDefault(); }}>
|
|
37
39
|
<FieldArray
|
|
38
40
|
actionAssigner={actionAssigner}
|
|
39
41
|
actionCalls={actionCalls}
|
|
40
42
|
columnMapping={columnMapping}
|
|
41
43
|
component={ActionListFieldArray}
|
|
44
|
+
creatableFields={creatableFields}
|
|
42
45
|
editableFields={editableFields}
|
|
43
46
|
name="contentData"
|
|
44
47
|
visibleFields={visibleFields}
|
|
@@ -15,6 +15,7 @@ const propTypes = {
|
|
|
15
15
|
actionAssigner: PropTypes.func,
|
|
16
16
|
actionCalls: PropTypes.object,
|
|
17
17
|
columnMapping: PropTypes.object,
|
|
18
|
+
creatableFields: PropTypes.object,
|
|
18
19
|
editableFields: PropTypes.object,
|
|
19
20
|
fields: PropTypes.object,
|
|
20
21
|
visibleFields: PropTypes.arrayOf(PropTypes.string)
|
|
@@ -24,6 +25,7 @@ const ActionListFieldArray = ({
|
|
|
24
25
|
actionAssigner,
|
|
25
26
|
actionCalls,
|
|
26
27
|
columnMapping,
|
|
28
|
+
creatableFields,
|
|
27
29
|
editableFields,
|
|
28
30
|
fields,
|
|
29
31
|
visibleFields
|
|
@@ -54,7 +56,7 @@ const ActionListFieldArray = ({
|
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
const handleCreate = (index) => {
|
|
57
|
-
const rowData = fields.value[index];
|
|
59
|
+
const { actionListActions: _a, ...rowData } = fields.value[index];
|
|
58
60
|
actionCalls.create(rowData);
|
|
59
61
|
};
|
|
60
62
|
|
|
@@ -105,8 +107,13 @@ const ActionListFieldArray = ({
|
|
|
105
107
|
key={`cancel[${data.rowIndex}]`}
|
|
106
108
|
data-type-button="cancel"
|
|
107
109
|
onClick={() => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
if (!data.id && editing === 'NEW_ROW') {
|
|
111
|
+
fields.remove(data.rowIndex);
|
|
112
|
+
toggleEditing('NEW_ROW');
|
|
113
|
+
} else {
|
|
114
|
+
change(fieldName, get(initialValues, fieldName));
|
|
115
|
+
toggleEditing(data.id);
|
|
116
|
+
}
|
|
110
117
|
}}
|
|
111
118
|
>
|
|
112
119
|
<FormattedMessage id="stripes-kint-components.actionList.cancel" />
|
|
@@ -153,7 +160,7 @@ const ActionListFieldArray = ({
|
|
|
153
160
|
|
|
154
161
|
const formatContent = () => {
|
|
155
162
|
return (
|
|
156
|
-
fields.map(fieldName => {
|
|
163
|
+
fields.map((fieldName, fieldIndex) => {
|
|
157
164
|
// Fetch the content from the field Values
|
|
158
165
|
const cd = get(values, fieldName);
|
|
159
166
|
cd.actionListActions = actionAssigner(cd);
|
|
@@ -170,17 +177,22 @@ const ActionListFieldArray = ({
|
|
|
170
177
|
*/
|
|
171
178
|
for (const key of visibleFields) {
|
|
172
179
|
const editFunction = editableFields[key] ?? (() => true);
|
|
180
|
+
const createFunction = creatableFields[key] ?? (() => true);
|
|
173
181
|
/*
|
|
174
|
-
Next check if this is a new row, if so we should
|
|
175
|
-
If it
|
|
176
|
-
|
|
182
|
+
Next check if this is a new row, if so we should run the createableField function with the data.
|
|
183
|
+
If it is not a new row, then we run the editableField function with the data,
|
|
184
|
+
and it should return true/false
|
|
185
|
+
|
|
186
|
+
For both checks
|
|
187
|
+
true => Field, false => display value
|
|
177
188
|
*/
|
|
178
189
|
if (
|
|
179
|
-
!cd.id ||
|
|
190
|
+
(!cd.id && createFunction(cd)) ||
|
|
180
191
|
(editFunction(cd))
|
|
181
192
|
) {
|
|
182
193
|
returnObj[key] =
|
|
183
194
|
<Field
|
|
195
|
+
autofocus={fieldIndex === 0}
|
|
184
196
|
component={TextField}
|
|
185
197
|
name={`${fieldName}.${key}`}
|
|
186
198
|
/>;
|
|
@@ -61,5 +61,6 @@ actionAssigner | function | A function which will be passed the entire row objec
|
|
|
61
61
|
actionCalls | object<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. | {} | ✕ |
|
|
62
62
|
columnMapping | object | An object which will act on the rendered MultiColumnList headers to map the labels for each `visibleField` | | ✕ |
|
|
63
63
|
contentData | array | An array of objects to render along with their actions | | ✓ |
|
|
64
|
+
creatableFields | object<function> | An object with keys from the `visibleFields` array, and values of functions which take the entire row object and return a boolean indicating whether that field is fillable on create or not. | | ✕ |
|
|
64
65
|
editableFields | object<function> | An object with keys from the `visibleFields` array, and values of functions which take the entire row object and return a boolean indicating whether that field is editable or not. | | ✕ |
|
|
65
66
|
visibleFields | array<String> | An array of strings corresponding to those fields to be displayed in the rendered MultiColumnList | | ✓ |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default
|
|
1
|
+
export { default } from './ActionList';
|
|
@@ -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;
|