@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.
Files changed (42) hide show
  1. package/build/cjs/__demo__/OrgUnitDimension.stories.js +104 -0
  2. package/build/cjs/api/organisationUnits.js +100 -46
  3. package/build/cjs/components/FileMenu/DeleteDialog.js +2 -2
  4. package/build/cjs/components/FileMenu/FileMenu.js +2 -2
  5. package/build/cjs/components/FileMenu/GetLinkDialog.js +2 -2
  6. package/build/cjs/components/FileMenu/RenameDialog.js +2 -2
  7. package/build/cjs/components/FileMenu/SaveAsDialog.js +2 -2
  8. package/build/cjs/components/OrgUnitDimension/OrgUnitDimension.js +223 -193
  9. package/build/cjs/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +5 -2
  10. package/build/cjs/components/PeriodDimension/FixedPeriodSelect.js +2 -2
  11. package/build/cjs/components/TransferOption.js +2 -2
  12. package/build/cjs/index.js +22 -4
  13. package/build/cjs/locales/en/translations.json +14 -0
  14. package/build/cjs/modules/list.js +25 -0
  15. package/build/cjs/modules/ouIdHelper/index.js +7 -1
  16. package/build/cjs/modules/relativeItems/index.js +1 -1
  17. package/build/cjs/visualizations/util/__tests__/getFilterText.spec.js +1 -1
  18. package/build/cjs/visualizations/util/getFilterText.js +1 -9
  19. package/build/es/__demo__/OrgUnitDimension.stories.js +93 -0
  20. package/build/es/api/organisationUnits.js +93 -43
  21. package/build/es/components/FileMenu/DeleteDialog.js +1 -1
  22. package/build/es/components/FileMenu/FileMenu.js +1 -1
  23. package/build/es/components/FileMenu/GetLinkDialog.js +1 -1
  24. package/build/es/components/FileMenu/RenameDialog.js +1 -1
  25. package/build/es/components/FileMenu/SaveAsDialog.js +1 -1
  26. package/build/es/components/OrgUnitDimension/OrgUnitDimension.js +224 -196
  27. package/build/es/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +3 -2
  28. package/build/es/components/PeriodDimension/FixedPeriodSelect.js +6 -6
  29. package/build/es/components/TransferOption.js +12 -12
  30. package/build/es/index.js +2 -2
  31. package/build/es/locales/en/translations.json +14 -0
  32. package/build/es/modules/list.js +13 -0
  33. package/build/es/modules/ouIdHelper/index.js +3 -0
  34. package/build/es/modules/relativeItems/index.js +2 -2
  35. package/build/es/visualizations/util/__tests__/getFilterText.spec.js +1 -1
  36. package/build/es/visualizations/util/getFilterText.js +2 -10
  37. package/package.json +3 -2
  38. package/CHANGELOG.md +0 -2763
  39. package/build/cjs/api/organisationUnits-dataEngine.js +0 -119
  40. package/build/cjs/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js +0 -96
  41. package/build/es/api/organisationUnits-dataEngine.js +0 -96
  42. package/build/es/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js +0 -86
