From 36470341071abd5bf8bbf1e0660579e13af058cb Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 21 Jan 2020 16:07:27 +0530 Subject: [PATCH] fix: dimensions as array (DHIS2-7787) (#526) * fix: updated handling of dimensions to match latest Analytics * fix: upgraded to Analytics v2.8.3 --- package.json | 2 +- src/actions/dimensions.js | 4 +- src/components/FilterBar/FilterBar.js | 2 +- src/components/ItemFilter/FilterDialog.js | 7 ++- src/components/ItemFilter/FilterSelector.js | 7 +-- src/reducers/dimensions.js | 19 +++--- yarn.lock | 65 ++++++++++++++++++--- 7 files changed, 78 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index a6c6b3190..be303f7fc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "private": true, "license": "BSD-3-Clause", "dependencies": { - "@dhis2/analytics": "^2.6.14", + "@dhis2/analytics": "^2.8.3", "@dhis2/app-runtime": "^2.0.3", "@dhis2/d2-i18n": "^1.0.6", "@dhis2/d2-ui-core": "^6.0.1", diff --git a/src/actions/dimensions.js b/src/actions/dimensions.js index e17e9f8c5..a2be23e63 100644 --- a/src/actions/dimensions.js +++ b/src/actions/dimensions.js @@ -1,12 +1,10 @@ -import keyBy from 'lodash/keyBy'; -import sortBy from 'lodash/sortBy'; import { SET_DIMENSIONS } from '../reducers/dimensions'; import { apiFetchDimensions } from '@dhis2/analytics'; import { sGetSettingsDisplayNameProperty } from '../reducers/settings'; export const acSetDimensions = dimensions => ({ type: SET_DIMENSIONS, - value: keyBy(sortBy(dimensions, [d => d.name.toLowerCase()]), 'id'), + value: dimensions, }); export const tSetDimensions = d2 => async (dispatch, getState) => { diff --git a/src/components/FilterBar/FilterBar.js b/src/components/FilterBar/FilterBar.js index 880b884d6..534b1c2ae 100644 --- a/src/components/FilterBar/FilterBar.js +++ b/src/components/FilterBar/FilterBar.js @@ -80,7 +80,7 @@ const filtersSelector = createSelector( Object.keys(filters).reduce((arr, id) => { arr.push({ id: id, - name: dimensions[id].name, + name: dimensions.find(dimension => dimension.id === id).name, values: filters[id].map(value => ({ id: value.id, name: value.displayName || value.name, diff --git a/src/components/ItemFilter/FilterDialog.js b/src/components/ItemFilter/FilterDialog.js index 0d744f40f..b85ba7c44 100644 --- a/src/components/ItemFilter/FilterDialog.js +++ b/src/components/ItemFilter/FilterDialog.js @@ -11,11 +11,12 @@ import { PeriodDimension, DynamicDimension, OrgUnitDimension, - FIXED_DIMENSIONS, + DIMENSION_ID_PERIOD, + DIMENSION_ID_ORGUNIT, } from '@dhis2/analytics'; -const peId = FIXED_DIMENSIONS.pe.id; -const ouId = FIXED_DIMENSIONS.ou.id; +const peId = DIMENSION_ID_PERIOD; +const ouId = DIMENSION_ID_ORGUNIT; class FilterDialog extends Component { onConfirm = id => () => this.props.onConfirm(id); diff --git a/src/components/ItemFilter/FilterSelector.js b/src/components/ItemFilter/FilterSelector.js index 6c474cd3e..5c20b943e 100644 --- a/src/components/ItemFilter/FilterSelector.js +++ b/src/components/ItemFilter/FilterSelector.js @@ -50,10 +50,9 @@ class FilterSelector extends Component { }; selectDimension = id => { - this.props.setActiveModalDimension({ - id, - name: this.props.dimensions[id].name, - }); + this.props.setActiveModalDimension( + this.props.dimensions.find(dimension => dimension.id === id) + ); }; onSelectItems = ({ dimensionId, items }) => { diff --git a/src/reducers/dimensions.js b/src/reducers/dimensions.js index 1a0c3db00..1ef192c70 100644 --- a/src/reducers/dimensions.js +++ b/src/reducers/dimensions.js @@ -1,18 +1,19 @@ -import { FIXED_DIMENSIONS } from '@dhis2/analytics'; +import { + getDimensionById, + DIMENSION_ID_PERIOD, + DIMENSION_ID_ORGUNIT, +} from '@dhis2/analytics'; export const SET_DIMENSIONS = 'SET_DIMENSIONS'; -export const DEFAULT_DIMENSIONS = { - pe: FIXED_DIMENSIONS.pe, - ou: FIXED_DIMENSIONS.ou, -}; +export const DEFAULT_DIMENSIONS = [ + getDimensionById(DIMENSION_ID_PERIOD), + getDimensionById(DIMENSION_ID_ORGUNIT), +]; export default (state = DEFAULT_DIMENSIONS, action) => { switch (action.type) { case SET_DIMENSIONS: { - return { - ...DEFAULT_DIMENSIONS, - ...action.value, - }; + return [...DEFAULT_DIMENSIONS, ...action.value]; } default: return state; diff --git a/yarn.lock b/yarn.lock index 84f7efd90..d2609d6c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1192,15 +1192,15 @@ react-beautiful-dnd "^10.1.1" styled-jsx "^3.2.1" -"@dhis2/analytics@^2.6.14": - version "2.6.14" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-2.6.14.tgz#26a5fc362b1258a3428953a38d5044ed40616467" - integrity sha512-TbAFEFsp2XLa8IIJLlDyRPlQfeoBLqq4rFBrZf9U0kJCpElmma6dI9Parchkb1fiQg/7CjYf3uG0a6xMIS36ag== +"@dhis2/analytics@^2.8.3": + version "2.8.3" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-2.8.3.tgz#062118d257c29d5e28cf4bf035842f112b9eef41" + integrity sha512-bF38HNa6vL9JcJApSPE1KvLAb8M3p1nh/ymtcD6ULIhnTTqKy9eOaiz8hulH2NYRG+aJkXFNtp46OhmQGTZ7Ng== dependencies: "@dhis2/d2-i18n" "^1.0.4" - "@dhis2/d2-ui-org-unit-dialog" "^6.3.0" - "@dhis2/d2-ui-period-selector-dialog" "^6.3.0" - "@dhis2/ui-core" "^3.4.0" + "@dhis2/d2-ui-org-unit-dialog" "^6.3.2" + "@dhis2/d2-ui-period-selector-dialog" "^6.3.2" + "@dhis2/ui-core" "^4.1.1" "@material-ui/core" "^3.9.3" "@material-ui/icons" "^3.0.2" classnames "^2.2.6" @@ -1323,6 +1323,16 @@ lodash "^4.17.10" material-ui "^0.20.0" +"@dhis2/d2-ui-core@6.5.0": + version "6.5.0" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-core/-/d2-ui-core-6.5.0.tgz#fe83f664343f631525fa8c6046bcdfcd640ac4ca" + integrity sha512-t/BlaqJyyAPf94WUHrbLPuY1sWcB7DYUxM5H7o4yW3LySNHFAwXyQrRw2W38c5aUB1itFb/XDVA51QttC8bvYA== + dependencies: + babel-runtime "^6.26.0" + d2 "~31.7" + lodash "^4.17.10" + material-ui "^0.20.0" + "@dhis2/d2-ui-interpretations@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-interpretations/-/d2-ui-interpretations-6.0.1.tgz#bcfa9efda51c90879b32209272808057d342d6f0" @@ -1375,6 +1385,17 @@ "@material-ui/icons" "^3.0.1" prop-types "^15.5.10" +"@dhis2/d2-ui-org-unit-dialog@^6.3.2": + version "6.5.0" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-org-unit-dialog/-/d2-ui-org-unit-dialog-6.5.0.tgz#e0027fbb0c7fb977061b0ea9a55d454766bbc8bf" + integrity sha512-vrkpiS3dkizKu4dWXs9xmZboi9wrlI34nYjSqqZioGI069rUaei7CR/Fks92efIYu66vlzHV6JSCckV+TAVtXw== + dependencies: + "@dhis2/d2-i18n" "^1.0.3" + "@dhis2/d2-ui-org-unit-tree" "6.5.0" + "@material-ui/core" "^3.3.1" + "@material-ui/icons" "^3.0.1" + prop-types "^15.5.10" + "@dhis2/d2-ui-org-unit-tree@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-org-unit-tree/-/d2-ui-org-unit-tree-6.1.0.tgz#6604cf93c9d11395e157bdee8ca44133e36673df" @@ -1395,6 +1416,16 @@ babel-runtime "^6.26.0" prop-types "^15.5.10" +"@dhis2/d2-ui-org-unit-tree@6.5.0": + version "6.5.0" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-org-unit-tree/-/d2-ui-org-unit-tree-6.5.0.tgz#e16409ec3ae454132fed09fa0a13ac25b03ca986" + integrity sha512-D/nPBSisETN0qf120/30g7NYmAM8iFDKkSOSABdYS9hL5yZEF8zaReezdJnV36gTxDZcR51/b36Lh4Lzc6OgTQ== + dependencies: + "@dhis2/d2-ui-core" "6.5.0" + "@material-ui/core" "^3.3.1" + babel-runtime "^6.26.0" + prop-types "^15.5.10" + "@dhis2/d2-ui-period-selector-dialog@^6.2.0": version "6.2.1" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-period-selector-dialog/-/d2-ui-period-selector-dialog-6.2.1.tgz#e2345e1a7a3095c18fba9a893bbac6042cd037a7" @@ -1419,6 +1450,18 @@ babel-runtime "^6.26.0" prop-types "^15.6.0" +"@dhis2/d2-ui-period-selector-dialog@^6.3.2": + version "6.5.0" + resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-period-selector-dialog/-/d2-ui-period-selector-dialog-6.5.0.tgz#41ee143bf2e014fd001130655f26bcbc825cdc9b" + integrity sha512-dGTl98qmk8p3eBqW9TZdmHGUwSdp2HqYqETFe9SkET7vQJdNxG2AeUpXW4vQYi22G1ppe7PnFNqdCwVm++xQVQ== + dependencies: + "@dhis2/analytics" "^2.1.0" + "@dhis2/d2-i18n" "^1.0.4" + "@material-ui/core" "^3.3.1" + "@material-ui/icons" "^3.0.1" + babel-runtime "^6.26.0" + prop-types "^15.6.0" + "@dhis2/d2-ui-rich-text@6.0.1", "@dhis2/d2-ui-rich-text@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-rich-text/-/d2-ui-rich-text-6.0.1.tgz#6a57dbbc6586161cd64eda9b4f24a8de67c92dea" @@ -1525,6 +1568,14 @@ classnames "^2.2.6" styled-jsx "^3.2.4" +"@dhis2/ui-core@^4.1.1": + version "4.6.1" + resolved "https://registry.yarnpkg.com/@dhis2/ui-core/-/ui-core-4.6.1.tgz#62677590b3b32322dfa014b006e6226b637f0162" + integrity sha512-85ubddhmSRjDFPZqtSoTOZiPnfzHU1CyFyTXYmar/3lr8zl4mzY7aKScsEsTtJRWpN8ie86LWRqdGpbrV98VcQ== + dependencies: + "@dhis2/prop-types" "^1.5.0" + classnames "^2.2.6" + "@dhis2/ui-widgets@^2.0.5": version "2.0.5" resolved "https://registry.yarnpkg.com/@dhis2/ui-widgets/-/ui-widgets-2.0.5.tgz#78cc6300d57b633e796bff7856c27445ea315767"