@dhis2-ui/organisation-unit-tree 10.16.3 → 10.16.5
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 +41 -35
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.test.js +78 -7
- 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 +34 -27
- package/build/es/organisation-unit-tree/organisation-unit-tree.test.js +71 -0
- 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/organisation-unit-tree.js +14 -3
- package/src/organisation-unit-tree/organisation-unit-tree.test.js +64 -0
- package/src/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +14 -14
|
@@ -17,8 +17,7 @@ exports.patchMissingDisplayName = void 0;
|
|
|
17
17
|
*/
|
|
18
18
|
const patchMissingDisplayName = nodes => {
|
|
19
19
|
const nodeEntries = Object.entries(nodes);
|
|
20
|
-
const nodesWithDisplayName = nodeEntries.map(
|
|
21
|
-
let [id, node] = _ref;
|
|
20
|
+
const nodesWithDisplayName = nodeEntries.map(([id, node]) => {
|
|
22
21
|
const displayName = node.displayName || '';
|
|
23
22
|
return [id, {
|
|
24
23
|
...node,
|
|
@@ -12,15 +12,12 @@ const createRootQuery = (ids, displayProperty) => ids.reduce((query, id) => ({
|
|
|
12
12
|
[id]: {
|
|
13
13
|
id,
|
|
14
14
|
resource: `organisationUnits`,
|
|
15
|
-
params:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fields: [displayProperty === 'displayName' ? 'displayName' : `${displayProperty}~rename(displayName)`, 'path', 'id']
|
|
22
|
-
};
|
|
23
|
-
}
|
|
15
|
+
params: ({
|
|
16
|
+
isUserDataViewFallback
|
|
17
|
+
}) => ({
|
|
18
|
+
isUserDataViewFallback,
|
|
19
|
+
fields: [displayProperty === 'displayName' ? 'displayName' : `${displayProperty}~rename(displayName)`, 'path', 'id']
|
|
20
|
+
})
|
|
24
21
|
}
|
|
25
22
|
}), {});
|
|
26
23
|
|
|
@@ -33,11 +30,10 @@ const createRootQuery = (ids, displayProperty) => ids.reduce((query, id) => ({
|
|
|
33
30
|
* @returns {Object}
|
|
34
31
|
*/
|
|
35
32
|
exports.createRootQuery = createRootQuery;
|
|
36
|
-
const useRootOrgData =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
+
const useRootOrgData = (ids, {
|
|
34
|
+
isUserDataViewFallback,
|
|
35
|
+
displayProperty = 'displayName'
|
|
36
|
+
} = {}) => {
|
|
41
37
|
const query = (0, _react.useMemo)(() => createRootQuery(ids, displayProperty), [ids, displayProperty]);
|
|
42
38
|
const variables = {
|
|
43
39
|
isUserDataViewFallback
|
|
@@ -8,10 +8,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
8
8
|
describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
9
9
|
// @TODO: Figure out why this is necessary at all...
|
|
10
10
|
const origError = console.error;
|
|
11
|
-
jest.spyOn(console, 'error').mockImplementation(
|
|
12
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
-
args[_key] = arguments[_key];
|
|
14
|
-
}
|
|
11
|
+
jest.spyOn(console, 'error').mockImplementation((...args) => {
|
|
15
12
|
const [err] = args;
|
|
16
13
|
if (!err.toString().match(/^Warning: An update to/)) {
|
|
17
14
|
origError(...args);
|
|
@@ -21,10 +18,7 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
21
18
|
// @TODO: This is kind of necessary; no idea if we can get rid of this
|
|
22
19
|
const origWarn = console.warn;
|
|
23
20
|
const dynamicQueryWarningMsg = "The query should be static, don't create it within the render loop!";
|
|
24
|
-
jest.spyOn(console, 'warn').mockImplementation(
|
|
25
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
26
|
-
args[_key2] = arguments[_key2];
|
|
27
|
-
}
|
|
21
|
+
jest.spyOn(console, 'warn').mockImplementation((...args) => {
|
|
28
22
|
const [err] = args;
|
|
29
23
|
if (!err.toString().match(dynamicQueryWarningMsg)) {
|
|
30
24
|
origWarn(...args);
|
|
@@ -43,14 +37,11 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
43
37
|
};
|
|
44
38
|
})
|
|
45
39
|
};
|
|
46
|
-
const wrapper =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
data: dataProviderData
|
|
52
|
-
}, children);
|
|
53
|
-
};
|
|
40
|
+
const wrapper = ({
|
|
41
|
+
children
|
|
42
|
+
}) => /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
43
|
+
data: dataProviderData
|
|
44
|
+
}, children);
|
|
54
45
|
it('should respond with `loading: false`, `error: null` and `data: null` initially', () => {
|
|
55
46
|
const {
|
|
56
47
|
result
|
|
@@ -70,32 +61,30 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
70
61
|
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
71
62
|
wrapper
|
|
72
63
|
});
|
|
73
|
-
await (0, _react.waitFor)(() => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
64
|
+
await (0, _react.waitFor)(() => {
|
|
65
|
+
expect(result.current).toEqual(expect.objectContaining({
|
|
66
|
+
loading: false,
|
|
67
|
+
error: null,
|
|
68
|
+
data: {
|
|
69
|
+
A0000000000: {
|
|
70
|
+
id: 'A0000000000',
|
|
71
|
+
path: '/A0000000000',
|
|
72
|
+
displayName: 'Org Unit 1'
|
|
73
|
+
}
|
|
82
74
|
}
|
|
83
|
-
}
|
|
84
|
-
})
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
85
77
|
});
|
|
86
78
|
it('should provide the error', async () => {
|
|
87
|
-
const errorWrapper =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
organisationUnits: async () => {
|
|
94
|
-
throw new Error('Error message');
|
|
95
|
-
}
|
|
79
|
+
const errorWrapper = ({
|
|
80
|
+
children
|
|
81
|
+
}) => /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
82
|
+
data: {
|
|
83
|
+
organisationUnits: async () => {
|
|
84
|
+
throw new Error('Error message');
|
|
96
85
|
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
86
|
+
}
|
|
87
|
+
}, children);
|
|
99
88
|
const {
|
|
100
89
|
result
|
|
101
90
|
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
@@ -145,14 +134,11 @@ describe('OrganisationUnitTree - useRootOrgData', () => {
|
|
|
145
134
|
};
|
|
146
135
|
})
|
|
147
136
|
};
|
|
148
|
-
const wrapperWithoutDisplayName =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
data: dataProviderDataWithoutDisplayName
|
|
154
|
-
}, children);
|
|
155
|
-
};
|
|
137
|
+
const wrapperWithoutDisplayName = ({
|
|
138
|
+
children
|
|
139
|
+
}) => /*#__PURE__*/_react2.default.createElement(_appRuntime.CustomDataProvider, {
|
|
140
|
+
data: dataProviderDataWithoutDisplayName
|
|
141
|
+
}, children);
|
|
156
142
|
const {
|
|
157
143
|
result
|
|
158
144
|
} = (0, _react.renderHook)(() => (0, _useRootOrgData.useRootOrgData)(['A0000000000']), {
|
|
@@ -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
|
+
})));
|