@@ -31,15 +31,7 @@ function _default(filters, metaData) {
31
31
  }) => _ouIdHelper.ouIdHelper.hasGroupPrefix(id) || _ouIdHelper.ouIdHelper.hasLevelPrefix(id))) {
32
32
  titleFragments.push((0, _getOuLevelAndGroupText.getOuLevelAndGroupText)(filter, metaData));
33
33
  } else {
34
- let filterItems = [];
35
-
36
- if ((0, _dimensionIs.dimensionIs)(filter, _predefinedDimensions.DIMENSION_ID_PERIOD)) {
37
- filterItems = items.map(({
38
- id
39
- }) => id);
40
- } else {
41
- filterItems = metaData.dimensions[filter.dimension];
42
- }
34
+ const filterItems = metaData.dimensions[filter.dimension];
43
35
 
44
36
  if (Array.isArray(filterItems)) {
45
37
  l = filterItems.length;
@@ -0,0 +1,93 @@
1
+ import { DataProvider } from '@dhis2/app-runtime';
2
+ import { storiesOf } from '@storybook/react';
3
+ import React, { useState } from 'react';
4
+ import OrgUnitDimension from '../components/OrgUnitDimension/OrgUnitDimension';
5
+
6
+ const Wrapper = story => /*#__PURE__*/React.createElement(DataProvider, {
7
+ baseUrl: "http://localhost:8080/",
8
+ apiVersion: ""
9
+ }, story());
10
+
11
+ const defaultRootOrgUnits = ['ImspTQPwCqd']; // Sierra Leone
12
+
13
+ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('None selected', () => {
14
+ const [selected, setSelected] = useState([]);
15
+ return /*#__PURE__*/React.createElement(OrgUnitDimension, {
16
+ selected: selected,
17
+ onSelect: response => setSelected(response.items),
18
+ roots: defaultRootOrgUnits
19
+ });
20
+ });
21
+ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Root selected', () => {
22
+ const [selected, setSelected] = useState([{
23
+ id: 'ImspTQPwCqd',
24
+ path: '/ImspTQPwCqd',
25
+ name: 'Sierra Leone'
26
+ }]);
27
+ return /*#__PURE__*/React.createElement(OrgUnitDimension, {
28
+ selected: selected,
29
+ onSelect: response => setSelected(response.items),
30
+ roots: defaultRootOrgUnits
31
+ });
32
+ });
33
+ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Single level 2 child selected', () => {
34
+ const [selected, setSelected] = useState([{
35
+ id: 'fdc6uOvgoji',
36
+ path: '/ImspTQPwCqd/fdc6uOvgoji',
37
+ name: 'Bombali'
38
+ }]);
39
+ return /*#__PURE__*/React.createElement(OrgUnitDimension, {
40
+ selected: selected,
41
+ onSelect: response => setSelected(response.items),
42
+ roots: defaultRootOrgUnits
43
+ });
44
+ });
45
+ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Multiple level 2 children selected', () => {
46
+ const [selected, setSelected] = useState([{
47
+ id: 'O6uvpzGd5pu',
48
+ path: '/ImspTQPwCqd/O6uvpzGd5pu',
49
+ name: 'Bo'
50
+ }, {
51
+ id: 'fdc6uOvgoji',
52
+ path: '/ImspTQPwCqd/fdc6uOvgoji',
53
+ name: 'Bombali'
54
+ }, {
55
+ id: 'lc3eMKXaEfw',
56
+ path: '/ImspTQPwCqd/lc3eMKXaEfw',
57
+ name: 'Bonthe'
58
+ }]);
59
+ return /*#__PURE__*/React.createElement(OrgUnitDimension, {
60
+ selected: selected,
61
+ onSelect: response => setSelected(response.items),
62
+ roots: defaultRootOrgUnits
63
+ });
64
+ });
65
+ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Multiple selected across different levels', () => {
66
+ const [selected, setSelected] = useState([{
67
+ id: 'fdc6uOvgoji',
68
+ path: '/ImspTQPwCqd/fdc6uOvgoji',
69
+ name: 'Bombali'
70
+ }, {
71
+ id: 'KKkLOTpMXGV',
72
+ path: '/ImspTQPwCqd/fdc6uOvgoji/KKkLOTpMXGV',
73
+ name: 'Bombali Sebora'
74
+ }, {
75
+ id: 'GQcsUZf81vP',
76
+ path: '/ImspTQPwCqd/fdc6uOvgoji/KKkLOTpMXGV/GQcsUZf81vP',
77
+ name: 'Govt. Hosp. Makeni'
78
+ }]);
79
+ return /*#__PURE__*/React.createElement(OrgUnitDimension, {
80
+ selected: selected,
81
+ onSelect: response => setSelected(response.items),
82
+ roots: defaultRootOrgUnits
83
+ });
84
+ });
85
+ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Multiple roots', () => {
86
+ const [selected, setSelected] = useState([]);
87
+ return /*#__PURE__*/React.createElement(OrgUnitDimension, {
88
+ selected: selected,
89
+ onSelect: response => setSelected(response.items),
90
+ roots: ['O6uvpzGd5pu', 'fdc6uOvgoji'] // Bo + Bombali
91
+
92
+ });
93
+ });
@@ -1,49 +1,99 @@
1
1
  import { onError } from './index';
