@dhis2-ui/organisation-unit-tree 7.2.8 → 7.4.2
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__/common.js +134 -92
- package/build/cjs/__e2e__/controlled_expanded.stories.e2e.js +90 -0
- package/build/cjs/__e2e__/path_based_filtering.stories.e2e.js +0 -1
- package/build/cjs/__e2e__/single_selection.stories.e2e.js +4 -4
- package/build/cjs/__e2e__/tree_api.stories.e2e.js +6 -8
- package/build/cjs/__stories__/collapsed.js +22 -0
- package/build/cjs/__stories__/custom-expanded-imperative-open.js +184 -0
- package/build/cjs/__stories__/custom-node-label.js +33 -0
- package/build/cjs/__stories__/development-stories.js +96 -0
- package/build/cjs/__stories__/expanded.js +23 -0
- package/build/cjs/__stories__/filtered-root.js +25 -0
- package/build/cjs/__stories__/filtered.js +24 -0
- package/build/cjs/__stories__/force-reload-all.js +58 -0
- package/build/cjs/__stories__/force-reload-one-unit.js +37 -0
- package/build/cjs/__stories__/highlighted.js +24 -0
- package/build/cjs/__stories__/indeterminate.js +24 -0
- package/build/cjs/__stories__/loading-error-grandchild.js +44 -0
- package/build/cjs/__stories__/loading.js +39 -0
- package/build/cjs/__stories__/multiple-roots.js +24 -0
- package/build/cjs/__stories__/no-selection.js +26 -0
- package/build/cjs/__stories__/replace-roots.js +28 -0
- package/build/cjs/__stories__/root-error.js +48 -0
- package/build/cjs/__stories__/root-loading.js +48 -0
- package/build/cjs/__stories__/selected-multiple.js +25 -0
- package/build/cjs/__stories__/shared.js +140 -0
- package/build/cjs/__stories__/single-selection.js +26 -0
- package/build/cjs/features/controlled_expanded/index.js +60 -0
- package/build/cjs/features/controlled_expanded.feature +11 -0
- package/build/cjs/features/tree_api/index.js +1 -3
- package/build/cjs/get-all-expanded-paths/get-all-expanded-paths.js +40 -0
- package/build/cjs/get-all-expanded-paths/get-all-expanded-paths.test.js +17 -0
- package/build/cjs/get-all-expanded-paths/index.js +13 -0
- package/build/cjs/index.js +9 -1
- package/build/cjs/organisation-unit-node/use-open-state.js +11 -16
- package/build/cjs/organisation-unit-node/use-open-state.test.js +59 -101
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.js +35 -20
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.test.js +63 -0
- package/build/cjs/organisation-unit-tree/use-expanded/{helpers.js → create-expand-handlers.js} +1 -30
- package/build/cjs/organisation-unit-tree/use-expanded/{helpers.test.js → create-expand-handlers.test.js} +5 -18
- package/build/cjs/organisation-unit-tree/use-expanded/use-expanded.js +23 -4
- package/build/cjs/organisation-unit-tree/use-expanded/use-expanded.test.js +42 -8
- package/build/cjs/organisation-unit-tree.stories.js +191 -534
- package/build/es/__e2e__/common.js +121 -90
- package/build/es/__e2e__/controlled_expanded.stories.e2e.js +68 -0
- package/build/es/__e2e__/path_based_filtering.stories.e2e.js +0 -1
- package/build/es/__e2e__/single_selection.stories.e2e.js +4 -4
- package/build/es/__e2e__/tree_api.stories.e2e.js +6 -7
- package/build/es/__stories__/collapsed.js +8 -0
- package/build/es/__stories__/custom-expanded-imperative-open.js +166 -0
- package/build/es/__stories__/custom-node-label.js +19 -0
- package/build/es/__stories__/development-stories.js +73 -0
- package/build/es/__stories__/expanded.js +9 -0
- package/build/es/__stories__/filtered-root.js +11 -0
- package/build/es/__stories__/filtered.js +10 -0
- package/build/es/__stories__/force-reload-all.js +38 -0
- package/build/es/__stories__/force-reload-one-unit.js +25 -0
- package/build/es/__stories__/highlighted.js +10 -0
- package/build/es/__stories__/indeterminate.js +10 -0
- package/build/es/__stories__/loading-error-grandchild.js +29 -0
- package/build/es/__stories__/loading.js +24 -0
- package/build/es/__stories__/multiple-roots.js +10 -0
- package/build/es/__stories__/no-selection.js +12 -0
- package/build/es/__stories__/replace-roots.js +16 -0
- package/build/es/__stories__/root-error.js +33 -0
- package/build/es/__stories__/root-loading.js +33 -0
- package/build/es/__stories__/selected-multiple.js +11 -0
- package/build/es/__stories__/shared.js +120 -0
- package/build/es/__stories__/single-selection.js +12 -0
- package/build/es/features/controlled_expanded/index.js +57 -0
- package/build/es/features/controlled_expanded.feature +11 -0
- package/build/es/features/tree_api/index.js +1 -3
- package/build/es/get-all-expanded-paths/get-all-expanded-paths.js +31 -0
- package/build/es/get-all-expanded-paths/get-all-expanded-paths.test.js +14 -0
- package/build/es/get-all-expanded-paths/index.js +1 -0
- package/build/es/index.js +2 -1
- package/build/es/organisation-unit-node/use-open-state.js +11 -16
- package/build/es/organisation-unit-node/use-open-state.test.js +59 -94
- package/build/es/organisation-unit-tree/organisation-unit-tree.js +15 -1
- package/build/es/organisation-unit-tree/organisation-unit-tree.test.js +55 -0
- package/build/es/organisation-unit-tree/use-expanded/{helpers.js → create-expand-handlers.js} +0 -23
- package/build/es/organisation-unit-tree/use-expanded/{helpers.test.js → create-expand-handlers.test.js} +1 -14
- package/build/es/organisation-unit-tree/use-expanded/use-expanded.js +21 -3
- package/build/es/organisation-unit-tree/use-expanded/use-expanded.test.js +40 -7
- package/build/es/organisation-unit-tree.stories.js +23 -465
- package/package.json +5 -5
|
@@ -3,25 +3,204 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
Collapsed: true,
|
|
8
|
+
Expanded: true,
|
|
9
|
+
CustomExpandedImperativeOpen: true,
|
|
10
|
+
MultipleRoots: true,
|
|
11
|
+
CustomNodeLabel: true,
|
|
12
|
+
FilteredRoot: true,
|
|
13
|
+
Filtered: true,
|
|
14
|
+
SelectedMultiple: true,
|
|
15
|
+
Indeterminate: true,
|
|
16
|
+
SingleSelection: true,
|
|
17
|
+
NoSelection: true,
|
|
18
|
+
Highlighted: true,
|
|
19
|
+
ForceReloadAll: true,
|
|
20
|
+
ForceReloadOneUnit: true,
|
|
21
|
+
ReplaceRoots: true,
|
|
22
|
+
Loading: true,
|
|
23
|
+
RootLoading: true,
|
|
24
|
+
RootError: true,
|
|
25
|
+
LoadingErrorGrandchild: true
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "Collapsed", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _collapsed.Collapsed;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "Expanded", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _expanded.Expanded;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "CustomExpandedImperativeOpen", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return _customExpandedImperativeOpen.CustomExpandedImperativeOpen;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "MultipleRoots", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () {
|
|
48
|
+
return _multipleRoots.MultipleRoots;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "CustomNodeLabel", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _customNodeLabel.CustomNodeLabel;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "FilteredRoot", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () {
|
|
60
|
+
return _filteredRoot.FilteredRoot;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "Filtered", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () {
|
|
66
|
+
return _filtered.Filtered;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "SelectedMultiple", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () {
|
|
72
|
+
return _selectedMultiple.SelectedMultiple;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "Indeterminate", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return _indeterminate.Indeterminate;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "SingleSelection", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return _singleSelection.SingleSelection;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "NoSelection", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _noSelection.NoSelection;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "Highlighted", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return _highlighted.Highlighted;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, "ForceReloadAll", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () {
|
|
102
|
+
return _forceReloadAll.ForceReloadAll;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "ForceReloadOneUnit", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () {
|
|
108
|
+
return _forceReloadOneUnit.ForceReloadOneUnit;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, "ReplaceRoots", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function () {
|
|
114
|
+
return _replaceRoots.ReplaceRoots;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "Loading", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () {
|
|
120
|
+
return _loading.Loading;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(exports, "RootLoading", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
get: function () {
|
|
126
|
+
return _rootLoading.RootLoading;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(exports, "RootError", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () {
|
|
132
|
+
return _rootError.RootError;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(exports, "LoadingErrorGrandchild", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () {
|
|
138
|
+
return _loadingErrorGrandchild.LoadingErrorGrandchild;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
exports.default = void 0;
|
|
11
142
|
|
|
12
143
|
var _appRuntime = require("@dhis2/app-runtime");
|
|
13
144
|
|
|
14
|
-
var _react =
|
|
145
|
+
var _react = _interopRequireDefault(require("react"));
|
|
146
|
+
|
|
147
|
+
var _shared = require("./__stories__/shared.js");
|
|
15
148
|
|
|
16
149
|
var _index = require("./index.js");
|
|
17
150
|
|
|
18
|
-
|
|
151
|
+
var _collapsed = require("./__stories__/collapsed.js");
|
|
19
152
|
|
|
20
|
-
|
|
153
|
+
var _expanded = require("./__stories__/expanded.js");
|
|
21
154
|
|
|
22
|
-
|
|
155
|
+
var _customExpandedImperativeOpen = require("./__stories__/custom-expanded-imperative-open.js");
|
|
23
156
|
|
|
24
|
-
|
|
157
|
+
var _multipleRoots = require("./__stories__/multiple-roots.js");
|
|
158
|
+
|
|
159
|
+
var _customNodeLabel = require("./__stories__/custom-node-label.js");
|
|
160
|
+
|
|
161
|
+
var _filteredRoot = require("./__stories__/filtered-root.js");
|
|
162
|
+
|
|
163
|
+
var _filtered = require("./__stories__/filtered.js");
|
|
164
|
+
|
|
165
|
+
var _selectedMultiple = require("./__stories__/selected-multiple.js");
|
|
166
|
+
|
|
167
|
+
var _indeterminate = require("./__stories__/indeterminate.js");
|
|
168
|
+
|
|
169
|
+
var _singleSelection = require("./__stories__/single-selection.js");
|
|
170
|
+
|
|
171
|
+
var _noSelection = require("./__stories__/no-selection.js");
|
|
172
|
+
|
|
173
|
+
var _highlighted = require("./__stories__/highlighted.js");
|
|
174
|
+
|
|
175
|
+
var _forceReloadAll = require("./__stories__/force-reload-all.js");
|
|
176
|
+
|
|
177
|
+
var _forceReloadOneUnit = require("./__stories__/force-reload-one-unit.js");
|
|
178
|
+
|
|
179
|
+
var _replaceRoots = require("./__stories__/replace-roots.js");
|
|
180
|
+
|
|
181
|
+
var _loading = require("./__stories__/loading.js");
|
|
182
|
+
|
|
183
|
+
var _rootLoading = require("./__stories__/root-loading.js");
|
|
184
|
+
|
|
185
|
+
var _rootError = require("./__stories__/root-error.js");
|
|
186
|
+
|
|
187
|
+
var _loadingErrorGrandchild = require("./__stories__/loading-error-grandchild.js");
|
|
188
|
+
|
|
189
|
+
var _developmentStories = require("./__stories__/development-stories.js");
|
|
190
|
+
|
|
191
|
+
Object.keys(_developmentStories).forEach(function (key) {
|
|
192
|
+
if (key === "default" || key === "__esModule") return;
|
|
193
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
194
|
+
if (key in exports && exports[key] === _developmentStories[key]) return;
|
|
195
|
+
Object.defineProperty(exports, key, {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function () {
|
|
198
|
+
return _developmentStories[key];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
204
|
|
|
26
205
|
const subtitle = 'Display, manipulate and select organization units displayed in a hierarchical tree';
|
|
27
206
|
const description = `
|
|
@@ -50,198 +229,11 @@ const orgUnitTree = (
|
|
|
50
229
|
\`\`\`
|
|
51
230
|
|
|
52
231
|
`;
|
|
53
|
-
const log = true;
|
|
54
|
-
|
|
55
|
-
const onChange = (...args) => log && console.log('onChange', ...args);
|
|
56
|
-
|
|
57
|
-
const onExpand = (...args) => log && console.log('onExpand', ...args);
|
|
58
|
-
|
|
59
|
-
const onCollapse = (...args) => log && console.log('onCollapse', ...args);
|
|
60
|
-
|
|
61
|
-
const onChildrenLoaded = (...args) => log && console.log('onChildrenLoaded', ...args);
|
|
62
|
-
|
|
63
|
-
const customData = {
|
|
64
|
-
organisationUnits: (...args) => {
|
|
65
|
-
const [, {
|
|
66
|
-
id
|
|
67
|
-
}] = args;
|
|
68
|
-
let data,
|
|
69
|
-
delay = 0;
|
|
70
|
-
|
|
71
|
-
if (id === 'A0000000000') {
|
|
72
|
-
delay = 1000;
|
|
73
|
-
data = {
|
|
74
|
-
id: 'A0000000000',
|
|
75
|
-
path: '/A0000000000',
|
|
76
|
-
displayName: 'Org Unit 1',
|
|
77
|
-
children: [{
|
|
78
|
-
id: 'A0000000001',
|
|
79
|
-
path: '/A0000000000/A0000000001',
|
|
80
|
-
children: [{
|
|
81
|
-
id: 'A0000000003'
|
|
82
|
-
}, {
|
|
83
|
-
id: 'A0000000004'
|
|
84
|
-
}],
|
|
85
|
-
displayName: 'Org Unit 2'
|
|
86
|
-
}, {
|
|
87
|
-
id: 'A0000000002',
|
|
88
|
-
path: '/A0000000000/A0000000002',
|
|
89
|
-
children: [],
|
|
90
|
-
displayName: 'Org Unit 3'
|
|
91
|
-
}, {
|
|
92
|
-
id: 'A0000000006',
|
|
93
|
-
path: '/A0000000000/A0000000006',
|
|
94
|
-
children: [],
|
|
95
|
-
displayName: 'Org Unit 7'
|
|
96
|
-
}]
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (id === 'A0000000001') {
|
|
101
|
-
data = {
|
|
102
|
-
id: 'A0000000001',
|
|
103
|
-
path: '/A0000000000/A0000000001',
|
|
104
|
-
displayName: 'Org Unit 2',
|
|
105
|
-
children: [{
|
|
106
|
-
id: 'A0000000003',
|
|
107
|
-
path: '/A0000000000/A0000000001/A0000000003',
|
|
108
|
-
children: [],
|
|
109
|
-
displayName: 'Org Unit 4'
|
|
110
|
-
}, {
|
|
111
|
-
id: 'A0000000004',
|
|
112
|
-
path: '/A0000000000/A0000000001/A0000000004',
|
|
113
|
-
children: [],
|
|
114
|
-
displayName: 'Org Unit 5'
|
|
115
|
-
}]
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (id === 'A0000000002') {
|
|
120
|
-
delay = 1000;
|
|
121
|
-
data = {
|
|
122
|
-
displayName: 'Org Unit 3',
|
|
123
|
-
id: 'A0000000002',
|
|
124
|
-
path: '/A0000000000/A0000000002',
|
|
125
|
-
children: []
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (id === 'A0000000003') {
|
|
130
|
-
data = {
|
|
131
|
-
displayName: 'Org Unit 4',
|
|
132
|
-
id: 'A0000000003',
|
|
133
|
-
path: '/A0000000000/A0000000001/A0000000003',
|
|
134
|
-
children: []
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (id === 'A0000000004') {
|
|
139
|
-
data = {
|
|
140
|
-
displayName: 'Org Unit 5',
|
|
141
|
-
id: 'A0000000004',
|
|
142
|
-
path: '/A0000000000/A0000000001/A0000000004',
|
|
143
|
-
children: []
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (id === 'A0000000006') {
|
|
148
|
-
data = {
|
|
149
|
-
displayName: 'Org Unit 7',
|
|
150
|
-
id: 'A0000000006',
|
|
151
|
-
path: '/A0000000000/A0000000006',
|
|
152
|
-
children: []
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!data) {
|
|
157
|
-
return Promise.reject(new Error('404 - Org unit not found'));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return new Promise(resolve => {
|
|
161
|
-
setTimeout(() => resolve(data), delay);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const ForceReloadAll = () => {
|
|
167
|
-
const [forceReload, _setForceReload] = (0, _react.useState)(false);
|
|
168
|
-
|
|
169
|
-
const setForceReload = v => console.log('setForceReload', v) || _setForceReload(v);
|
|
170
|
-
|
|
171
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_button.Button, {
|
|
172
|
-
disabled: forceReload,
|
|
173
|
-
onClick: () => setForceReload(true)
|
|
174
|
-
}, "Reload org unit tree"), ' ', /*#__PURE__*/_react.default.createElement("span", {
|
|
175
|
-
className: "jsx-2109967648"
|
|
176
|
-
}, "(Force reload: ", forceReload ? 'true' : 'false', ")"), /*#__PURE__*/_react.default.createElement("div", {
|
|
177
|
-
className: "jsx-2109967648"
|
|
178
|
-
}, /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
179
|
-
onChange: onChange,
|
|
180
|
-
forceReload: forceReload,
|
|
181
|
-
name: "Root org unit",
|
|
182
|
-
roots: ['A0000000000'],
|
|
183
|
-
initiallyExpanded: ['/A0000000000/A0000000001'],
|
|
184
|
-
selected: ['/A0000000000/A0000000001/A0000000003'],
|
|
185
|
-
onChildrenLoaded: data => {
|
|
186
|
-
const {
|
|
187
|
-
id
|
|
188
|
-
} = data;
|
|
189
|
-
|
|
190
|
-
if (id === 'A0000000000') {
|
|
191
|
-
setForceReload(false);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
})), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
195
|
-
id: "2109967648"
|
|
196
|
-
}, ["div.jsx-2109967648{width:400px;border:1px solid black;margin-top:32px;padding:16px;min-height:200px;}"]));
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const ForceReloadIds = () => {
|
|
200
|
-
return /*#__PURE__*/_react.default.createElement("p", null, "This is currently not working due to limitations of the data engine in the app runtime."); //const [idsThatShouldBeReloaded, setIdsThatShouldBeReloaded] = useState([])
|
|
201
|
-
//useEffect(() => {
|
|
202
|
-
// setTimeout(() => setIdsThatShouldBeReloaded(['A0000000001']), delay)
|
|
203
|
-
//}, [])
|
|
204
|
-
//return (
|
|
205
|
-
// <OrganisationUnitTree
|
|
206
|
-
// onChange={onChange}
|
|
207
|
-
// idsThatShouldBeReloaded={idsThatShouldBeReloaded}
|
|
208
|
-
// name="Root org unit"
|
|
209
|
-
// roots={['A0000000000']}
|
|
210
|
-
// initiallyExpanded={['/A0000000000', '/A0000000000/A0000000001']}
|
|
211
|
-
// selected={['/A0000000000/A0000000001/A0000000003']}
|
|
212
|
-
// onChildrenLoaded={({ path, forced }) =>
|
|
213
|
-
// console.log(
|
|
214
|
-
// `Unit with path "${path}" loaded, was forced: ${
|
|
215
|
-
// forced ? 'yes' : 'no'
|
|
216
|
-
// }`
|
|
217
|
-
// )
|
|
218
|
-
// }
|
|
219
|
-
// />
|
|
220
|
-
//)
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const ReplaceRoots = ({
|
|
224
|
-
delay
|
|
225
|
-
}) => {
|
|
226
|
-
return /*#__PURE__*/_react.default.createElement("p", null, "This is currently not working due to limitations of the data engine in the app runtime. Normally the root unit would've been replaced after ", ` ${delay} `, " milliseconds."); //const [roots, setRoots] = useState(['A0000000000'])
|
|
227
|
-
//useEffect(() => {
|
|
228
|
-
// setTimeout(() => setRoots(['A0000000001']), delay)
|
|
229
|
-
//}, [])
|
|
230
|
-
//return (
|
|
231
|
-
// <OrganisationUnitTree
|
|
232
|
-
// name="Root org unit"
|
|
233
|
-
// roots={roots}
|
|
234
|
-
// onChange={console.log.bind(null, 'onChange')}
|
|
235
|
-
// initiallyExpanded={['/A0000000001']}
|
|
236
|
-
// />
|
|
237
|
-
//)
|
|
238
|
-
};
|
|
239
|
-
|
|
240
232
|
var _default = {
|
|
241
233
|
title: 'Forms/Organisation Unit Tree',
|
|
242
234
|
component: _index.OrganisationUnitTree,
|
|
243
235
|
decorators: [fn => /*#__PURE__*/_react.default.createElement(_appRuntime.CustomDataProvider, {
|
|
244
|
-
data: customData
|
|
236
|
+
data: _shared.customData
|
|
245
237
|
}, fn())],
|
|
246
238
|
parameters: {
|
|
247
239
|
componentSubtitle: subtitle,
|
|
@@ -252,339 +244,4 @@ var _default = {
|
|
|
252
244
|
}
|
|
253
245
|
}
|
|
254
246
|
};
|
|
255
|
-
exports.default = _default;
|
|
256
|
-
|
|
257
|
-
const Collapsed = args => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, args);
|
|
258
|
-
|
|
259
|
-
exports.Collapsed = Collapsed;
|
|
260
|
-
Collapsed.args = {
|
|
261
|
-
onChange: onChange,
|
|
262
|
-
name: 'Root org unit',
|
|
263
|
-
roots: ['A0000000000']
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const Expanded = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
267
|
-
onChange: onChange,
|
|
268
|
-
name: "Root org unit",
|
|
269
|
-
roots: ['A0000000000'],
|
|
270
|
-
initiallyExpanded: ['/A0000000000/A0000000001']
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
exports.Expanded = Expanded;
|
|
274
|
-
|
|
275
|
-
const MultipleRoots = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
276
|
-
onChange: onChange,
|
|
277
|
-
name: "Root org unit",
|
|
278
|
-
roots: ['A0000000000', 'A0000000001'],
|
|
279
|
-
initiallyExpanded: ['/A0000000000/A0000000001']
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
exports.MultipleRoots = MultipleRoots;
|
|
283
|
-
MultipleRoots.storyName = 'Multiple roots';
|
|
284
|
-
|
|
285
|
-
const CustomNodeLabel = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
286
|
-
name: "Root org unit",
|
|
287
|
-
roots: "A0000000000",
|
|
288
|
-
initiallyExpanded: ['/A0000000000/A0000000001'],
|
|
289
|
-
renderNodeLabel: ({
|
|
290
|
-
label,
|
|
291
|
-
node
|
|
292
|
-
}) => {
|
|
293
|
-
if (node.path !== '/A0000000000/A0000000001') {
|
|
294
|
-
return label;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return /*#__PURE__*/_react.default.createElement("span", null, "--- ", label);
|
|
298
|
-
},
|
|
299
|
-
onChange: onChange
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
exports.CustomNodeLabel = CustomNodeLabel;
|
|
303
|
-
|
|
304
|
-
const FilteredRoot = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
305
|
-
onChange: onChange,
|
|
306
|
-
name: "Root org unit",
|
|
307
|
-
roots: ['A0000000000', 'A0000000001'],
|
|
308
|
-
initiallyExpanded: ['/A0000000000/A0000000001'],
|
|
309
|
-
filter: ['/A0000000000']
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
exports.FilteredRoot = FilteredRoot;
|
|
313
|
-
FilteredRoot.storyName = 'Filtered (root)';
|
|
314
|
-
|
|
315
|
-
const Filtered = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
316
|
-
onChange: onChange,
|
|
317
|
-
name: "Root org unit",
|
|
318
|
-
roots: ['A0000000000'],
|
|
319
|
-
initiallyExpanded: ['/A0000000000/A0000000001'],
|
|
320
|
-
filter: ['/A0000000000/A0000000001']
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
exports.Filtered = Filtered;
|
|
324
|
-
|
|
325
|
-
const SelectedMultiple = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
326
|
-
onChange: onChange,
|
|
327
|
-
name: "Root org unit",
|
|
328
|
-
roots: ['A0000000000'],
|
|
329
|
-
selected: ['/A0000000000/A0000000002', '/A0000000000/A0000000001/A0000000003'],
|
|
330
|
-
initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001']
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
exports.SelectedMultiple = SelectedMultiple;
|
|
334
|
-
SelectedMultiple.storyName = 'Selected multiple';
|
|
335
|
-
|
|
336
|
-
const Indeterminate = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
337
|
-
onChange: onChange,
|
|
338
|
-
name: "Root org unit",
|
|
339
|
-
roots: ['A0000000000'],
|
|
340
|
-
selected: ['/A0000000000/A0000000001'],
|
|
341
|
-
initiallyExpanded: ['/A0000000000']
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
exports.Indeterminate = Indeterminate;
|
|
345
|
-
|
|
346
|
-
const SingleSelection = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
347
|
-
onChange: onChange,
|
|
348
|
-
singleSelection: true,
|
|
349
|
-
name: "Root org unit",
|
|
350
|
-
roots: ['A0000000000'],
|
|
351
|
-
selected: ['/A0000000000/A0000000001'],
|
|
352
|
-
initiallyExpanded: ['/A0000000000']
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
exports.SingleSelection = SingleSelection;
|
|
356
|
-
SingleSelection.storyName = 'Single selection';
|
|
357
|
-
|
|
358
|
-
const NoSelection = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
359
|
-
onChange: onChange,
|
|
360
|
-
disableSelection: true,
|
|
361
|
-
name: "Root org unit",
|
|
362
|
-
roots: ['A0000000000'],
|
|
363
|
-
selected: ['/A0000000000/A0000000001'],
|
|
364
|
-
initiallyExpanded: ['/A0000000000']
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
exports.NoSelection = NoSelection;
|
|
368
|
-
NoSelection.storyName = 'No selection';
|
|
369
|
-
|
|
370
|
-
const Highlighted = () => /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
371
|
-
onChange: onChange,
|
|
372
|
-
highlighted: ['/A0000000000/A0000000001'],
|
|
373
|
-
name: "Root org unit",
|
|
374
|
-
roots: ['A0000000000'],
|
|
375
|
-
initiallyExpanded: ['/A0000000000']
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
exports.Highlighted = Highlighted;
|
|
379
|
-
|
|
380
|
-
const _ForceReloadAll = () => /*#__PURE__*/_react.default.createElement(ForceReloadAll, null);
|
|
381
|
-
|
|
382
|
-
exports._ForceReloadAll = _ForceReloadAll;
|
|
383
|
-
_ForceReloadAll.storyName = 'Force reload all';
|
|
384
|
-
|
|
385
|
-
const ForceReloadOneUnit = () => /*#__PURE__*/_react.default.createElement(ForceReloadIds, {
|
|
386
|
-
delay: 2000
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
exports.ForceReloadOneUnit = ForceReloadOneUnit;
|
|
390
|
-
ForceReloadOneUnit.storyName = 'Force reload one unit';
|
|
391
|
-
|
|
392
|
-
const _ReplaceRoots = () => /*#__PURE__*/_react.default.createElement(ReplaceRoots, {
|
|
393
|
-
delay: 1000
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
exports._ReplaceRoots = _ReplaceRoots;
|
|
397
|
-
_ReplaceRoots.storyName = 'Replace roots';
|
|
398
|
-
|
|
399
|
-
const Loading = () => /*#__PURE__*/_react.default.createElement(_appRuntime.CustomDataProvider, {
|
|
400
|
-
data: { ...customData,
|
|
401
|
-
organisationUnits: (...args) => {
|
|
402
|
-
const [, {
|
|
403
|
-
id
|
|
404
|
-
}] = args;
|
|
405
|
-
|
|
406
|
-
if (id === 'A0000000001') {
|
|
407
|
-
return new Promise(() => null);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
return customData.organisationUnits(...args);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}, /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
414
|
-
onChange: onChange,
|
|
415
|
-
name: "Root org unit",
|
|
416
|
-
roots: ['A0000000000'],
|
|
417
|
-
initiallyExpanded: ['/A0000000000/A0000000001']
|
|
418
|
-
}));
|
|
419
|
-
|
|
420
|
-
exports.Loading = Loading;
|
|
421
|
-
|
|
422
|
-
const RootLoading = () => /*#__PURE__*/_react.default.createElement(_appRuntime.CustomDataProvider, {
|
|
423
|
-
data: { ...customData,
|
|
424
|
-
organisationUnits: (...args) => {
|
|
425
|
-
const [, {
|
|
426
|
-
id
|
|
427
|
-
}] = args;
|
|
428
|
-
|
|
429
|
-
if (id === 'A0000000000') {
|
|
430
|
-
return new Promise(() => null);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return customData.organisationUnits(...args);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}, /*#__PURE__*/_react.default.createElement("fieldset", {
|
|
437
|
-
style: {
|
|
438
|
-
maxWidth: 600
|
|
439
|
-
}
|
|
440
|
-
}, /*#__PURE__*/_react.default.createElement("legend", {
|
|
441
|
-
style: {
|
|
442
|
-
padding: '0 10px'
|
|
443
|
-
}
|
|
444
|
-
}, "Custom container (max-width: 600px)"), /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
445
|
-
onChange: onChange,
|
|
446
|
-
name: "Root org unit",
|
|
447
|
-
roots: ['A0000000000'],
|
|
448
|
-
initiallyExpanded: ['/A0000000000/A0000000001']
|
|
449
|
-
})));
|
|
450
|
-
|
|
451
|
-
exports.RootLoading = RootLoading;
|
|
452
|
-
RootLoading.storyName = 'Root loading';
|
|
453
|
-
|
|
454
|
-
const RootError = () => /*#__PURE__*/_react.default.createElement(_appRuntime.CustomDataProvider, {
|
|
455
|
-
data: { ...customData,
|
|
456
|
-
organisationUnits: (...args) => {
|
|
457
|
-
const [, {
|
|
458
|
-
id
|
|
459
|
-
}] = args;
|
|
460
|
-
|
|
461
|
-
if (id === 'A0000000000') {
|
|
462
|
-
return Promise.reject('This is a custom error message, it could be anything');
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return customData.organisationUnits(...args);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}, /*#__PURE__*/_react.default.createElement("fieldset", {
|
|
469
|
-
style: {
|
|
470
|
-
maxWidth: 600
|
|
471
|
-
}
|
|
472
|
-
}, /*#__PURE__*/_react.default.createElement("legend", {
|
|
473
|
-
style: {
|
|
474
|
-
padding: '0 10px'
|
|
475
|
-
}
|
|
476
|
-
}, "Custom container (max-width: 600px)"), /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
477
|
-
onChange: onChange,
|
|
478
|
-
name: "Root org unit",
|
|
479
|
-
roots: ['A0000000000'],
|
|
480
|
-
initiallyExpanded: ['/A0000000000/A0000000001']
|
|
481
|
-
})));
|
|
482
|
-
|
|
483
|
-
exports.RootError = RootError;
|
|
484
|
-
RootError.storyName = 'Root error';
|
|
485
|
-
|
|
486
|
-
const LoadingErrorGrandchild = () => /*#__PURE__*/_react.default.createElement(_appRuntime.CustomDataProvider, {
|
|
487
|
-
data: { ...customData,
|
|
488
|
-
organisationUnits: (...args) => {
|
|
489
|
-
const [, {
|
|
490
|
-
id
|
|
491
|
-
}] = args;
|
|
492
|
-
|
|
493
|
-
if (id === 'A0000000003') {
|
|
494
|
-
return Promise.reject('Loading org unit 4 and 5 failed');
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
return customData.organisationUnits(...args);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}, /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, {
|
|
501
|
-
autoExpandLoadingError: true,
|
|
502
|
-
name: "Root org unit",
|
|
503
|
-
roots: ['A0000000000'],
|
|
504
|
-
onChange: onChange,
|
|
505
|
-
onExpand: onExpand,
|
|
506
|
-
onCollapse: onCollapse,
|
|
507
|
-
onChildrenLoaded: onChildrenLoaded,
|
|
508
|
-
initiallyExpanded: ['/A0000000000/A0000000001']
|
|
509
|
-
}));
|
|
510
|
-
|
|
511
|
-
exports.LoadingErrorGrandchild = LoadingErrorGrandchild;
|
|
512
|
-
LoadingErrorGrandchild.storyName = 'Loading error grandchild';
|
|
513
|
-
|
|
514
|
-
const DX_onChange = (selected, setSelected, singleSelection) => ({
|
|
515
|
-
id,
|
|
516
|
-
path,
|
|
517
|
-
checked
|
|
518
|
-
}) => {
|
|
519
|
-
console.log('onChange', {
|
|
520
|
-
path,
|
|
521
|
-
id,
|
|
522
|
-
checked
|
|
523
|
-
});
|
|
524
|
-
const pathIndex = selected.indexOf(path);
|
|
525
|
-
|
|
526
|
-
if (checked) {
|
|
527
|
-
setSelected(singleSelection ? [path] : [...selected, path]);
|
|
528
|
-
} else {
|
|
529
|
-
setSelected(singleSelection ? [] : [...selected.slice(0, pathIndex), ...selected.slice(pathIndex + 1)]);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
const Wrapper = props => {
|
|
534
|
-
const [selected, setSelected] = (0, _react.useState)([]);
|
|
535
|
-
return /*#__PURE__*/_react.default.createElement(_index.OrganisationUnitTree, _extends({
|
|
536
|
-
name: "Root org unit",
|
|
537
|
-
roots: ['A0000000000'],
|
|
538
|
-
selected: selected,
|
|
539
|
-
onChange: DX_onChange(selected, setSelected, props.singleSelection),
|
|
540
|
-
initiallyExpanded: ['A0000000001/A0000000002']
|
|
541
|
-
}, props));
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
const DxMultiSelection = () => /*#__PURE__*/_react.default.createElement(Wrapper, null);
|
|
545
|
-
|
|
546
|
-
exports.DxMultiSelection = DxMultiSelection;
|
|
547
|
-
DxMultiSelection.storyName = 'DX: Multi selection';
|
|
548
|
-
|
|
549
|
-
const DxSingleSelection = () => /*#__PURE__*/_react.default.createElement(Wrapper, {
|
|
550
|
-
singleSelection: true
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
exports.DxSingleSelection = DxSingleSelection;
|
|
554
|
-
DxSingleSelection.storyName = 'DX: Single selection';
|
|
555
|
-
|
|
556
|
-
const DxNoSelection = () => /*#__PURE__*/_react.default.createElement(Wrapper, {
|
|
557
|
-
disableSelection: true
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
exports.DxNoSelection = DxNoSelection;
|
|
561
|
-
DxNoSelection.storyName = 'DX: No selection';
|
|
562
|
-
|
|
563
|
-
const DxWithRealBackend = () => /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
564
|
-
style: {
|
|
565
|
-
marginBottom: 20,
|
|
566
|
-
lineHeight: '28px'
|
|
567
|
-
}
|
|
568
|
-
}, /*#__PURE__*/_react.default.createElement("b", null, "This story doesn't work on netlify for some reason, just run it locally."), /*#__PURE__*/_react.default.createElement("br", null), "You need to log in to", ' ', /*#__PURE__*/_react.default.createElement("a", {
|
|
569
|
-
href: "https://debug.dhis2.org/dev",
|
|
570
|
-
target: "_blank",
|
|
571
|
-
rel: "noopener noreferrer"
|
|
572
|
-
}, "https://debug.dhis2.org/dev"), /*#__PURE__*/_react.default.createElement("br", null), "Make sure the", ' ', /*#__PURE__*/_react.default.createElement("code", {
|
|
573
|
-
style: {
|
|
574
|
-
background: '#ccc'
|
|
575
|
-
}
|
|
576
|
-
}, "localhost:[PORT]"), " is part of the accepted list:", ' ', /*#__PURE__*/_react.default.createElement("a", {
|
|
577
|
-
href: "https://debug.dhis2.org/dev/dhis-web-settings/#/access",
|
|
578
|
-
target: "_blank",
|
|
579
|
-
rel: "noopener noreferrer"
|
|
580
|
-
}, "Settings app / Access")), /*#__PURE__*/_react.default.createElement(_appRuntime.DataProvider, {
|
|
581
|
-
baseUrl: "https://debug.dhis2.org/dev",
|
|
582
|
-
apiVersion: ""
|
|
583
|
-
}, /*#__PURE__*/_react.default.createElement(Wrapper //initiallyExpanded={['/ImspTQPwCqd/eIQbndfxQMb']}
|
|
584
|
-
, {
|
|
585
|
-
suppressAlphabeticalSorting: true,
|
|
586
|
-
roots: "ImspTQPwCqd"
|
|
587
|
-
})));
|
|
588
|
-
|
|
589
|
-
exports.DxWithRealBackend = DxWithRealBackend;
|
|
590
|
-
DxWithRealBackend.storyName = 'DX: With real backend';
|
|
247
|
+
exports.default = _default;
|