@dhis2-ui/organisation-unit-tree 10.16.3 → 10.16.4
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/build/cjs/__e2e__/children_as_child_nodes.js +8 -11
- package/build/cjs/__e2e__/common.js +19 -26
- package/build/cjs/__e2e__/controlled_expanded.js +7 -10
- package/build/cjs/__e2e__/displaying_loading_error.js +1 -4
- package/build/cjs/__e2e__/expanded.js +25 -34
- package/build/cjs/__e2e__/force_reload.js +15 -22
- package/build/cjs/__e2e__/get-organisation-unit-data.js +25 -29
- package/build/cjs/__e2e__/highlight.js +7 -10
- package/build/cjs/__e2e__/loading_state.js +7 -13
- package/build/cjs/__e2e__/multi_selection.js +8 -11
- package/build/cjs/__e2e__/no_selection.js +15 -21
- package/build/cjs/__e2e__/path_based_filtering.js +16 -22
- package/build/cjs/__e2e__/single_selection.js +10 -16
- package/build/cjs/__e2e__/sub_unit_as_root.js +5 -7
- package/build/cjs/__e2e__/tree_api.js +15 -21
- package/build/cjs/__stories__/custom-expanded-imperative-open.js +7 -10
- package/build/cjs/__stories__/custom-node-label.js +4 -5
- package/build/cjs/__stories__/development-stories.js +6 -8
- package/build/cjs/__stories__/force-reload-all.js +1 -2
- package/build/cjs/__stories__/loading-error-grandchild.js +1 -4
- package/build/cjs/__stories__/loading.js +1 -4
- package/build/cjs/__stories__/multiple-roots.js +9 -12
- package/build/cjs/__stories__/root-error.js +1 -4
- package/build/cjs/__stories__/root-loading.js +1 -4
- package/build/cjs/__stories__/shared.js +46 -79
- package/build/cjs/features/controlled_expanded/index.js +3 -6
- package/build/cjs/locales/index.js +49 -27
- package/build/cjs/organisation-unit-node/error-message.js +10 -13
- package/build/cjs/organisation-unit-node/label/disabled-selection-label.js +9 -12
- package/build/cjs/organisation-unit-node/label/icon-empty.js +19 -22
- package/build/cjs/organisation-unit-node/label/icon-folder-closed.js +25 -28
- package/build/cjs/organisation-unit-node/label/icon-folder-open.js +34 -37
- package/build/cjs/organisation-unit-node/label/icon-single.js +28 -31
- package/build/cjs/organisation-unit-node/label/icon.js +6 -7
- package/build/cjs/organisation-unit-node/label/iconized-checkbox.js +12 -13
- package/build/cjs/organisation-unit-node/label/label-container.js +13 -16
- package/build/cjs/organisation-unit-node/label/label.js +27 -30
- package/build/cjs/organisation-unit-node/label/single-selection-label.js +18 -21
- package/build/cjs/organisation-unit-node/organisation-unit-node-children.js +27 -29
- package/build/cjs/organisation-unit-node/organisation-unit-node.js +22 -23
- package/build/cjs/organisation-unit-node/use-open-state.js +8 -9
- package/build/cjs/organisation-unit-node/use-org-children.js +14 -21
- package/build/cjs/organisation-unit-node/use-org-children.test.js +40 -59
- package/build/cjs/organisation-unit-node/use-org-data/use-org-data.js +13 -20
- package/build/cjs/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
- package/build/cjs/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
- package/build/cjs/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
- package/build/cjs/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.js +24 -26
- package/build/cjs/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
- package/build/cjs/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
- package/build/cjs/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
- package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
- package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
- package/build/es/__e2e__/children_as_child_nodes.js +8 -11
- package/build/es/__e2e__/common.js +18 -24
- package/build/es/__e2e__/controlled_expanded.js +6 -8
- package/build/es/__e2e__/displaying_loading_error.js +1 -4
- package/build/es/__e2e__/expanded.js +25 -34
- package/build/es/__e2e__/force_reload.js +14 -20
- package/build/es/__e2e__/get-organisation-unit-data.js +25 -29
- package/build/es/__e2e__/highlight.js +7 -10
- package/build/es/__e2e__/loading_state.js +7 -13
- package/build/es/__e2e__/multi_selection.js +8 -11
- package/build/es/__e2e__/no_selection.js +15 -21
- package/build/es/__e2e__/path_based_filtering.js +16 -22
- package/build/es/__e2e__/single_selection.js +10 -16
- package/build/es/__e2e__/sub_unit_as_root.js +4 -5
- package/build/es/__e2e__/tree_api.js +15 -21
- package/build/es/__stories__/custom-expanded-imperative-open.js +6 -8
- package/build/es/__stories__/custom-node-label.js +4 -5
- package/build/es/__stories__/development-stories.js +5 -6
- package/build/es/__stories__/loading-error-grandchild.js +1 -4
- package/build/es/__stories__/loading.js +1 -4
- package/build/es/__stories__/multiple-roots.js +9 -12
- package/build/es/__stories__/root-error.js +1 -4
- package/build/es/__stories__/root-loading.js +1 -4
- package/build/es/__stories__/shared.js +45 -77
- package/build/es/features/controlled_expanded/index.js +3 -6
- package/build/es/locales/index.js +40 -18
- package/build/es/organisation-unit-node/error-message.js +10 -13
- package/build/es/organisation-unit-node/label/disabled-selection-label.js +9 -12
- package/build/es/organisation-unit-node/label/icon-empty.js +19 -22
- package/build/es/organisation-unit-node/label/icon-folder-closed.js +25 -28
- package/build/es/organisation-unit-node/label/icon-folder-open.js +34 -37
- package/build/es/organisation-unit-node/label/icon-single.js +28 -31
- package/build/es/organisation-unit-node/label/icon.js +6 -7
- package/build/es/organisation-unit-node/label/iconized-checkbox.js +12 -13
- package/build/es/organisation-unit-node/label/label-container.js +13 -16
- package/build/es/organisation-unit-node/label/label.js +27 -30
- package/build/es/organisation-unit-node/label/single-selection-label.js +18 -21
- package/build/es/organisation-unit-node/organisation-unit-node-children.js +27 -29
- package/build/es/organisation-unit-node/organisation-unit-node.js +22 -23
- package/build/es/organisation-unit-node/use-open-state.js +8 -9
- package/build/es/organisation-unit-node/use-org-children.js +14 -21
- package/build/es/organisation-unit-node/use-org-children.test.js +40 -59
- package/build/es/organisation-unit-node/use-org-data/use-org-data.js +13 -20
- package/build/es/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
- package/build/es/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
- package/build/es/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
- package/build/es/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
- package/build/es/organisation-unit-tree/organisation-unit-tree.js +23 -24
- package/build/es/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
- package/build/es/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
- package/build/es/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
- package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
- package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
- package/package.json +6 -6
- package/src/locales/index.js +57 -18
- package/src/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +14 -14
|
@@ -7,14 +7,11 @@ export default {
|
|
|
7
7
|
};
|
|
8
8
|
export const ClosedWithChildren = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
9
9
|
data: dataProviderData
|
|
10
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
selected: selected
|
|
19
|
-
});
|
|
20
|
-
}));
|
|
10
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
11
|
+
selected,
|
|
12
|
+
onChange
|
|
13
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
14
|
+
roots: "A0000000000",
|
|
15
|
+
onChange: onChange,
|
|
16
|
+
selected: selected
|
|
17
|
+
})));
|
|
@@ -7,11 +7,10 @@ export { getOrganisationUnitData } from './get-organisation-unit-data.js';
|
|
|
7
7
|
export { namespace } from './namespace.js';
|
|
8
8
|
export const delayResponse = (delay, response) => () => new Promise(resolve => setTimeout(() => resolve(response), delay));
|
|
9
9
|
export const dataProviderData = {
|
|
10
|
-
organisationUnits: (_,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref;
|
|
10
|
+
organisationUnits: (_, {
|
|
11
|
+
id,
|
|
12
|
+
params = {}
|
|
13
|
+
}) => {
|
|
15
14
|
console.log('id, params', id, params);
|
|
16
15
|
const data = getOrganisationUnitData(id, params);
|
|
17
16
|
if (!data) {
|
|
@@ -20,18 +19,16 @@ export const dataProviderData = {
|
|
|
20
19
|
return Promise.resolve(data);
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
|
-
export const StatefulMultiSelectionWrapper =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = _ref2;
|
|
22
|
+
export const StatefulMultiSelectionWrapper = ({
|
|
23
|
+
children,
|
|
24
|
+
onSelectionChange = () => null
|
|
25
|
+
}) => {
|
|
28
26
|
const [selected, setSelected] = useState([]);
|
|
29
27
|
return children({
|
|
30
28
|
selected,
|
|
31
|
-
onChange:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} = _ref3;
|
|
29
|
+
onChange: ({
|
|
30
|
+
selected: newSelected
|
|
31
|
+
}) => {
|
|
35
32
|
setSelected(newSelected);
|
|
36
33
|
onSelectionChange(newSelected);
|
|
37
34
|
}
|
|
@@ -44,16 +41,13 @@ StatefulMultiSelectionWrapper.propTypes = {
|
|
|
44
41
|
export const createDecoratorStatefulMultiSelection = args => {
|
|
45
42
|
return Story => /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, {
|
|
46
43
|
onSelectionChange: args === null || args === void 0 ? void 0 : args.onSelectionChange
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onChange: onChange
|
|
55
|
-
});
|
|
56
|
-
});
|
|
44
|
+
}, ({
|
|
45
|
+
selected,
|
|
46
|
+
onChange
|
|
47
|
+
}) => /*#__PURE__*/React.createElement(Story, {
|
|
48
|
+
selected: selected,
|
|
49
|
+
onChange: onChange
|
|
50
|
+
}));
|
|
57
51
|
};
|
|
58
52
|
export const createDecoratorCustomDataProvider = args => {
|
|
59
53
|
const data = (args === null || args === void 0 ? void 0 : args.data) || dataProviderData;
|
|
@@ -7,18 +7,16 @@ window.orgUnitPathToExpand = '/A0000000000/A0000000001';
|
|
|
7
7
|
export const Controlled = () => {
|
|
8
8
|
const initiallyExpanded = getAllExpandedOrgUnitPaths(window.initiallyExpandedPaths);
|
|
9
9
|
const [expanded, setExpanded] = useState(initiallyExpanded);
|
|
10
|
-
const handleExpand =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = _ref;
|
|
10
|
+
const handleExpand = ({
|
|
11
|
+
path
|
|
12
|
+
}) => {
|
|
14
13
|
if (!expanded.includes(path)) {
|
|
15
14
|
setExpanded([...expanded, path]);
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
|
-
const handleCollapse =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = _ref2;
|
|
17
|
+
const handleCollapse = ({
|
|
18
|
+
path
|
|
19
|
+
}) => {
|
|
22
20
|
const pathIndex = expanded.indexOf(path);
|
|
23
21
|
if (pathIndex !== -1) {
|
|
24
22
|
const updatedExpanded = pathIndex === 0 ? expanded.slice(1) : [...expanded.slice(0, pathIndex), ...expanded.slice(pathIndex + 1)];
|
|
@@ -3,10 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { OrganisationUnitTree } from '../index.js';
|
|
4
4
|
import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
|
|
5
5
|
const dataProviderDataWithError = {
|
|
6
|
-
organisationUnits:
|
|
7
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
-
args[_key] = arguments[_key];
|
|
9
|
-
}
|
|
6
|
+
organisationUnits: (...args) => {
|
|
10
7
|
const [, {
|
|
11
8
|
id
|
|
12
9
|
}] = args;
|
|
@@ -2,40 +2,31 @@ import React from 'react';
|
|
|
2
2
|
import { OrganisationUnitTree } from '../index.js';
|
|
3
3
|
import { createDecoratorCustomDataProvider, createDecoratorStatefulMultiSelection } from './common.js';
|
|
4
4
|
const decorators = [createDecoratorStatefulMultiSelection(), createDecoratorCustomDataProvider()];
|
|
5
|
-
export const NoInitiallyExpandedPaths = (_,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onChange: onChange
|
|
14
|
-
});
|
|
15
|
-
};
|
|
5
|
+
export const NoInitiallyExpandedPaths = (_, {
|
|
6
|
+
onChange,
|
|
7
|
+
selected
|
|
8
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
9
|
+
roots: "A0000000000",
|
|
10
|
+
selected: selected,
|
|
11
|
+
onChange: onChange
|
|
12
|
+
});
|
|
16
13
|
NoInitiallyExpandedPaths.decorators = decorators;
|
|
17
|
-
export const InitiallyExpandedPaths = (_,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
initiallyExpanded: ['/A0000000000']
|
|
27
|
-
});
|
|
28
|
-
};
|
|
14
|
+
export const InitiallyExpandedPaths = (_, {
|
|
15
|
+
onChange,
|
|
16
|
+
selected
|
|
17
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
18
|
+
roots: "A0000000000",
|
|
19
|
+
selected: selected,
|
|
20
|
+
onChange: onChange,
|
|
21
|
+
initiallyExpanded: ['/A0000000000']
|
|
22
|
+
});
|
|
29
23
|
InitiallyExpandedPaths.decorators = decorators;
|
|
30
|
-
export const WithRootMainAndRootSubOrgUnit = (_,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
onChange: onChange
|
|
39
|
-
});
|
|
40
|
-
};
|
|
24
|
+
export const WithRootMainAndRootSubOrgUnit = (_, {
|
|
25
|
+
onChange,
|
|
26
|
+
selected
|
|
27
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
28
|
+
roots: ['A0000000000', 'A0000000001'],
|
|
29
|
+
selected: selected,
|
|
30
|
+
onChange: onChange
|
|
31
|
+
});
|
|
41
32
|
WithRootMainAndRootSubOrgUnit.decorators = decorators;
|
|
@@ -3,10 +3,7 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import { OrganisationUnitTree } from '../index.js';
|
|
4
4
|
import { StatefulMultiSelectionWrapper, dataProviderData, delayResponse, namespace } from './common.js';
|
|
5
5
|
const afterReloadData = {
|
|
6
|
-
organisationUnits:
|
|
7
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
-
args[_key] = arguments[_key];
|
|
9
|
-
}
|
|
6
|
+
organisationUnits: (...args) => {
|
|
10
7
|
const [, {
|
|
11
8
|
id
|
|
12
9
|
}] = args;
|
|
@@ -27,23 +24,20 @@ const ForceReloading_ = () => {
|
|
|
27
24
|
disabled: forceReload,
|
|
28
25
|
"data-test": "reload-all",
|
|
29
26
|
onClick: () => setForceReload(true)
|
|
30
|
-
}, "Force reload tree"), /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (data.A0000000000) {
|
|
42
|
-
setForceReload(false);
|
|
43
|
-
}
|
|
27
|
+
}, "Force reload tree"), /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
28
|
+
selected,
|
|
29
|
+
onChange
|
|
30
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
31
|
+
roots: "A0000000000",
|
|
32
|
+
onChange: onChange,
|
|
33
|
+
selected: selected,
|
|
34
|
+
forceReload: forceReload,
|
|
35
|
+
onChildrenLoaded: data => {
|
|
36
|
+
if (data.A0000000000) {
|
|
37
|
+
setForceReload(false);
|
|
44
38
|
}
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
39
|
+
}
|
|
40
|
+
})));
|
|
47
41
|
};
|
|
48
42
|
export default {
|
|
49
43
|
title: namespace
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
const createResponse =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const createResponse = ({
|
|
2
|
+
fields,
|
|
3
|
+
id,
|
|
4
|
+
path,
|
|
5
|
+
displayName,
|
|
6
|
+
children
|
|
7
|
+
}) => ({
|
|
8
|
+
...(fields.includes('id') ? {
|
|
9
|
+
id
|
|
10
|
+
} : {}),
|
|
11
|
+
...(fields.includes('path') ? {
|
|
12
|
+
path
|
|
13
|
+
} : {}),
|
|
14
|
+
...(fields.includes('displayName') ? {
|
|
15
|
+
displayName
|
|
16
|
+
} : {}),
|
|
17
|
+
...(fields.includes('children::size') ? {
|
|
18
|
+
children: children.length
|
|
19
|
+
} : {}),
|
|
20
|
+
...(fields.includes('children[id,path,displayName]') ? {
|
|
7
21
|
children
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...(fields.includes('path') ? {
|
|
14
|
-
path
|
|
15
|
-
} : {}),
|
|
16
|
-
...(fields.includes('displayName') ? {
|
|
17
|
-
displayName
|
|
18
|
-
} : {}),
|
|
19
|
-
...(fields.includes('children::size') ? {
|
|
20
|
-
children: children.length
|
|
21
|
-
} : {}),
|
|
22
|
-
...(fields.includes('children[id,path,displayName]') ? {
|
|
23
|
-
children
|
|
24
|
-
} : {})
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export const getOrganisationUnitData = (id, _ref2) => {
|
|
28
|
-
let {
|
|
29
|
-
fields
|
|
30
|
-
} = _ref2;
|
|
22
|
+
} : {})
|
|
23
|
+
});
|
|
24
|
+
export const getOrganisationUnitData = (id, {
|
|
25
|
+
fields
|
|
26
|
+
}) => {
|
|
31
27
|
let data;
|
|
32
28
|
if (id === 'A0000000000') {
|
|
33
29
|
data = createResponse({
|
|
@@ -7,13 +7,10 @@ export default {
|
|
|
7
7
|
};
|
|
8
8
|
export const RootHighlighted = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
9
9
|
data: dataProviderData
|
|
10
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
highlighted: ['/A0000000000']
|
|
18
|
-
});
|
|
19
|
-
}));
|
|
10
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
11
|
+
onChange
|
|
12
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
13
|
+
roots: "A0000000000",
|
|
14
|
+
onChange: onChange,
|
|
15
|
+
highlighted: ['/A0000000000']
|
|
16
|
+
})));
|
|
@@ -3,10 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { OrganisationUnitTree } from '../index.js';
|
|
4
4
|
import { StatefulMultiSelectionWrapper, dataProviderData, delayResponse } from './common.js';
|
|
5
5
|
const data = {
|
|
6
|
-
organisationUnits:
|
|
7
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
-
args[_key] = arguments[_key];
|
|
9
|
-
}
|
|
6
|
+
organisationUnits: (...args) => {
|
|
10
7
|
const [, {
|
|
11
8
|
id
|
|
12
9
|
}] = args;
|
|
@@ -21,12 +18,9 @@ const data = {
|
|
|
21
18
|
};
|
|
22
19
|
export const A0000000001Loading = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
23
20
|
data: data
|
|
24
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onChange: onChange
|
|
31
|
-
});
|
|
32
|
-
}));
|
|
21
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
22
|
+
onChange
|
|
23
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
24
|
+
roots: "A0000000000",
|
|
25
|
+
onChange: onChange
|
|
26
|
+
})));
|
|
@@ -7,14 +7,11 @@ export const MultipleSelection = () => /*#__PURE__*/React.createElement(CustomDa
|
|
|
7
7
|
data: dataProviderData
|
|
8
8
|
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, {
|
|
9
9
|
onSelectionChange: newSelection => window.selection = newSelection
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
selected: selected
|
|
19
|
-
});
|
|
20
|
-
}));
|
|
10
|
+
}, ({
|
|
11
|
+
selected,
|
|
12
|
+
onChange
|
|
13
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
14
|
+
roots: "A0000000000",
|
|
15
|
+
onChange: onChange,
|
|
16
|
+
selected: selected
|
|
17
|
+
})));
|
|
@@ -4,26 +4,20 @@ import { OrganisationUnitTree } from '../index.js';
|
|
|
4
4
|
import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
|
|
5
5
|
export const NoSelectionClosed = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
6
6
|
data: dataProviderData
|
|
7
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
onChange: onChange
|
|
15
|
-
});
|
|
16
|
-
}));
|
|
7
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
8
|
+
onChange
|
|
9
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
10
|
+
disableSelection: true,
|
|
11
|
+
roots: "A0000000000",
|
|
12
|
+
onChange: onChange
|
|
13
|
+
})));
|
|
17
14
|
export const NoSelectionRootOpened = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
18
15
|
data: dataProviderData
|
|
19
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
initiallyExpanded: ['/A0000000000']
|
|
28
|
-
});
|
|
29
|
-
}));
|
|
16
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
17
|
+
onChange
|
|
18
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
19
|
+
disableSelection: true,
|
|
20
|
+
roots: "A0000000000",
|
|
21
|
+
onChange: onChange,
|
|
22
|
+
initiallyExpanded: ['/A0000000000']
|
|
23
|
+
})));
|
|
@@ -8,27 +8,21 @@ for (let i = 0; i < 7; ++i) {
|
|
|
8
8
|
}
|
|
9
9
|
export const FilteredBy3LevelPath = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
10
10
|
data: dataProviderData
|
|
11
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
filter: ['/A0000000000/A0000000001/A0000000003']
|
|
20
|
-
});
|
|
21
|
-
}));
|
|
11
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
12
|
+
onChange
|
|
13
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
14
|
+
roots: "A0000000000",
|
|
15
|
+
onChange: onChange,
|
|
16
|
+
initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001', '/A0000000000/A0000000002'],
|
|
17
|
+
filter: ['/A0000000000/A0000000001/A0000000003']
|
|
18
|
+
})));
|
|
22
19
|
export const FilteredBy3LevelPathAnd2LevelPath = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
23
20
|
data: dataProviderData
|
|
24
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
filter: ['/A0000000000/A0000000001/A0000000003', '/A0000000000/A0000000002']
|
|
33
|
-
});
|
|
34
|
-
}));
|
|
21
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
22
|
+
onChange
|
|
23
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
24
|
+
roots: "A0000000000",
|
|
25
|
+
onChange: onChange,
|
|
26
|
+
initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001', '/A0000000000/A0000000002'],
|
|
27
|
+
filter: ['/A0000000000/A0000000001/A0000000003', '/A0000000000/A0000000002']
|
|
28
|
+
})));
|
|
@@ -3,10 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { OrganisationUnitTree } from '../index.js';
|
|
4
4
|
import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
|
|
5
5
|
const data = {
|
|
6
|
-
organisationUnits:
|
|
7
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
-
args[_key] = arguments[_key];
|
|
9
|
-
}
|
|
6
|
+
organisationUnits: (...args) => {
|
|
10
7
|
const [, {
|
|
11
8
|
id
|
|
12
9
|
}] = args;
|
|
@@ -28,15 +25,12 @@ const data = {
|
|
|
28
25
|
};
|
|
29
26
|
export const SingleSelection = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
30
27
|
data: data
|
|
31
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
selected: selected
|
|
41
|
-
});
|
|
42
|
-
}));
|
|
28
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
29
|
+
selected,
|
|
30
|
+
onChange
|
|
31
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
32
|
+
singleSelection: true,
|
|
33
|
+
roots: ['A0000000000', 'A0000000001'],
|
|
34
|
+
onChange: onChange,
|
|
35
|
+
selected: selected
|
|
36
|
+
})));
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { OrganisationUnitTree } from '../index.js';
|
|
3
3
|
import { createDecoratorCustomDataProvider, createDecoratorStatefulMultiSelection } from './common.js';
|
|
4
|
-
export const MultipleRootSubAndOneMainOrgUnit = (_,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} = _ref;
|
|
4
|
+
export const MultipleRootSubAndOneMainOrgUnit = (_, {
|
|
5
|
+
selected,
|
|
6
|
+
onChange
|
|
7
|
+
}) => {
|
|
9
8
|
const [filter, setFilter] = useState('');
|
|
10
9
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
11
10
|
type: "input",
|
|
@@ -3,10 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { OrganisationUnitTree } from '../index.js';
|
|
4
4
|
import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
|
|
5
5
|
const customizedDataProviderData = {
|
|
6
|
-
organisationUnits:
|
|
7
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
-
args[_key] = arguments[_key];
|
|
9
|
-
}
|
|
6
|
+
organisationUnits: (...args) => {
|
|
10
7
|
const [, {
|
|
11
8
|
id,
|
|
12
9
|
params
|
|
@@ -39,20 +36,17 @@ window.onExpand = window.Cypress && window.Cypress.cy.stub();
|
|
|
39
36
|
window.onChildrenLoaded = window.Cypress && window.Cypress.cy.stub();
|
|
40
37
|
export const Events = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
41
38
|
data: customizedDataProviderData
|
|
42
|
-
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
onChange
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
onChildrenLoaded: window.onChildrenLoaded
|
|
57
|
-
});
|
|
58
|
-
}));
|
|
39
|
+
}, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
|
|
40
|
+
selected,
|
|
41
|
+
onChange
|
|
42
|
+
}) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
|
|
43
|
+
roots: "A0000000000",
|
|
44
|
+
selected: selected,
|
|
45
|
+
onChange: (...args) => {
|
|
46
|
+
onChange(...args);
|
|
47
|
+
window.onChange(...args);
|
|
48
|
+
},
|
|
49
|
+
onExpand: window.onExpand,
|
|
50
|
+
onCollapse: window.onCollapse,
|
|
51
|
+
onChildrenLoaded: window.onChildrenLoaded
|
|
52
|
+
})));
|
|
@@ -6,18 +6,16 @@ export const CustomExpandedImperativeOpen = () => {
|
|
|
6
6
|
const orgUnit2Path = '/A0000000000/A0000000001';
|
|
7
7
|
const initiallyExpanded = getAllExpandedOrgUnitPaths([]);
|
|
8
8
|
const [expanded, setExpanded] = useState(initiallyExpanded);
|
|
9
|
-
const handleExpand =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = _ref;
|
|
9
|
+
const handleExpand = ({
|
|
10
|
+
path
|
|
11
|
+
}) => {
|
|
13
12
|
if (!expanded.includes(path)) {
|
|
14
13
|
setExpanded([...expanded, path]);
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
|
-
const handleCollapse =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = _ref2;
|
|
16
|
+
const handleCollapse = ({
|
|
17
|
+
path
|
|
18
|
+
}) => {
|
|
21
19
|
const pathIndex = expanded.indexOf(path);
|
|
22
20
|
if (pathIndex !== -1) {
|
|
23
21
|
const updatedExpanded = pathIndex === 0 ? expanded.slice(1) : [...expanded.slice(0, pathIndex), ...expanded.slice(pathIndex + 1)];
|
|
@@ -5,11 +5,10 @@ export const CustomNodeLabel = () => /*#__PURE__*/React.createElement(Organisati
|
|
|
5
5
|
name: "Root org unit",
|
|
6
6
|
roots: "A0000000000",
|
|
7
7
|
initiallyExpanded: ['/A0000000000/A0000000001'],
|
|
8
|
-
renderNodeLabel:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = _ref;
|
|
8
|
+
renderNodeLabel: ({
|
|
9
|
+
label,
|
|
10
|
+
node
|
|
11
|
+
}) => {
|
|
13
12
|
if (node.path !== '/A0000000000/A0000000001') {
|
|
14
13
|
return label;
|
|
15
14
|
}
|
|
@@ -2,12 +2,11 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import { DataProvider } from '@dhis2/app-runtime';
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
4
|
import { OrganisationUnitTree } from '../index.js';
|
|
5
|
-
const DX_onChange = (selected, setSelected, singleSelection) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
5
|
+
const DX_onChange = (selected, setSelected, singleSelection) => ({
|
|
6
|
+
id,
|
|
7
|
+
path,
|
|
8
|
+
checked
|
|
9
|
+
}) => {
|
|
11
10
|
console.log('onChange', {
|
|
12
11
|
path,
|
|
13
12
|
id,
|
|
@@ -5,10 +5,7 @@ import { customData, onChange, onExpand, onCollapse, onChildrenLoaded } from './
|
|
|
5
5
|
export const LoadingErrorGrandchild = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
6
6
|
data: {
|
|
7
7
|
...customData,
|
|
8
|
-
organisationUnits:
|
|
9
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
-
args[_key] = arguments[_key];
|
|
11
|
-
}
|
|
8
|
+
organisationUnits: (...args) => {
|
|
12
9
|
const [, {
|
|
13
10
|
id
|
|
14
11
|
}] = args;
|