@dhis2-ui/organisation-unit-tree 10.15.1 → 10.16.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/build/cjs/organisation-unit-node/organisation-unit-node-children.js +5 -1
- package/build/cjs/organisation-unit-node/organisation-unit-node.js +3 -0
- package/build/cjs/organisation-unit-node/use-org-children.js +16 -8
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.js +11 -1
- package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-data.js +6 -4
- package/build/es/organisation-unit-node/organisation-unit-node-children.js +5 -1
- package/build/es/organisation-unit-node/organisation-unit-node.js +3 -0
- package/build/es/organisation-unit-node/use-org-children.js +16 -8
- package/build/es/organisation-unit-tree/organisation-unit-tree.js +11 -1
- package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-data.js +6 -4
- package/package.json +6 -6
- package/types/index.d.ts +7 -0
|
@@ -31,6 +31,7 @@ const OrganisationUnitNodeChildren = _ref2 => {
|
|
|
31
31
|
autoExpandLoadingError,
|
|
32
32
|
dataTest,
|
|
33
33
|
disableSelection,
|
|
34
|
+
displayProperty,
|
|
34
35
|
expanded,
|
|
35
36
|
filter,
|
|
36
37
|
highlighted,
|
|
@@ -51,7 +52,8 @@ const OrganisationUnitNodeChildren = _ref2 => {
|
|
|
51
52
|
node,
|
|
52
53
|
isUserDataViewFallback,
|
|
53
54
|
suppressAlphabeticalSorting,
|
|
54
|
-
onComplete: onChildrenLoaded
|
|
55
|
+
onComplete: onChildrenLoaded,
|
|
56
|
+
displayProperty
|
|
55
57
|
});
|
|
56
58
|
const displayChildren = orgChildren.called && !orgChildren.loading && !orgChildren.error;
|
|
57
59
|
const filteredChildren = displayChildren ? getFilteredChildren({
|
|
@@ -66,6 +68,7 @@ const OrganisationUnitNodeChildren = _ref2 => {
|
|
|
66
68
|
dataTest: dataTest,
|
|
67
69
|
disableSelection: disableSelection,
|
|
68
70
|
displayName: child.displayName,
|
|
71
|
+
displayProperty: displayProperty,
|
|
69
72
|
expanded: expanded,
|
|
70
73
|
filter: filter,
|
|
71
74
|
highlighted: highlighted,
|
|
@@ -97,6 +100,7 @@ OrganisationUnitNodeChildren.propTypes = {
|
|
|
97
100
|
onChange: _propTypes.default.func.isRequired,
|
|
98
101
|
autoExpandLoadingError: _propTypes.default.bool,
|
|
99
102
|
disableSelection: _propTypes.default.bool,
|
|
103
|
+
displayProperty: _propTypes.default.oneOf(['displayName', 'displayShortName']),
|
|
100
104
|
expanded: _propTypes.default.arrayOf(_propTypes2.orgUnitPathPropType),
|
|
101
105
|
filter: _propTypes.default.arrayOf(_propTypes2.orgUnitPathPropType),
|
|
102
106
|
highlighted: _propTypes.default.arrayOf(_propTypes2.orgUnitPathPropType),
|
|
@@ -24,6 +24,7 @@ const OrganisationUnitNode = _ref => {
|
|
|
24
24
|
dataTest,
|
|
25
25
|
disableSelection,
|
|
26
26
|
displayName,
|
|
27
|
+
displayProperty,
|
|
27
28
|
expanded,
|
|
28
29
|
highlighted,
|
|
29
30
|
id,
|
|
@@ -132,6 +133,7 @@ const OrganisationUnitNode = _ref => {
|
|
|
132
133
|
autoExpandLoadingError: autoExpandLoadingError,
|
|
133
134
|
dataTest: dataTest,
|
|
134
135
|
disableSelection: disableSelection,
|
|
136
|
+
displayProperty: displayProperty,
|
|
135
137
|
expanded: expanded,
|
|
136
138
|
filter: filter,
|
|
137
139
|
highlighted: highlighted,
|
|
@@ -158,6 +160,7 @@ OrganisationUnitNode.propTypes = {
|
|
|
158
160
|
autoExpandLoadingError: _propTypes.default.bool,
|
|
159
161
|
disableSelection: _propTypes.default.bool,
|
|
160
162
|
displayName: _propTypes.default.string,
|
|
163
|
+
displayProperty: _propTypes.default.oneOf(['displayName', 'displayShortName']),
|
|
161
164
|
expanded: _propTypes.default.arrayOf(_propTypes2.orgUnitPathPropType),
|
|
162
165
|
filter: _propTypes.default.arrayOf(_propTypes2.orgUnitPathPropType),
|
|
163
166
|
highlighted: _propTypes.default.arrayOf(_propTypes2.orgUnitPathPropType),
|
|
@@ -16,8 +16,13 @@ const ORG_DATA_QUERY = {
|
|
|
16
16
|
} = _ref;
|
|
17
17
|
return id;
|
|
18
18
|
},
|
|
19
|
-
params: {
|
|
20
|
-
|
|
19
|
+
params: _ref2 => {
|
|
20
|
+
let {
|
|
21
|
+
displayProperty
|
|
22
|
+
} = _ref2;
|
|
23
|
+
return {
|
|
24
|
+
fields: displayProperty === 'displayName' ? 'children[id,path,displayName]' : `children[id,path,${displayProperty}~rename(displayName)]`
|
|
25
|
+
};
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
};
|
|
@@ -27,14 +32,16 @@ const ORG_DATA_QUERY = {
|
|
|
27
32
|
* @param {Object} options
|
|
28
33
|
* @param {string} options.displayName
|
|
29
34
|
* @param {boolean} [options.withChildren]
|
|
35
|
+
* @param {'displayName'|'displayShortName'} [options.displayProperty]
|
|
30
36
|
* @returns {Object}
|
|
31
37
|
*/
|
|
32
|
-
const useOrgChildren =
|
|
38
|
+
const useOrgChildren = _ref3 => {
|
|
33
39
|
let {
|
|
34
40
|
node,
|
|
35
41
|
suppressAlphabeticalSorting,
|
|
36
|
-
onComplete
|
|
37
|
-
|
|
42
|
+
onComplete,
|
|
43
|
+
displayProperty = 'displayName'
|
|
44
|
+
} = _ref3;
|
|
38
45
|
const onCompleteCalledRef = (0, _react.useRef)(false);
|
|
39
46
|
const {
|
|
40
47
|
called,
|
|
@@ -43,7 +50,8 @@ const useOrgChildren = _ref2 => {
|
|
|
43
50
|
data
|
|
44
51
|
} = (0, _appRuntime.useDataQuery)(ORG_DATA_QUERY, {
|
|
45
52
|
variables: {
|
|
46
|
-
id: node.id
|
|
53
|
+
id: node.id,
|
|
54
|
+
displayProperty
|
|
47
55
|
}
|
|
48
56
|
});
|
|
49
57
|
const orgChildren = (0, _react.useMemo)(() => {
|
|
@@ -59,7 +67,7 @@ const useOrgChildren = _ref2 => {
|
|
|
59
67
|
orgUnit
|
|
60
68
|
} = data;
|
|
61
69
|
return suppressAlphabeticalSorting ? orgUnit.children : (0, _index.sortNodeChildrenAlphabetically)(orgUnit.children);
|
|
62
|
-
}, [data, suppressAlphabeticalSorting]);
|
|
70
|
+
}, [data, node.children, suppressAlphabeticalSorting]);
|
|
63
71
|
(0, _react.useEffect)(() => {
|
|
64
72
|
if (onComplete && orgChildren && !onCompleteCalledRef.current) {
|
|
65
73
|
// For backwards compatibility: Pass entire node incl. children
|
|
@@ -69,7 +77,7 @@ const useOrgChildren = _ref2 => {
|
|
|
69
77
|
});
|
|
70
78
|
onCompleteCalledRef.current = true;
|
|
71
79
|
}
|
|
72
|
-
}, [onComplete, orgChildren, onCompleteCalledRef]);
|
|
80
|
+
}, [node, onComplete, orgChildren, onCompleteCalledRef]);
|
|
73
81
|
return {
|
|
74
82
|
called,
|
|
75
83
|
loading,
|
|
@@ -28,6 +28,7 @@ const OrganisationUnitTree = _ref => {
|
|
|
28
28
|
autoExpandLoadingError,
|
|
29
29
|
dataTest = 'dhis2-uiwidgets-orgunittree',
|
|
30
30
|
disableSelection,
|
|
31
|
+
displayProperty = 'displayName',
|
|
31
32
|
forceReload,
|
|
32
33
|
highlighted = staticArray,
|
|
33
34
|
isUserDataViewFallback,
|
|
@@ -55,7 +56,8 @@ const OrganisationUnitTree = _ref => {
|
|
|
55
56
|
refetch
|
|
56
57
|
} = (0, _index4.useRootOrgData)(rootIds, {
|
|
57
58
|
isUserDataViewFallback,
|
|
58
|
-
suppressAlphabeticalSorting
|
|
59
|
+
suppressAlphabeticalSorting,
|
|
60
|
+
displayProperty
|
|
59
61
|
});
|
|
60
62
|
const {
|
|
61
63
|
expanded,
|
|
@@ -91,6 +93,7 @@ const OrganisationUnitTree = _ref => {
|
|
|
91
93
|
dataTest: dataTest,
|
|
92
94
|
disableSelection: disableSelection,
|
|
93
95
|
displayName: rootNode.displayName,
|
|
96
|
+
displayProperty: displayProperty,
|
|
94
97
|
expanded: expanded,
|
|
95
98
|
highlighted: highlighted,
|
|
96
99
|
id: rootId,
|
|
@@ -120,6 +123,13 @@ OrganisationUnitTree.propTypes = {
|
|
|
120
123
|
dataTest: _propTypes2.default.string,
|
|
121
124
|
/** When set to true, no unit can be selected */
|
|
122
125
|
disableSelection: _propTypes2.default.bool,
|
|
126
|
+
/**
|
|
127
|
+
* Which field to render as the org unit label. Defaults to `'displayName'`.
|
|
128
|
+
* Set to `'displayShortName'` to honour the `keyAnalysisDisplayProperty`
|
|
129
|
+
* system/user setting. The query renames the chosen field back to
|
|
130
|
+
* `displayName` internally, so consumer-facing data shape is unchanged.
|
|
131
|
+
*/
|
|
132
|
+
displayProperty: _propTypes2.default.oneOf(['displayName', 'displayShortName']),
|
|
123
133
|
expanded: (0, _propTypes.requiredIf)(props => !!props.handleExpand || !!props.handleCollapse, _propTypes2.default.arrayOf(_propTypes2.default.string)),
|
|
124
134
|
/**
|
|
125
135
|
* All organisation units with a path that includes the provided paths will be shown.
|
|
@@ -7,7 +7,7 @@ exports.useRootOrgData = exports.createRootQuery = void 0;
|
|
|
7
7
|
var _appRuntime = require("@dhis2/app-runtime");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _patchMissingDisplayName = require("./patch-missing-display-name.js");
|
|
10
|
-
const createRootQuery = ids => ids.reduce((query, id) => ({
|
|
10
|
+
const createRootQuery = (ids, displayProperty) => ids.reduce((query, id) => ({
|
|
11
11
|
...query,
|
|
12
12
|
[id]: {
|
|
13
13
|
id,
|
|
@@ -18,7 +18,7 @@ const createRootQuery = ids => ids.reduce((query, id) => ({
|
|
|
18
18
|
} = _ref;
|
|
19
19
|
return {
|
|
20
20
|
isUserDataViewFallback,
|
|
21
|
-
fields: ['displayName'
|
|
21
|
+
fields: [displayProperty === 'displayName' ? 'displayName' : `${displayProperty}~rename(displayName)`, 'path', 'id']
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -29,14 +29,16 @@ const createRootQuery = ids => ids.reduce((query, id) => ({
|
|
|
29
29
|
* @param {Object} [options]
|
|
30
30
|
* @param {boolean} [options.withChildren]
|
|
31
31
|
* @param {boolean} [options.isUserDataViewFallback]
|
|
32
|
+
* @param {'displayName'|'displayShortName'} [options.displayProperty]
|
|
32
33
|
* @returns {Object}
|
|
33
34
|
*/
|
|
34
35
|
exports.createRootQuery = createRootQuery;
|
|
35
36
|
const useRootOrgData = function (ids) {
|
|
36
37
|
let {
|
|
37
|
-
isUserDataViewFallback
|
|
38
|
+
isUserDataViewFallback,
|
|
39
|
+
displayProperty = 'displayName'
|
|
38
40
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
|
-
const query = (0, _react.useMemo)(() => createRootQuery(ids), [ids]);
|
|
41
|
+
const query = (0, _react.useMemo)(() => createRootQuery(ids, displayProperty), [ids, displayProperty]);
|
|
40
42
|
const variables = {
|
|
41
43
|
isUserDataViewFallback
|
|
42
44
|
};
|
|
@@ -24,6 +24,7 @@ export const OrganisationUnitNodeChildren = _ref2 => {
|
|
|
24
24
|
autoExpandLoadingError,
|
|
25
25
|
dataTest,
|
|
26
26
|
disableSelection,
|
|
27
|
+
displayProperty,
|
|
27
28
|
expanded,
|
|
28
29
|
filter,
|
|
29
30
|
highlighted,
|
|
@@ -44,7 +45,8 @@ export const OrganisationUnitNodeChildren = _ref2 => {
|
|
|
44
45
|
node,
|
|
45
46
|
isUserDataViewFallback,
|
|
46
47
|
suppressAlphabeticalSorting,
|
|
47
|
-
onComplete: onChildrenLoaded
|
|
48
|
+
onComplete: onChildrenLoaded,
|
|
49
|
+
displayProperty
|
|
48
50
|
});
|
|
49
51
|
const displayChildren = orgChildren.called && !orgChildren.loading && !orgChildren.error;
|
|
50
52
|
const filteredChildren = displayChildren ? getFilteredChildren({
|
|
@@ -59,6 +61,7 @@ export const OrganisationUnitNodeChildren = _ref2 => {
|
|
|
59
61
|
dataTest: dataTest,
|
|
60
62
|
disableSelection: disableSelection,
|
|
61
63
|
displayName: child.displayName,
|
|
64
|
+
displayProperty: displayProperty,
|
|
62
65
|
expanded: expanded,
|
|
63
66
|
filter: filter,
|
|
64
67
|
highlighted: highlighted,
|
|
@@ -89,6 +92,7 @@ OrganisationUnitNodeChildren.propTypes = {
|
|
|
89
92
|
onChange: PropTypes.func.isRequired,
|
|
90
93
|
autoExpandLoadingError: PropTypes.bool,
|
|
91
94
|
disableSelection: PropTypes.bool,
|
|
95
|
+
displayProperty: PropTypes.oneOf(['displayName', 'displayShortName']),
|
|
92
96
|
expanded: PropTypes.arrayOf(orgUnitPathPropType),
|
|
93
97
|
filter: PropTypes.arrayOf(orgUnitPathPropType),
|
|
94
98
|
highlighted: PropTypes.arrayOf(orgUnitPathPropType),
|
|
@@ -17,6 +17,7 @@ export const OrganisationUnitNode = _ref => {
|
|
|
17
17
|
dataTest,
|
|
18
18
|
disableSelection,
|
|
19
19
|
displayName,
|
|
20
|
+
displayProperty,
|
|
20
21
|
expanded,
|
|
21
22
|
highlighted,
|
|
22
23
|
id,
|
|
@@ -125,6 +126,7 @@ export const OrganisationUnitNode = _ref => {
|
|
|
125
126
|
autoExpandLoadingError: autoExpandLoadingError,
|
|
126
127
|
dataTest: dataTest,
|
|
127
128
|
disableSelection: disableSelection,
|
|
129
|
+
displayProperty: displayProperty,
|
|
128
130
|
expanded: expanded,
|
|
129
131
|
filter: filter,
|
|
130
132
|
highlighted: highlighted,
|
|
@@ -150,6 +152,7 @@ OrganisationUnitNode.propTypes = {
|
|
|
150
152
|
autoExpandLoadingError: PropTypes.bool,
|
|
151
153
|
disableSelection: PropTypes.bool,
|
|
152
154
|
displayName: PropTypes.string,
|
|
155
|
+
displayProperty: PropTypes.oneOf(['displayName', 'displayShortName']),
|
|
153
156
|
expanded: PropTypes.arrayOf(orgUnitPathPropType),
|
|
154
157
|
filter: PropTypes.arrayOf(orgUnitPathPropType),
|
|
155
158
|
highlighted: PropTypes.arrayOf(orgUnitPathPropType),
|
|
@@ -10,8 +10,13 @@ const ORG_DATA_QUERY = {
|
|
|
10
10
|
} = _ref;
|
|
11
11
|
return id;
|
|
12
12
|
},
|
|
13
|
-
params: {
|
|
14
|
-
|
|
13
|
+
params: _ref2 => {
|
|
14
|
+
let {
|
|
15
|
+
displayProperty
|
|
16
|
+
} = _ref2;
|
|
17
|
+
return {
|
|
18
|
+
fields: displayProperty === 'displayName' ? 'children[id,path,displayName]' : `children[id,path,${displayProperty}~rename(displayName)]`
|
|
19
|
+
};
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
};
|
|
@@ -21,14 +26,16 @@ const ORG_DATA_QUERY = {
|
|
|
21
26
|
* @param {Object} options
|
|
22
27
|
* @param {string} options.displayName
|
|
23
28
|
* @param {boolean} [options.withChildren]
|
|
29
|
+
* @param {'displayName'|'displayShortName'} [options.displayProperty]
|
|
24
30
|
* @returns {Object}
|
|
25
31
|
*/
|
|
26
|
-
export const useOrgChildren =
|
|
32
|
+
export const useOrgChildren = _ref3 => {
|
|
27
33
|
let {
|
|
28
34
|
node,
|
|
29
35
|
suppressAlphabeticalSorting,
|
|
30
|
-
onComplete
|
|
31
|
-
|
|
36
|
+
onComplete,
|
|
37
|
+
displayProperty = 'displayName'
|
|
38
|
+
} = _ref3;
|
|
32
39
|
const onCompleteCalledRef = useRef(false);
|
|
33
40
|
const {
|
|
34
41
|
called,
|
|
@@ -37,7 +44,8 @@ export const useOrgChildren = _ref2 => {
|
|
|
37
44
|
data
|
|
38
45
|
} = useDataQuery(ORG_DATA_QUERY, {
|
|
39
46
|
variables: {
|
|
40
|
-
id: node.id
|
|
47
|
+
id: node.id,
|
|
48
|
+
displayProperty
|
|
41
49
|
}
|
|
42
50
|
});
|
|
43
51
|
const orgChildren = useMemo(() => {
|
|
@@ -53,7 +61,7 @@ export const useOrgChildren = _ref2 => {
|
|
|
53
61
|
orgUnit
|
|
54
62
|
} = data;
|
|
55
63
|
return suppressAlphabeticalSorting ? orgUnit.children : sortNodeChildrenAlphabetically(orgUnit.children);
|
|
56
|
-
}, [data, suppressAlphabeticalSorting]);
|
|
64
|
+
}, [data, node.children, suppressAlphabeticalSorting]);
|
|
57
65
|
useEffect(() => {
|
|
58
66
|
if (onComplete && orgChildren && !onCompleteCalledRef.current) {
|
|
59
67
|
// For backwards compatibility: Pass entire node incl. children
|
|
@@ -63,7 +71,7 @@ export const useOrgChildren = _ref2 => {
|
|
|
63
71
|
});
|
|
64
72
|
onCompleteCalledRef.current = true;
|
|
65
73
|
}
|
|
66
|
-
}, [onComplete, orgChildren, onCompleteCalledRef]);
|
|
74
|
+
}, [node, onComplete, orgChildren, onCompleteCalledRef]);
|
|
67
75
|
return {
|
|
68
76
|
called,
|
|
69
77
|
loading,
|
|
@@ -20,6 +20,7 @@ const OrganisationUnitTree = _ref => {
|
|
|
20
20
|
autoExpandLoadingError,
|
|
21
21
|
dataTest = 'dhis2-uiwidgets-orgunittree',
|
|
22
22
|
disableSelection,
|
|
23
|
+
displayProperty = 'displayName',
|
|
23
24
|
forceReload,
|
|
24
25
|
highlighted = staticArray,
|
|
25
26
|
isUserDataViewFallback,
|
|
@@ -47,7 +48,8 @@ const OrganisationUnitTree = _ref => {
|
|
|
47
48
|
refetch
|
|
48
49
|
} = useRootOrgData(rootIds, {
|
|
49
50
|
isUserDataViewFallback,
|
|
50
|
-
suppressAlphabeticalSorting
|
|
51
|
+
suppressAlphabeticalSorting,
|
|
52
|
+
displayProperty
|
|
51
53
|
});
|
|
52
54
|
const {
|
|
53
55
|
expanded,
|
|
@@ -83,6 +85,7 @@ const OrganisationUnitTree = _ref => {
|
|
|
83
85
|
dataTest: dataTest,
|
|
84
86
|
disableSelection: disableSelection,
|
|
85
87
|
displayName: rootNode.displayName,
|
|
88
|
+
displayProperty: displayProperty,
|
|
86
89
|
expanded: expanded,
|
|
87
90
|
highlighted: highlighted,
|
|
88
91
|
id: rootId,
|
|
@@ -111,6 +114,13 @@ OrganisationUnitTree.propTypes = {
|
|
|
111
114
|
dataTest: PropTypes.string,
|
|
112
115
|
/** When set to true, no unit can be selected */
|
|
113
116
|
disableSelection: PropTypes.bool,
|
|
117
|
+
/**
|
|
118
|
+
* Which field to render as the org unit label. Defaults to `'displayName'`.
|
|
119
|
+
* Set to `'displayShortName'` to honour the `keyAnalysisDisplayProperty`
|
|
120
|
+
* system/user setting. The query renames the chosen field back to
|
|
121
|
+
* `displayName` internally, so consumer-facing data shape is unchanged.
|
|
122
|
+
*/
|
|
123
|
+
displayProperty: PropTypes.oneOf(['displayName', 'displayShortName']),
|
|
114
124
|
expanded: requiredIf(props => !!props.handleExpand || !!props.handleCollapse, PropTypes.arrayOf(PropTypes.string)),
|
|
115
125
|
/**
|
|
116
126
|
* All organisation units with a path that includes the provided paths will be shown.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useDataQuery } from '@dhis2/app-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { patchMissingDisplayName } from './patch-missing-display-name.js';
|
|
4
|
-
export const createRootQuery = ids => ids.reduce((query, id) => ({
|
|
4
|
+
export const createRootQuery = (ids, displayProperty) => ids.reduce((query, id) => ({
|
|
5
5
|
...query,
|
|
6
6
|
[id]: {
|
|
7
7
|
id,
|
|
@@ -12,7 +12,7 @@ export const createRootQuery = ids => ids.reduce((query, id) => ({
|
|
|
12
12
|
} = _ref;
|
|
13
13
|
return {
|
|
14
14
|
isUserDataViewFallback,
|
|
15
|
-
fields: ['displayName'
|
|
15
|
+
fields: [displayProperty === 'displayName' ? 'displayName' : `${displayProperty}~rename(displayName)`, 'path', 'id']
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -23,13 +23,15 @@ export const createRootQuery = ids => ids.reduce((query, id) => ({
|
|
|
23
23
|
* @param {Object} [options]
|
|
24
24
|
* @param {boolean} [options.withChildren]
|
|
25
25
|
* @param {boolean} [options.isUserDataViewFallback]
|
|
26
|
+
* @param {'displayName'|'displayShortName'} [options.displayProperty]
|
|
26
27
|
* @returns {Object}
|
|
27
28
|
*/
|
|
28
29
|
export const useRootOrgData = function (ids) {
|
|
29
30
|
let {
|
|
30
|
-
isUserDataViewFallback
|
|
31
|
+
isUserDataViewFallback,
|
|
32
|
+
displayProperty = 'displayName'
|
|
31
33
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
32
|
-
const query = useMemo(() => createRootQuery(ids), [ids]);
|
|
34
|
+
const query = useMemo(() => createRootQuery(ids, displayProperty), [ids, displayProperty]);
|
|
33
35
|
const variables = {
|
|
34
36
|
isUserDataViewFallback
|
|
35
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/organisation-unit-tree",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.16.0",
|
|
4
4
|
"description": "UI OrganisationUnitTree",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@dhis2/prop-types": "^3.1.2",
|
|
38
|
-
"@dhis2-ui/button": "10.
|
|
39
|
-
"@dhis2-ui/checkbox": "10.
|
|
40
|
-
"@dhis2-ui/loader": "10.
|
|
41
|
-
"@dhis2-ui/node": "10.
|
|
42
|
-
"@dhis2/ui-constants": "10.
|
|
38
|
+
"@dhis2-ui/button": "10.16.0",
|
|
39
|
+
"@dhis2-ui/checkbox": "10.16.0",
|
|
40
|
+
"@dhis2-ui/loader": "10.16.0",
|
|
41
|
+
"@dhis2-ui/node": "10.16.0",
|
|
42
|
+
"@dhis2/ui-constants": "10.16.0",
|
|
43
43
|
"classnames": "^2.3.1",
|
|
44
44
|
"prop-types": "^15.7.2"
|
|
45
45
|
},
|
package/types/index.d.ts
CHANGED
|
@@ -52,6 +52,13 @@ export interface OrganisationUnitTreeProps {
|
|
|
52
52
|
* When set to true, no unit can be selected
|
|
53
53
|
*/
|
|
54
54
|
disableSelection?: boolean
|
|
55
|
+
/**
|
|
56
|
+
* Which field to render as the org unit label. Defaults to 'displayName'.
|
|
57
|
+
* Set to 'displayShortName' to honour the keyAnalysisDisplayProperty
|
|
58
|
+
* system/user setting. The query renames the chosen field back to
|
|
59
|
+
* `displayName` internally, so the consumer-facing data shape is unchanged.
|
|
60
|
+
*/
|
|
61
|
+
displayProperty?: 'displayName' | 'displayShortName'
|
|
55
62
|
expanded?: boolean
|
|
56
63
|
/**
|
|
57
64
|
* All organisation units with a path that includes the provided paths will be shown.
|