2
- export const apiFetchOrganisationUnitRoot = d2 => {
3
- const endPoint = '/organisationUnits';
4
- const fields = ['id', 'displayName', 'name'];
5
- const url = "".concat(endPoint, "?paging=false&userDataViewFallback=true&fields=").concat(fields.join(','));
6
- return d2.Api.getApi().get(url).then(({
7
- organisationUnits
8
- }) => organisationUnits[0]).catch(onError);
9
- };
10
- /**
11
- * Fetch organisation units
12
- * @returns {Promise<T | never>}
13
- */
14
-
15
- export const apiFetchOrganisationUnits = (d2, displayNameProperty) => {
16
- const fields = ['id', 'path', "".concat(displayNameProperty, "~rename(displayName)"), 'children::isNotEmpty'];
17
- return d2.models.organisationUnits.list({
18
- paging: false,
2
+ const orgUnitLevelsQuery = {
3
+ resource: 'organisationUnitLevels',
4
+ params: ({
5
+ displayNameProp = 'displayName'
6
+ }) => ({
7
+ fields: "id,level,".concat(displayNameProp, "~rename(displayName),name"),
8
+ paging: false
9
+ })
10
+ };
11
+ const orgUnitGroupsQuery = {
12
+ resource: 'organisationUnitGroups',
13
+ params: ({
14
+ displayNameProp = 'displayName'
15
+ }) => ({
16
+ fields: "id,".concat(displayNameProp, "~rename(displayName),name"),
17
+ paging: false
18
+ })
19
+ };
20
+ const orgUnitRootsQuery = {
21
+ resource: 'organisationUnits',
22
+ params: {
23
+ fields: 'id,displayName,name',
24
+ userDataViewFallback: true,
25
+ paging: false
26
+ }
27
+ };
28
+ const orgUnitsQuery = {
29
+ resource: 'organisationUnits',
30
+ params: ({
31
+ displayNameProp
32
+ }) => ({
33
+ fields: "id,path,".concat(displayNameProp, "~rename(displayName),children::isNotEmpty"),
19
34
  level: 1,
20
- fields: fields.join(','),
21
- userDataViewFallback: true
35
+ userDataViewFallback: true,
36
+ paging: false
37
+ })
38
+ };
39
+ const orgUnitQuery = {
40
+ resource: 'organisationUnits',
41
+ id: ({
42
+ id
43
+ }) => id,
44
+ params: {
45
+ fields: 'id,level,displayName~rename(name),path,parent[id,displayName~rename(name)],children[level]',
46
+ userDataViewFallback: true,
47
+ paging: false
48
+ }
49
+ };
50
+ export const apiFetchOrganisationUnitLevels = async dataEngine => {
51
+ const orgUnitLevelsData = await dataEngine.query({
52
+ orgUnitLevels: orgUnitLevelsQuery
53
+ }, {
54
+ onError
22
55
  });
56
+ return orgUnitLevelsData.orgUnitLevels.organisationUnitLevels;
23
57
  };
24
- /**
25
- * Fetch organisation unit groups
26
- * @returns {*}
27
- */
28
-
29
- export const apiFetchOrganisationUnitGroups = (d2, displayNameProperty) => {
30
- const endPoint = '/organisationUnitGroups';
31
- const fields = ['id', "".concat(displayNameProperty, "~rename(displayName)"), 'name'];
32
- const url = "".concat(endPoint, "?paging=false&fields=").concat(fields.join(','));
33
- return d2.Api.getApi().get(url).then(({
34
- organisationUnitGroups
35
- }) => organisationUnitGroups).catch(onError);
36
- };
37
- /**
38
- * Fetch organisation unit levels
39
- * @returns {*}
40
- */
58
+ export const apiFetchOrganisationUnitGroups = async (dataEngine, displayNameProp) => {
59
+ const orgUnitGroupsData = await dataEngine.query({
60
+ orgUnitGroups: orgUnitGroupsQuery
61
+ }, {
62
+ variables: {
63
+ displayNameProp
64
+ },
65
+ onError
66
+ });
67
+ return orgUnitGroupsData.orgUnitGroups.organisationUnitGroups;
68
+ };
69
+ export const apiFetchOrganisationUnitRoots = async dataEngine => {
70
+ const orgUnitRootsData = await dataEngine.query({
71
+ orgUnitRoots: orgUnitRootsQuery
72
+ }, {
73
+ onError
74
+ });
75
+ return orgUnitRootsData.orgUnitRoots.organisationUnits;
76
+ }; // TODO: Unused, previously used to load all org units for the tree, but that is done by the ui component internally now, remove?
41
77
 
42
- export const apiFetchOrganisationUnitLevels = d2 => {
43
- const endPoint = '/organisationUnitLevels';
44
- const fields = ['id', 'displayName', 'name', 'level'];
45
- const url = "".concat(endPoint, "?paging=false&fields=").concat(fields.join(','));
46
- return d2.Api.getApi().get(url).then(({
47
- organisationUnitLevels
48
- }) => organisationUnitLevels).catch(onError);
78
+ export const apiFetchOrganisationUnits = async (dataEngine, displayNameProp) => {
79
+ const orgUnitsData = await dataEngine.query({
80
+ orgUnits: orgUnitsQuery
81
+ }, {
82
+ variables: {
83
+ displayNameProp
84
+ },
85
+ onError
86
+ });
87
+ return orgUnitsData.orgUnits.organisationUnits;
88
+ };
89
+ export const apiFetchOrganisationUnit = async (dataEngine, id) => {
90
+ const orgUnitData = await dataEngine.query({
91
+ orgUnit: orgUnitQuery
92
+ }, {
93
+ variables: {
94
+ id
95
+ },
96
+ onError
97
+ });
98
+ return orgUnitData.orgUnit;
49
99
  };
@@ -1,6 +1,6 @@
1
1
  import { useDataMutation } from '@dhis2/app-runtime';
2
- import PropTypes from '@dhis2/prop-types';
3
2
  import { Modal, ModalTitle, ModalContent, ModalActions, ButtonStrip, Button } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
4
  import React, { useMemo } from 'react';
5
5
  import i18n from '../../locales/index.js';
6
6
  import { supportedFileTypes, endpointFromFileType } from './utils';
@@ -1,7 +1,7 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
2
  import TranslationDialog from '@dhis2/d2-ui-translation-dialog';
3
- import PropTypes from '@dhis2/prop-types';
4
3
  import { IconAdd24, IconLaunch24, IconSave24, IconEdit24, IconTranslate24, IconShare24, IconLink24, IconDelete24, SharingDialog, colors, FlyoutMenu, Layer, MenuItem, MenuDivider, Popper } from '@dhis2/ui';
4
+ import PropTypes from 'prop-types';
5
5
  import React, { createRef, useState } from 'react';
6
6
  import i18n from '../../locales/index.js';
7
7
  import { OpenFileDialog } from '../OpenFileDialog/OpenFileDialog';
@@ -1,6 +1,6 @@
1
1
  import { useConfig } from '@dhis2/app-runtime';
2
- import PropTypes from '@dhis2/prop-types';
3
2
  import { Modal, ModalContent, ModalActions, ButtonStrip, Button } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import i18n from '../../locales/index.js';
6
6
  import { supportedFileTypes, appPathFor } from './utils';
@@ -1,6 +1,6 @@
1
1
  import { useDataMutation } from '@dhis2/app-runtime';
2
- import PropTypes from '@dhis2/prop-types';
3
2
  import { Modal, ModalTitle, ModalContent, ModalActions, ButtonStrip, Button, InputField, TextAreaField } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
4
  import React, { useMemo, useState } from 'react';
5
5
  import i18n from '../../locales/index.js';
6
6
  import { supportedFileTypes, endpointFromFileType } from './utils';
@@ -1,5 +1,5 @@
1
- import PropTypes from '@dhis2/prop-types';
2
1
  import { Modal, ModalTitle, ModalContent, ModalActions, ButtonStrip, Button, InputField, TextAreaField } from '@dhis2/ui';
2
+ import PropTypes from 'prop-types';
3
3
  import React, { useState } from 'react';
4
4
  import i18n from '../../locales/index.js';
5
5
  import { supportedFileTypes } from './utils';