Skip to content

Commit

Permalink
fix: short name was not being shown in visualizations (#2959)
Browse files Browse the repository at this point in the history
Fixes: https://dhis2.atlassian.net/browse/DHIS2-12499

The plugin was changed and now just directly uses the value of the displayProperty.
Analytics requests expects 'name' or 'shortName'.
Meanwhile, fetching dimensions and dimensionItems still expects 'displayName'
or 'displayShortName'.
  • Loading branch information
jenniferarnesen committed Apr 23, 2024
1 parent 3651a71 commit c0fc1d6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const IframePlugin = ({
() => ({
isVisualizationLoaded: true,
forDashboard: true,
displayProperty: userSettings.displayProperty,
displayProperty: userSettings.keyAnalysisDisplayProperty,
visualization,
onError,

Expand Down
7 changes: 5 additions & 2 deletions src/components/UserSettingsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ const UserSettingsProvider = ({ children }) => {

setSettings({
...userSettings,
displayProperty: userSettings.keyAnalysisDisplayProperty,
displayProperty:
userSettings.keyAnalysisDisplayProperty === 'name'
? 'displayName'
: 'displayShortName',
})
}
fetchData()
}, [])
}, [engine])

return (
<UserSettingsCtx.Provider
Expand Down
16 changes: 9 additions & 7 deletions src/modules/useDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const useDimensions = (doFetch) => {
try {
const unfilteredDimensions = await apiFetchDimensions(
dataEngine,
userSettings.keyAnalysisDisplayProperty
userSettings.displayProperty
)

dispatch(
Expand All @@ -28,14 +28,16 @@ const useDimensions = (doFetch) => {
}
}

if (
!dimensions.length &&
doFetch &&
userSettings.keyAnalysisDisplayProperty
) {
if (!dimensions.length && doFetch && userSettings.displayProperty) {
fetchDimensions()
}
}, [dimensions, doFetch, userSettings.keyAnalysisDisplayProperty])
}, [
dimensions,
doFetch,
userSettings.displayProperty,
dispatch,
dataEngine,
])

return dimensions
}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/view/TitleBar/FilterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ const FilterDialog = ({
dimensionId={dimension.id}
onSelect={onSelectItems}
dimensionTitle={dimension.name}
displayNameProp={
userSettings.keyAnalysisDisplayProperty
}
displayNameProp={userSettings.displayProperty}
/>
)
}
Expand Down

0 comments on commit c0fc1d6

Please sign in to comment.