Skip to content

Commit

Permalink
fix(filters): filter the list of dimensions usable as filters (#287)
Browse files Browse the repository at this point in the history
Only show dimensions of type CATEGORY where data dimension type is
ATTRIBUTE.
  • Loading branch information
edoardo authored Apr 24, 2019
1 parent 9419d28 commit 6569200
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "BSD-3-Clause",
"dependencies": {
"@dhis2/d2-i18n": "^1.0.4",
"@dhis2/d2-ui-analytics": "^0.0.9",
"@dhis2/d2-ui-analytics": "^0.0.18",
"@dhis2/d2-ui-core": "^5.2.9",
"@dhis2/d2-ui-interpretations": "^5.2.10",
"@dhis2/d2-ui-mentions-wrapper": "^5.2.9",
Expand Down
10 changes: 9 additions & 1 deletion src/actions/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ export const tSetDimensions = d2 => async (dispatch, getState) => {
try {
const displayNameProp = sGetSettingsDisplayNameProperty(getState());
const dimensions = await apiFetchDimensions(d2, displayNameProp);
return onSuccess(dimensions);

// filter out CATEGORY that are not of type ATTRIBUTE
const filteredDimensions = dimensions.filter(
dim =>
dim.dimensionType !== 'CATEGORY' ||
(dim.dimensionType === 'CATEGORY' &&
dim.dataDimensionType === 'ATTRIBUTE')
);
return onSuccess(filteredDimensions);
} catch (err) {
return onError(err);
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,10 @@
dependencies:
i18next "^10.3"

"@dhis2/d2-ui-analytics@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-analytics/-/d2-ui-analytics-0.0.9.tgz#4c2baa7dc941f9219d35da08287b676a57eb2cb8"
integrity sha512-wwfu9SPhJrbxgbmICKVX2WE6EphTovA8up8EBBSW5+2BgYV1262VVssXj5XboCsXxxbA35x6zvGa1KxT0+yHog==
"@dhis2/d2-ui-analytics@^0.0.18":
version "0.0.18"
resolved "https://registry.yarnpkg.com/@dhis2/d2-ui-analytics/-/d2-ui-analytics-0.0.18.tgz#1d512a870ccd055197fdefb7302138426a9a79a6"
integrity sha512-9EIXHIxK5IOPGHM+DC4aHWd/Be249h0xGL24k4hgzRyxUYBI1uRXxo4Ckn0FcUOI2GkSxMbGdf3uw5sP80AkTg==
dependencies:
"@dhis2/d2-i18n" "^1.0.4"
"@dhis2/d2-ui-org-unit-dialog" "5.3.1"
Expand Down

0 comments on commit 6569200

Please sign in to comment.