diff --git a/src/components/DataDimension/Info/CalculationInfo.js b/src/components/DataDimension/Info/CalculationInfo.js
index 0f6f175c1..632ef6e08 100644
--- a/src/components/DataDimension/Info/CalculationInfo.js
+++ b/src/components/DataDimension/Info/CalculationInfo.js
@@ -3,7 +3,11 @@ import PropTypes from 'prop-types'
import React, { useCallback, useEffect, useState } from 'react'
import { validateIndicatorExpressionMutation } from '../../../api/expression.js'
import i18n from '../../../locales/index.js'
-import { getCommonFields, InfoTable } from './InfoTable.js'
+import {
+ getCommonFields,
+ renderHumanReadableExpression,
+ InfoTable,
+} from './InfoTable.js'
import styles from './styles/InfoPopover.style.js'
const calculationQuery = {
@@ -40,8 +44,8 @@ export const CalculationInfo = ({ id, displayNameProp }) => {
expression: calculation.expression,
})
- if (result?.description) {
- calculation.humanReadableExpression = result.description
+ if (result) {
+ calculation.humanReadableExpression = result
}
}
@@ -66,9 +70,9 @@ export const CalculationInfo = ({ id, displayNameProp }) => {
{i18n.t('Expression description')} |
{data?.calculation.humanReadableExpression ? (
-
- {data.calculation.humanReadableExpression}
-
+ renderHumanReadableExpression(
+ data.calculation.humanReadableExpression
+ )
) : (
{i18n.t('None')}
)}
diff --git a/src/components/DataDimension/Info/IndicatorInfo.js b/src/components/DataDimension/Info/IndicatorInfo.js
index 602e6be27..690e28dfa 100644
--- a/src/components/DataDimension/Info/IndicatorInfo.js
+++ b/src/components/DataDimension/Info/IndicatorInfo.js
@@ -3,7 +3,11 @@ import PropTypes from 'prop-types'
import React, { useCallback, useEffect, useState } from 'react'
import { validateIndicatorExpressionMutation } from '../../../api/expression.js'
import i18n from '../../../locales/index.js'
-import { getCommonFields, InfoTable } from './InfoTable.js'
+import {
+ getCommonFields,
+ renderHumanReadableExpression,
+ InfoTable,
+} from './InfoTable.js'
import styles from './styles/InfoPopover.style.js'
const indicatorQuery = {
@@ -40,9 +44,8 @@ export const IndicatorInfo = ({ id, displayNameProp }) => {
expression: indicator.denominator,
})
- if (result?.description) {
- indicator.humanReadableDenominatorExpression =
- result.description
+ if (result) {
+ indicator.humanReadableDenominatorExpression = result
}
}
@@ -51,8 +54,8 @@ export const IndicatorInfo = ({ id, displayNameProp }) => {
expression: indicator.numerator,
})
- if (result?.description) {
- indicator.humanReadableNumeratorExpression = result.description
+ if (result) {
+ indicator.humanReadableNumeratorExpression = result
}
}
@@ -69,18 +72,21 @@ export const IndicatorInfo = ({ id, displayNameProp }) => {
{i18n.t('Numerator description')} |
- {data?.indicator.displayNumeratorDescription} |
+
+ {data?.indicator.displayNumeratorDescription ? (
+ data.indicator.displayNumeratorDescription
+ ) : (
+ {i18n.t('None')}
+ )}
+ |
{i18n.t('Numerator expression')} |
{data?.indicator.humanReadableNumeratorExpression ? (
-
- {
- data.indicator
- .humanReadableNumeratorExpression
- }
-
+ renderHumanReadableExpression(
+ data.indicator.humanReadableNumeratorExpression
+ )
) : (
{i18n.t('None')}
)}
@@ -88,18 +94,22 @@ export const IndicatorInfo = ({ id, displayNameProp }) => {
|
{i18n.t('Denominator description')} |
- {data?.indicator.displayDenominatorDescription} |
+
+ {data?.indicator.displayDenominatorDescription ? (
+ data.indicator.displayDenominatorDescription
+ ) : (
+ {i18n.t('None')}
+ )}
+ |
{i18n.t('Denominator expression')} |
{data?.indicator.humanReadableDenominatorExpression ? (
-
- {
- data.indicator
- .humanReadableDenominatorExpression
- }
-
+ renderHumanReadableExpression(
+ data.indicator
+ .humanReadableDenominatorExpression
+ )
) : (
{i18n.t('None')}
)}
diff --git a/src/components/DataDimension/Info/InfoTable.js b/src/components/DataDimension/Info/InfoTable.js
index 2684c8feb..9d7b457c1 100644
--- a/src/components/DataDimension/Info/InfoTable.js
+++ b/src/components/DataDimension/Info/InfoTable.js
@@ -15,6 +15,17 @@ export const capitalizeText = (text) =>
export const sentenceCaseText = (text) =>
text && capitalizeText(text.replaceAll('_', ' ').toLowerCase())
+export const renderHumanReadableExpression = (expressionData) => (
+ <>
+ {expressionData.status === 'ERROR' ? (
+ {expressionData.message}
+ ) : (
+ {expressionData.description}
+ )}
+
+ >
+)
+
export const InfoTable = ({ data, error, loading, children }) => {
const { fromServerDate } = useTimeZoneConversion()
diff --git a/src/components/DataDimension/Info/ProgramIndicatorInfo.js b/src/components/DataDimension/Info/ProgramIndicatorInfo.js
index f4e44f3f0..7336b6146 100644
--- a/src/components/DataDimension/Info/ProgramIndicatorInfo.js
+++ b/src/components/DataDimension/Info/ProgramIndicatorInfo.js
@@ -3,7 +3,12 @@ import PropTypes from 'prop-types'
import React, { useCallback, useEffect, useState } from 'react'
import { validateProgramIndicatorExpressionMutation } from '../../../api/expression.js'
import i18n from '../../../locales/index.js'
-import { getCommonFields, sentenceCaseText, InfoTable } from './InfoTable.js'
+import {
+ getCommonFields,
+ renderHumanReadableExpression,
+ sentenceCaseText,
+ InfoTable,
+} from './InfoTable.js'
import styles from './styles/InfoPopover.style.js'
const dataElementQuery = {
@@ -62,8 +67,8 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
expression: programIndicator.expression,
})
- if (result?.description) {
- programIndicator.humanReadableExpression = result.description
+ if (result) {
+ programIndicator.humanReadableExpression = result
}
}
@@ -72,8 +77,8 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
expression: programIndicator.filter,
})
- if (result?.description) {
- programIndicator.humanReadableFilter = result.description
+ if (result) {
+ programIndicator.humanReadableFilter = result
}
}
@@ -219,9 +224,9 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
| {i18n.t('Expression')} |
{data?.programIndicator.humanReadableExpression ? (
-
- {data.programIndicator.humanReadableExpression}
-
+ renderHumanReadableExpression(
+ data.programIndicator.humanReadableExpression
+ )
) : (
{i18n.t('None')}
)}
@@ -231,9 +236,9 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => {
| {i18n.t('Filter')} |
{data?.programIndicator.humanReadableFilter ? (
-
- {data.programIndicator.humanReadableFilter}
-
+ renderHumanReadableExpression(
+ data.programIndicator.humanReadableFilter
+ )
) : (
{i18n.t('None')}
)}
| |