@dhis2/analytics 20.7.0 → 21.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/__demo__/OrgUnitDimension.stories.js +104 -0
- package/build/cjs/api/organisationUnits.js +100 -46
- package/build/cjs/components/FileMenu/DeleteDialog.js +2 -2
- package/build/cjs/components/FileMenu/FileMenu.js +2 -2
- package/build/cjs/components/FileMenu/GetLinkDialog.js +2 -2
- package/build/cjs/components/FileMenu/RenameDialog.js +2 -2
- package/build/cjs/components/FileMenu/SaveAsDialog.js +2 -2
- package/build/cjs/components/OrgUnitDimension/OrgUnitDimension.js +223 -193
- package/build/cjs/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +5 -2
- package/build/cjs/components/PeriodDimension/FixedPeriodSelect.js +2 -2
- package/build/cjs/components/TransferOption.js +2 -2
- package/build/cjs/index.js +22 -4
- package/build/cjs/locales/en/translations.json +14 -0
- package/build/cjs/modules/list.js +25 -0
- package/build/cjs/modules/ouIdHelper/index.js +7 -1
- package/build/cjs/modules/relativeItems/index.js +1 -1
- package/build/cjs/visualizations/util/__tests__/getFilterText.spec.js +1 -1
- package/build/cjs/visualizations/util/getFilterText.js +1 -9
- package/build/es/__demo__/OrgUnitDimension.stories.js +93 -0
- package/build/es/api/organisationUnits.js +93 -43
- package/build/es/components/FileMenu/DeleteDialog.js +1 -1
- package/build/es/components/FileMenu/FileMenu.js +1 -1
- package/build/es/components/FileMenu/GetLinkDialog.js +1 -1
- package/build/es/components/FileMenu/RenameDialog.js +1 -1
- package/build/es/components/FileMenu/SaveAsDialog.js +1 -1
- package/build/es/components/OrgUnitDimension/OrgUnitDimension.js +224 -196
- package/build/es/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +3 -2
- package/build/es/components/PeriodDimension/FixedPeriodSelect.js +6 -6
- package/build/es/components/TransferOption.js +12 -12
- package/build/es/index.js +2 -2
- package/build/es/locales/en/translations.json +14 -0
- package/build/es/modules/list.js +13 -0
- package/build/es/modules/ouIdHelper/index.js +3 -0
- package/build/es/modules/relativeItems/index.js +2 -2
- package/build/es/visualizations/util/__tests__/getFilterText.spec.js +1 -1
- package/build/es/visualizations/util/getFilterText.js +2 -10
- package/package.json +3 -2
- package/CHANGELOG.md +0 -2763
- package/build/cjs/api/organisationUnits-dataEngine.js +0 -119
- package/build/cjs/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js +0 -96
- package/build/es/api/organisationUnits-dataEngine.js +0 -96
- package/build/es/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js +0 -86
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.apiFetchOrganisationUnit = exports.apiFetchOrganisationUnits = exports.apiFetchOrganisationUnitRoots = exports.apiFetchOrganisationUnitGroups = exports.apiFetchOrganisationUnitLevels = void 0;
|
|
7
|
-
|
|
8
|
-
var _index = require("./index");
|
|
9
|
-
|
|
10
|
-
const orgUnitLevelsQuery = {
|
|
11
|
-
resource: 'organisationUnitLevels',
|
|
12
|
-
params: {
|
|
13
|
-
fields: 'id,level,displayName,name',
|
|
14
|
-
paging: false
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const orgUnitGroupsQuery = {
|
|
18
|
-
resource: 'organisationUnitGroups',
|
|
19
|
-
params: ({
|
|
20
|
-
displayNameProp
|
|
21
|
-
}) => ({
|
|
22
|
-
fields: "id,".concat(displayNameProp, "~rename(displayName),name"),
|
|
23
|
-
paging: false
|
|
24
|
-
})
|
|
25
|
-
};
|
|
26
|
-
const orgUnitRootsQuery = {
|
|
27
|
-
resource: 'organisationUnits',
|
|
28
|
-
params: {
|
|
29
|
-
fields: 'id,displayName,name',
|
|
30
|
-
userDataViewFallback: true,
|
|
31
|
-
paging: false
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const orgUnitsQuery = {
|
|
35
|
-
resource: 'organisationUnits',
|
|
36
|
-
params: ({
|
|
37
|
-
displayNameProp
|
|
38
|
-
}) => ({
|
|
39
|
-
fields: "id,path,".concat(displayNameProp, "~rename(displayName),children::isNotEmpty"),
|
|
40
|
-
level: 1,
|
|
41
|
-
userDataViewFallback: true,
|
|
42
|
-
paging: false
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
const orgUnitQuery = {
|
|
46
|
-
resource: 'organisationUnits',
|
|
47
|
-
id: ({
|
|
48
|
-
id
|
|
49
|
-
}) => id,
|
|
50
|
-
params: {
|
|
51
|
-
fields: 'id,level,displayName~rename(name),path,parent[id,displayName~rename(name)],children[level]',
|
|
52
|
-
userDataViewFallback: true,
|
|
53
|
-
paging: false
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const apiFetchOrganisationUnitLevels = async dataEngine => {
|
|
58
|
-
const orgUnitLevelsData = await dataEngine.query({
|
|
59
|
-
orgUnitLevels: orgUnitLevelsQuery
|
|
60
|
-
}, {
|
|
61
|
-
onError: _index.onError
|
|
62
|
-
});
|
|
63
|
-
return orgUnitLevelsData.orgUnitLevels.organisationUnitLevels;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
exports.apiFetchOrganisationUnitLevels = apiFetchOrganisationUnitLevels;
|
|
67
|
-
|
|
68
|
-
const apiFetchOrganisationUnitGroups = async (dataEngine, displayNameProp) => {
|
|
69
|
-
const orgUnitGroupsData = await dataEngine.query({
|
|
70
|
-
orgUnitGroups: orgUnitGroupsQuery
|
|
71
|
-
}, {
|
|
72
|
-
variables: {
|
|
73
|
-
displayNameProp
|
|
74
|
-
},
|
|
75
|
-
onError: _index.onError
|
|
76
|
-
});
|
|
77
|
-
return orgUnitGroupsData.orgUnitGroups.organisationUnitGroups;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
exports.apiFetchOrganisationUnitGroups = apiFetchOrganisationUnitGroups;
|
|
81
|
-
|
|
82
|
-
const apiFetchOrganisationUnitRoots = async dataEngine => {
|
|
83
|
-
const orgUnitRootsData = await dataEngine.query({
|
|
84
|
-
orgUnitRoots: orgUnitRootsQuery
|
|
85
|
-
}, {
|
|
86
|
-
onError: _index.onError
|
|
87
|
-
});
|
|
88
|
-
return orgUnitRootsData.orgUnitRoots.organisationUnits;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
exports.apiFetchOrganisationUnitRoots = apiFetchOrganisationUnitRoots;
|
|
92
|
-
|
|
93
|
-
const apiFetchOrganisationUnits = async (dataEngine, displayNameProp) => {
|
|
94
|
-
const orgUnitsData = await dataEngine.query({
|
|
95
|
-
orgUnits: orgUnitsQuery
|
|
96
|
-
}, {
|
|
97
|
-
variables: {
|
|
98
|
-
displayNameProp
|
|
99
|
-
},
|
|
100
|
-
onError: _index.onError
|
|
101
|
-
});
|
|
102
|
-
return orgUnitsData.orgUnits.organisationUnits;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
exports.apiFetchOrganisationUnits = apiFetchOrganisationUnits;
|
|
106
|
-
|
|
107
|
-
const apiFetchOrganisationUnit = async (dataEngine, id) => {
|
|
108
|
-
const orgUnitData = await dataEngine.query({
|
|
109
|
-
orgUnit: orgUnitQuery
|
|
110
|
-
}, {
|
|
111
|
-
variables: {
|
|
112
|
-
id
|
|
113
|
-
},
|
|
114
|
-
onError: _index.onError
|
|
115
|
-
});
|
|
116
|
-
return orgUnitData.orgUnit;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
exports.apiFetchOrganisationUnit = apiFetchOrganisationUnit;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _enzyme = require("enzyme");
|
|
4
|
-
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _OrgUnitDimension = _interopRequireWildcard(require("../OrgUnitDimension"));
|
|
8
|
-
|
|
9
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
10
|
-
|
|
11
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
/* eslint-disable react/display-name */
|
|
16
|
-
jest.mock('@dhis2/d2-ui-org-unit-dialog', () => {
|
|
17
|
-
return {
|
|
18
|
-
OrgUnitSelector: () => /*#__PURE__*/_react.default.createElement("div", {
|
|
19
|
-
id: "mockOrgUnitSelector"
|
|
20
|
-
}, " mockOrgUnitSelector"),
|
|
21
|
-
userOrgUnits: [{
|
|
22
|
-
displayName: 'User organisation unit',
|
|
23
|
-
id: 'USER_ORGUNIT'
|
|
24
|
-
}, {
|
|
25
|
-
displayName: 'User sub-units',
|
|
26
|
-
id: 'USER_ORGUNIT_CHILDREN'
|
|
27
|
-
}, {
|
|
28
|
-
displayName: 'User sub-x2-units',
|
|
29
|
-
id: 'USER_ORGUNIT_GRANDCHILDREN'
|
|
30
|
-
}],
|
|
31
|
-
removeOrgUnitLastPathSegment: () => null
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
/* eslint-enable react/display-name */
|
|
35
|
-
|
|
36
|
-
jest.mock('../../../api/organisationUnits', () => {
|
|
37
|
-
return {
|
|
38
|
-
apiFetchOrganisationUnitGroups: () => Promise.resolve([{
|
|
39
|
-
displayName: 'CHC',
|
|
40
|
-
id: 'CXw2yu5fodb',
|
|
41
|
-
name: 'CHC'
|
|
42
|
-
}, {
|
|
43
|
-
displayName: 'Chiefdom',
|
|
44
|
-
id: 'gzcv65VyaGq',
|
|
45
|
-
name: 'Chiefdom'
|
|
46
|
-
}]),
|
|
47
|
-
apiFetchOrganisationUnitLevels: () => Promise.resolve([{
|
|
48
|
-
displayName: 'National',
|
|
49
|
-
id: 'H1KlN4QIauv',
|
|
50
|
-
level: 1,
|
|
51
|
-
name: 'National'
|
|
52
|
-
}, {
|
|
53
|
-
displayName: 'District',
|
|
54
|
-
id: 'wjP19dkFeIk',
|
|
55
|
-
level: 2,
|
|
56
|
-
name: 'District'
|
|
57
|
-
}]),
|
|
58
|
-
apiFetchOrganisationUnits: () => Promise.resolve({
|
|
59
|
-
toArray: () => {
|
|
60
|
-
return [{
|
|
61
|
-
id: 'jen'
|
|
62
|
-
}];
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
describe('The OrgUnitDimension component ', () => {
|
|
68
|
-
let props;
|
|
69
|
-
let shallowDataDim;
|
|
70
|
-
|
|
71
|
-
const orgUnitDimension = () => {
|
|
72
|
-
if (!shallowDataDim) {
|
|
73
|
-
shallowDataDim = (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_OrgUnitDimension.default, props));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return shallowDataDim;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
beforeEach(() => {
|
|
80
|
-
props = {
|
|
81
|
-
d2: {},
|
|
82
|
-
ouItems: [],
|
|
83
|
-
onSelect: jest.fn(),
|
|
84
|
-
onDeselect: jest.fn(),
|
|
85
|
-
current: {
|
|
86
|
-
id: null
|
|
87
|
-
},
|
|
88
|
-
displayNameProperty: 'displayName'
|
|
89
|
-
};
|
|
90
|
-
shallowDataDim = undefined;
|
|
91
|
-
});
|
|
92
|
-
it('has default state', () => {
|
|
93
|
-
const actualState = orgUnitDimension().state();
|
|
94
|
-
expect(actualState).toEqual(_OrgUnitDimension.defaultState);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { onError } from './index';
|
|
2
|
-
const orgUnitLevelsQuery = {
|
|
3
|
-
resource: 'organisationUnitLevels',
|
|
4
|
-
params: {
|
|
5
|
-
fields: 'id,level,displayName,name',
|
|
6
|
-
paging: false
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
const orgUnitGroupsQuery = {
|
|
10
|
-
resource: 'organisationUnitGroups',
|
|
11
|
-
params: ({
|
|
12
|
-
displayNameProp
|
|
13
|
-
}) => ({
|
|
14
|
-
fields: "id,".concat(displayNameProp, "~rename(displayName),name"),
|
|
15
|
-
paging: false
|
|
16
|
-
})
|
|
17
|
-
};
|
|
18
|
-
const orgUnitRootsQuery = {
|
|
19
|
-
resource: 'organisationUnits',
|
|
20
|
-
params: {
|
|
21
|
-
fields: 'id,displayName,name',
|
|
22
|
-
userDataViewFallback: true,
|
|
23
|
-
paging: false
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const orgUnitsQuery = {
|
|
27
|
-
resource: 'organisationUnits',
|
|
28
|
-
params: ({
|
|
29
|
-
displayNameProp
|
|
30
|
-
}) => ({
|
|
31
|
-
fields: "id,path,".concat(displayNameProp, "~rename(displayName),children::isNotEmpty"),
|
|
32
|
-
level: 1,
|
|
33
|
-
userDataViewFallback: true,
|
|
34
|
-
paging: false
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
const orgUnitQuery = {
|
|
38
|
-
resource: 'organisationUnits',
|
|
39
|
-
id: ({
|
|
40
|
-
id
|
|
41
|
-
}) => id,
|
|
42
|
-
params: {
|
|
43
|
-
fields: 'id,level,displayName~rename(name),path,parent[id,displayName~rename(name)],children[level]',
|
|
44
|
-
userDataViewFallback: true,
|
|
45
|
-
paging: false
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
export const apiFetchOrganisationUnitLevels = async dataEngine => {
|
|
49
|
-
const orgUnitLevelsData = await dataEngine.query({
|
|
50
|
-
orgUnitLevels: orgUnitLevelsQuery
|
|
51
|
-
}, {
|
|
52
|
-
onError
|
|
53
|
-
});
|
|
54
|
-
return orgUnitLevelsData.orgUnitLevels.organisationUnitLevels;
|
|
55
|
-
};
|
|
56
|
-
export const apiFetchOrganisationUnitGroups = async (dataEngine, displayNameProp) => {
|
|
57
|
-
const orgUnitGroupsData = await dataEngine.query({
|
|
58
|
-
orgUnitGroups: orgUnitGroupsQuery
|
|
59
|
-
}, {
|
|
60
|
-
variables: {
|
|
61
|
-
displayNameProp
|
|
62
|
-
},
|
|
63
|
-
onError
|
|
64
|
-
});
|
|
65
|
-
return orgUnitGroupsData.orgUnitGroups.organisationUnitGroups;
|
|
66
|
-
};
|
|
67
|
-
export const apiFetchOrganisationUnitRoots = async dataEngine => {
|
|
68
|
-
const orgUnitRootsData = await dataEngine.query({
|
|
69
|
-
orgUnitRoots: orgUnitRootsQuery
|
|
70
|
-
}, {
|
|
71
|
-
onError
|
|
72
|
-
});
|
|
73
|
-
return orgUnitRootsData.orgUnitRoots.organisationUnits;
|
|
74
|
-
};
|
|
75
|
-
export const apiFetchOrganisationUnits = async (dataEngine, displayNameProp) => {
|
|
76
|
-
const orgUnitsData = await dataEngine.query({
|
|
77
|
-
orgUnits: orgUnitsQuery
|
|
78
|
-
}, {
|
|
79
|
-
variables: {
|
|
80
|
-
displayNameProp
|
|
81
|
-
},
|
|
82
|
-
onError
|
|
83
|
-
});
|
|
84
|
-
return orgUnitsData.orgUnits.organisationUnits;
|
|
85
|
-
};
|
|
86
|
-
export const apiFetchOrganisationUnit = async (dataEngine, id) => {
|
|
87
|
-
const orgUnitData = await dataEngine.query({
|
|
88
|
-
orgUnit: orgUnitQuery
|
|
89
|
-
}, {
|
|
90
|
-
variables: {
|
|
91
|
-
id
|
|
92
|
-
},
|
|
93
|
-
onError
|
|
94
|
-
});
|
|
95
|
-
return orgUnitData.orgUnit;
|
|
96
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { shallow } from 'enzyme';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import OrgUnitDimension, { defaultState } from '../OrgUnitDimension';
|
|
4
|
-
/* eslint-disable react/display-name */
|
|
5
|
-
|
|
6
|
-
jest.mock('@dhis2/d2-ui-org-unit-dialog', () => {
|
|
7
|
-
return {
|
|
8
|
-
OrgUnitSelector: () => /*#__PURE__*/React.createElement("div", {
|
|
9
|
-
id: "mockOrgUnitSelector"
|
|
10
|
-
}, " mockOrgUnitSelector"),
|
|
11
|
-
userOrgUnits: [{
|
|
12
|
-
displayName: 'User organisation unit',
|
|
13
|
-
id: 'USER_ORGUNIT'
|
|
14
|
-
}, {
|
|
15
|
-
displayName: 'User sub-units',
|
|
16
|
-
id: 'USER_ORGUNIT_CHILDREN'
|
|
17
|
-
}, {
|
|
18
|
-
displayName: 'User sub-x2-units',
|
|
19
|
-
id: 'USER_ORGUNIT_GRANDCHILDREN'
|
|
20
|
-
}],
|
|
21
|
-
removeOrgUnitLastPathSegment: () => null
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
/* eslint-enable react/display-name */
|
|
25
|
-
|
|
26
|
-
jest.mock('../../../api/organisationUnits', () => {
|
|
27
|
-
return {
|
|
28
|
-
apiFetchOrganisationUnitGroups: () => Promise.resolve([{
|
|
29
|
-
displayName: 'CHC',
|
|
30
|
-
id: 'CXw2yu5fodb',
|
|
31
|
-
name: 'CHC'
|
|
32
|
-
}, {
|
|
33
|
-
displayName: 'Chiefdom',
|
|
34
|
-
id: 'gzcv65VyaGq',
|
|
35
|
-
name: 'Chiefdom'
|
|
36
|
-
}]),
|
|
37
|
-
apiFetchOrganisationUnitLevels: () => Promise.resolve([{
|
|
38
|
-
displayName: 'National',
|
|
39
|
-
id: 'H1KlN4QIauv',
|
|
40
|
-
level: 1,
|
|
41
|
-
name: 'National'
|
|
42
|
-
}, {
|
|
43
|
-
displayName: 'District',
|
|
44
|
-
id: 'wjP19dkFeIk',
|
|
45
|
-
level: 2,
|
|
46
|
-
name: 'District'
|
|
47
|
-
}]),
|
|
48
|
-
apiFetchOrganisationUnits: () => Promise.resolve({
|
|
49
|
-
toArray: () => {
|
|
50
|
-
return [{
|
|
51
|
-
id: 'jen'
|
|
52
|
-
}];
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
describe('The OrgUnitDimension component ', () => {
|
|
58
|
-
let props;
|
|
59
|
-
let shallowDataDim;
|
|
60
|
-
|
|
61
|
-
const orgUnitDimension = () => {
|
|
62
|
-
if (!shallowDataDim) {
|
|
63
|
-
shallowDataDim = shallow( /*#__PURE__*/React.createElement(OrgUnitDimension, props));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return shallowDataDim;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
beforeEach(() => {
|
|
70
|
-
props = {
|
|
71
|
-
d2: {},
|
|
72
|
-
ouItems: [],
|
|
73
|
-
onSelect: jest.fn(),
|
|
74
|
-
onDeselect: jest.fn(),
|
|
75
|
-
current: {
|
|
76
|
-
id: null
|
|
77
|
-
},
|
|
78
|
-
displayNameProperty: 'displayName'
|
|
79
|
-
};
|
|
80
|
-
shallowDataDim = undefined;
|
|
81
|
-
});
|
|
82
|
-
it('has default state', () => {
|
|
83
|
-
const actualState = orgUnitDimension().state();
|
|
84
|
-
expect(actualState).toEqual(defaultState);
|
|
85
|
-
});
|
|
86
|
-
});
|