Skip to content

Commit

Permalink
fix: dimensions as array (DHIS2-7787) (#526)
Browse files Browse the repository at this point in the history
* fix: updated handling of dimensions to match latest Analytics

* fix: upgraded to Analytics v2.8.3
  • Loading branch information
martinkrulltott authored Jan 21, 2020
1 parent 1fef3e3 commit 3647034
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions src/actions/dimensions.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FilterBar/FilterBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions src/components/ItemFilter/FilterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/components/ItemFilter/FilterSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
19 changes: 10 additions & 9 deletions src/reducers/dimensions.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
65 changes: 58 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 3647034

Please sign in to comment.