@dhis2-ui/organisation-unit-tree 9.4.3 → 9.4.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__/common.js +26 -147
- package/build/cjs/__e2e__/get-organisation-unit-data.js +140 -0
- package/build/cjs/__e2e__/namespace.js +8 -0
- package/build/cjs/features/children_as_child_nodes/index.js +4 -4
- package/build/cjs/features/controlled_expanded/index.js +13 -11
- package/build/cjs/features/displaying_loading_error/index.js +8 -8
- package/build/cjs/features/expanded/index.js +11 -11
- package/build/cjs/features/force_reload/index.js +5 -5
- package/build/cjs/features/highlight/index.js +3 -3
- package/build/cjs/features/loading_state/index.js +5 -5
- package/build/cjs/features/multi_selection/index.js +17 -17
- package/build/cjs/features/no_selection/index.js +7 -7
- package/build/cjs/features/path_based_filtering/index.js +15 -15
- package/build/cjs/features/single_selection/index.js +12 -16
- package/build/cjs/features/single_selection.feature +1 -1
- package/build/cjs/features/sub_unit_as_root/index.js +13 -19
- package/build/cjs/features/tree_api/index.js +22 -22
- package/build/es/__e2e__/common.js +11 -141
- package/build/es/__e2e__/get-organisation-unit-data.js +131 -0
- package/build/es/__e2e__/namespace.js +1 -0
- package/build/es/features/children_as_child_nodes/index.js +1 -1
- package/build/es/features/controlled_expanded/index.js +3 -2
- package/build/es/features/displaying_loading_error/index.js +1 -1
- package/build/es/features/expanded/index.js +1 -1
- package/build/es/features/force_reload/index.js +1 -1
- package/build/es/features/highlight/index.js +1 -1
- package/build/es/features/loading_state/index.js +1 -1
- package/build/es/features/multi_selection/index.js +1 -1
- package/build/es/features/no_selection/index.js +1 -1
- package/build/es/features/path_based_filtering/index.js +2 -2
- package/build/es/features/single_selection/index.js +3 -7
- package/build/es/features/single_selection.feature +1 -1
- package/build/es/features/sub_unit_as_root/index.js +1 -7
- package/build/es/features/tree_api/index.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const createResponse = _ref => {
|
|
2
|
+
let {
|
|
3
|
+
fields,
|
|
4
|
+
id,
|
|
5
|
+
path,
|
|
6
|
+
displayName,
|
|
7
|
+
children
|
|
8
|
+
} = _ref;
|
|
9
|
+
return { ...(fields.includes('id') ? {
|
|
10
|
+
id
|
|
11
|
+
} : {}),
|
|
12
|
+
...(fields.includes('path') ? {
|
|
13
|
+
path
|
|
14
|
+
} : {}),
|
|
15
|
+
...(fields.includes('displayName') ? {
|
|
16
|
+
displayName
|
|
17
|
+
} : {}),
|
|
18
|
+
...(fields.includes('children::size') ? {
|
|
19
|
+
children: children.length
|
|
20
|
+
} : {}),
|
|
21
|
+
...(fields.includes('children[id,path,displayName]') ? {
|
|
22
|
+
children
|
|
23
|
+
} : {})
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getOrganisationUnitData = (id, _ref2) => {
|
|
28
|
+
let {
|
|
29
|
+
fields
|
|
30
|
+
} = _ref2;
|
|
31
|
+
let data;
|
|
32
|
+
|
|
33
|
+
if (id === 'A0000000000') {
|
|
34
|
+
data = createResponse({
|
|
35
|
+
fields,
|
|
36
|
+
id: 'A0000000000',
|
|
37
|
+
path: '/A0000000000',
|
|
38
|
+
displayName: 'Org Unit 1',
|
|
39
|
+
children: [{
|
|
40
|
+
id: 'A0000000001',
|
|
41
|
+
path: '/A0000000000/A0000000001',
|
|
42
|
+
displayName: 'Org Unit 2'
|
|
43
|
+
}, {
|
|
44
|
+
id: 'A0000000002',
|
|
45
|
+
path: '/A0000000000/A0000000002',
|
|
46
|
+
displayName: 'Org Unit 3'
|
|
47
|
+
}, {
|
|
48
|
+
id: 'A0000000006',
|
|
49
|
+
path: '/A0000000000/A0000000006',
|
|
50
|
+
displayName: 'Org Unit 7'
|
|
51
|
+
}]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (id === 'A0000000001') {
|
|
56
|
+
data = createResponse({
|
|
57
|
+
fields,
|
|
58
|
+
id: 'A0000000001',
|
|
59
|
+
path: '/A0000000000/A0000000001',
|
|
60
|
+
displayName: 'Org Unit 2',
|
|
61
|
+
children: [{
|
|
62
|
+
id: 'A0000000003',
|
|
63
|
+
path: '/A0000000000/A0000000001/A0000000003',
|
|
64
|
+
children: [],
|
|
65
|
+
displayName: 'Org Unit 4'
|
|
66
|
+
}, {
|
|
67
|
+
id: 'A0000000004',
|
|
68
|
+
path: '/A0000000000/A0000000001/A0000000004',
|
|
69
|
+
children: [],
|
|
70
|
+
displayName: 'Org Unit 5'
|
|
71
|
+
}]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (id === 'A0000000002') {
|
|
76
|
+
data = createResponse({
|
|
77
|
+
fields,
|
|
78
|
+
displayName: 'Org Unit 3',
|
|
79
|
+
id: 'A0000000002',
|
|
80
|
+
path: '/A0000000000/A0000000002',
|
|
81
|
+
children: []
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (id === 'A0000000003') {
|
|
86
|
+
data = createResponse({
|
|
87
|
+
fields,
|
|
88
|
+
displayName: 'Org Unit 4',
|
|
89
|
+
id: 'A0000000003',
|
|
90
|
+
path: '/A0000000000/A0000000001/A0000000003',
|
|
91
|
+
children: [{
|
|
92
|
+
id: 'A0000000007',
|
|
93
|
+
path: '/A0000000000/A0000000001/A0000000003/A0000000007',
|
|
94
|
+
children: [],
|
|
95
|
+
displayName: 'Org Unit 8'
|
|
96
|
+
}]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (id === 'A0000000004') {
|
|
101
|
+
data = createResponse({
|
|
102
|
+
fields,
|
|
103
|
+
displayName: 'Org Unit 5',
|
|
104
|
+
id: 'A0000000004',
|
|
105
|
+
path: '/A0000000000/A0000000001/A0000000004',
|
|
106
|
+
children: []
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (id === 'A0000000006') {
|
|
111
|
+
data = createResponse({
|
|
112
|
+
fields,
|
|
113
|
+
displayName: 'Org Unit 7',
|
|
114
|
+
id: 'A0000000006',
|
|
115
|
+
path: '/A0000000000/A0000000006',
|
|
116
|
+
children: []
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (id === 'A0000000007') {
|
|
121
|
+
data = createResponse({
|
|
122
|
+
fields,
|
|
123
|
+
displayName: 'Org Unit 8',
|
|
124
|
+
id: 'A0000000007',
|
|
125
|
+
path: '/A0000000000/A0000000001/A0000000003/A0000000007',
|
|
126
|
+
children: []
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return data;
|
|
131
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const namespace = 'OrganisationUnitTree';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('an OrganisationUnitTree with children is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'Closed with children');
|
|
4
4
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
2
|
-
import { getOrganisationUnitData
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
|
+
import { getOrganisationUnitData } from '../../__e2e__/get-organisation-unit-data.js';
|
|
3
|
+
import { namespace } from '../../__e2e__/namespace.js';
|
|
3
4
|
|
|
4
5
|
const expectOrgUnitsToBeDisplayed = ids => {
|
|
5
6
|
const expandedLabels = ids.map(id => getOrganisationUnitData(id, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given("loading errors do not display automatically and loading A0000000001's children will fail", () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'A0000000001 loading error');
|
|
4
4
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
|
|
3
3
|
const getRootOrgUnitByLabel = label => {
|
|
4
4
|
const rootOrgUnitLabelSelector = "\n [data-test=\"dhis2-uiwidgets-orgunittree\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node-content\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node-label\"]\n label\n ";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a OrganisationUnitTree with three levels is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'Force reloading');
|
|
4
4
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a OrganisationUnitTree with a highlighted root unit is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'Root highlighted');
|
|
4
4
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a OrganisationUnitTree with two levels is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'A0000000001 loading');
|
|
4
4
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('an OrganisationUnitTree with two levels is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'Multiple selection');
|
|
4
4
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a disabled, collapsed OrganisationUnitTree with two levels is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'No selection closed');
|
|
4
4
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Before, Given, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Before, Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Before(() => {
|
|
3
3
|
cy.wrap([]).as('displayedUnits');
|
|
4
4
|
});
|
|
@@ -47,7 +47,7 @@ Then('the second node on the first level is visible', () => {
|
|
|
47
47
|
cy.getOrgUnitByLabel('Org Unit 3').should('exist');
|
|
48
48
|
addDisplayedUnit('A0000000002');
|
|
49
49
|
});
|
|
50
|
-
Then('all other nodes are not rendered',
|
|
50
|
+
Then('all other nodes are not rendered', () => {
|
|
51
51
|
cy.get('@displayedUnits').then(displayedUnits => {
|
|
52
52
|
cy.window().then(win => {
|
|
53
53
|
const excludedUnitNumbers = win.allUnits.filter(unit => !displayedUnits.includes(unit)).map(id => parseInt(id.replace(/^.*(\d)$/, '$1'), 10) + 1);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('an OrganisationUnitTree with two nodes is rendered', () => {
|
|
3
3
|
cy.visitStory('OrganisationUnitTree', 'Single selection');
|
|
4
4
|
});
|
|
5
|
-
Given('no unit
|
|
5
|
+
Given('no unit has been selected', () => {
|
|
6
6
|
cy.get('.checked').should('not.exist');
|
|
7
7
|
});
|
|
8
8
|
Given('the first unit has been selected', () => {
|
|
@@ -27,9 +27,5 @@ Then('the second unit is selected', () => {
|
|
|
27
27
|
cy.getOrgUnitByLabel('Org Unit 2').shouldBeASelectedOrgUnitNode(true);
|
|
28
28
|
});
|
|
29
29
|
Then('no unit is selected', () => {
|
|
30
|
-
cy.get('
|
|
31
|
-
$nodes.each((index, node) => {
|
|
32
|
-
cy.wrap(Cypress.$(node)).shouldNotBeASelectedOrgUnitNode();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
30
|
+
cy.get('.checked').should('not.exist');
|
|
35
31
|
});
|
|
@@ -2,7 +2,7 @@ Feature: When specified only one unit can be selected
|
|
|
2
2
|
|
|
3
3
|
Scenario: The user selects a unit when no other unit is selected
|
|
4
4
|
Given an OrganisationUnitTree with two nodes is rendered
|
|
5
|
-
And no unit
|
|
5
|
+
And no unit has been selected
|
|
6
6
|
When the user selects the first unit
|
|
7
7
|
Then the first unit is selected
|
|
8
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Given, When, Then } from 'cypress-cucumber-preprocessor
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
const rootOrgUnitLabelSelector = "\n [data-test=\"dhis2-uiwidgets-orgunittree\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node-content\"]\n > [data-test=\"dhis2-uiwidgets-orgunittree-node-label\"]\n label\n";
|
|
3
3
|
Given('a sub org unit is a root org unit', () => {
|
|
4
4
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
@@ -6,18 +6,12 @@ Given('a sub org unit is a root org unit', () => {
|
|
|
6
6
|
Given('both a sub org unit and a main org unit are root org units', () => {
|
|
7
7
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
8
8
|
});
|
|
9
|
-
Given('both a sub org unit and a main org unit are root org units', () => {
|
|
10
|
-
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
11
|
-
});
|
|
12
9
|
Given('multiple sub org units is a root org unit', () => {
|
|
13
10
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
14
11
|
});
|
|
15
12
|
Given('the root sub org unit is a child of the root main org unit', () => {
|
|
16
13
|
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
17
14
|
});
|
|
18
|
-
Given('the root sub org unit is a child of the root main org unit', () => {
|
|
19
|
-
cy.visitStory('OrganisationUnitTree', 'multiple root sub and one main org unit');
|
|
20
|
-
});
|
|
21
15
|
Given('the user provided one root sub org unit to the filter', () => {
|
|
22
16
|
cy.get('input[type="input"]').clear().type('/A0000000001');
|
|
23
17
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/organisation-unit-tree",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.5",
|
|
4
4
|
"description": "UI OrganisationUnitTree",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@dhis2/prop-types": "^3.1.2",
|
|
38
|
-
"@dhis2-ui/checkbox": "9.4.
|
|
39
|
-
"@dhis2-ui/loader": "9.4.
|
|
40
|
-
"@dhis2-ui/node": "9.4.
|
|
41
|
-
"@dhis2/ui-constants": "9.4.
|
|
38
|
+
"@dhis2-ui/checkbox": "9.4.5",
|
|
39
|
+
"@dhis2-ui/loader": "9.4.5",
|
|
40
|
+
"@dhis2-ui/node": "9.4.5",
|
|
41
|
+
"@dhis2/ui-constants": "9.4.5",
|
|
42
42
|
"classnames": "^2.3.1",
|
|
43
43
|
"prop-types": "^15.7.2"
|
|
44
44
|
},
|