From dc3ee9ccedcffde9cf75cb0e1d2fed04cd1e79a9 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Wed, 24 Apr 2024 13:51:56 +0200 Subject: [PATCH] fix: short name was not being shown in charts (#2958) Fixes: https://dhis2.atlassian.net/browse/DHIS2-12499 DV plugin fix: the plugin does not accept a userSettings prop. It expects a displayProperty of either displayName or displayShortName. LL plugin (IFramePlugin): expects displayProperty of name or shortName. The FIlterDialog and useDimensions expect 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 b743a76bd..55ed3441a 100644 --- a/src/components/Item/VisualizationItem/Visualization/IframePlugin.js +++ b/src/components/Item/VisualizationItem/Visualization/IframePlugin.js @@ -53,7 +53,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, + dataEngine, + dispatch, + ]) 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} /> ) }