From c0fc1d68b3fae20c1dcd3e5912a26e745fb015cb Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Tue, 23 Apr 2024 13:46:55 +0200 Subject: [PATCH] fix: short name was not being shown in visualizations (#2959) 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'. --- .../Visualization/IframePlugin.js | 2 +- src/components/UserSettingsProvider.js | 7 +++++-- src/modules/useDimensions.js | 16 +++++++++------- src/pages/view/TitleBar/FilterDialog.js | 4 +--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/Item/VisualizationItem/Visualization/IframePlugin.js b/src/components/Item/VisualizationItem/Visualization/IframePlugin.js index 79ba21c38..545cf3af2 100644 --- a/src/components/Item/VisualizationItem/Visualization/IframePlugin.js +++ b/src/components/Item/VisualizationItem/Visualization/IframePlugin.js @@ -66,7 +66,7 @@ const IframePlugin = ({ () => ({ isVisualizationLoaded: true, forDashboard: true, - displayProperty: userSettings.displayProperty, + displayProperty: userSettings.keyAnalysisDisplayProperty, visualization, onError, diff --git a/src/components/UserSettingsProvider.js b/src/components/UserSettingsProvider.js index 393a9eb31..1be994286 100644 --- a/src/components/UserSettingsProvider.js +++ b/src/components/UserSettingsProvider.js @@ -17,11 +17,14 @@ const UserSettingsProvider = ({ children }) => { setSettings({ ...userSettings, - displayProperty: userSettings.keyAnalysisDisplayProperty, + displayProperty: + userSettings.keyAnalysisDisplayProperty === 'name' + ? 'displayName' + : 'displayShortName', }) } fetchData() - }, []) + }, [engine]) return ( { try { const unfilteredDimensions = await apiFetchDimensions( dataEngine, - userSettings.keyAnalysisDisplayProperty + userSettings.displayProperty ) dispatch( @@ -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 } diff --git a/src/pages/view/TitleBar/FilterDialog.js b/src/pages/view/TitleBar/FilterDialog.js index 0cb807089..10e15b1aa 100644 --- a/src/pages/view/TitleBar/FilterDialog.js +++ b/src/pages/view/TitleBar/FilterDialog.js @@ -119,9 +119,7 @@ const FilterDialog = ({ dimensionId={dimension.id} onSelect={onSelectItems} dimensionTitle={dimension.name} - displayNameProp={ - userSettings.keyAnalysisDisplayProperty - } + displayNameProp={userSettings.displayProperty} /> ) }