diff --git a/src/api/expression.js b/src/api/expression.js index 64bb61c30..373fbccfa 100644 --- a/src/api/expression.js +++ b/src/api/expression.js @@ -1,9 +1,15 @@ -export const validateExpressionMutation = { +export const validateIndicatorExpressionMutation = { type: 'create', resource: 'indicators/expression/description', data: ({ expression }) => expression, } +export const validateProgramIndicatorExpressionMutation = { + type: 'create', + resource: 'programIndicators/expression/description', + data: ({ expression }) => expression, +} + export const createCalculationMutation = { type: 'create', resource: 'expressionDimensionItems', diff --git a/src/components/DataDimension/Calculation/CalculationModal.js b/src/components/DataDimension/Calculation/CalculationModal.js index 6fdcf8119..7a7cc812b 100644 --- a/src/components/DataDimension/Calculation/CalculationModal.js +++ b/src/components/DataDimension/Calculation/CalculationModal.js @@ -15,7 +15,7 @@ import { createCalculationMutation, deleteCalculationMutation, updateCalculationMutation, - validateExpressionMutation, + validateIndicatorExpressionMutation, } from '../../../api/expression.js' import i18n from '../../../locales/index.js' import { @@ -57,7 +57,7 @@ const CalculationModal = ({ const [deleteCalculation, { loading: isDeletingCalculation }] = useDataMutation(deleteCalculationMutation, mutationParams) const [doBackendValidation, { loading: isValidating }] = useDataMutation( - validateExpressionMutation, + validateIndicatorExpressionMutation, { onError: (error) => showError(error), } diff --git a/src/components/DataDimension/Info/CalculationInfo.js b/src/components/DataDimension/Info/CalculationInfo.js index b327e1f49..0f6f175c1 100644 --- a/src/components/DataDimension/Info/CalculationInfo.js +++ b/src/components/DataDimension/Info/CalculationInfo.js @@ -1,7 +1,7 @@ import { useConfig, useDataMutation, useDataEngine } from '@dhis2/app-runtime' import PropTypes from 'prop-types' import React, { useCallback, useEffect, useState } from 'react' -import { validateExpressionMutation } from '../../../api/expression.js' +import { validateIndicatorExpressionMutation } from '../../../api/expression.js' import i18n from '../../../locales/index.js' import { getCommonFields, InfoTable } from './InfoTable.js' import styles from './styles/InfoPopover.style.js' @@ -25,7 +25,7 @@ export const CalculationInfo = ({ id, displayNameProp }) => { const engine = useDataEngine() const [getHumanReadableExpression] = useDataMutation( - validateExpressionMutation, + validateIndicatorExpressionMutation, { onError: setError } ) diff --git a/src/components/DataDimension/Info/IndicatorInfo.js b/src/components/DataDimension/Info/IndicatorInfo.js index 8a9842132..602e6be27 100644 --- a/src/components/DataDimension/Info/IndicatorInfo.js +++ b/src/components/DataDimension/Info/IndicatorInfo.js @@ -1,7 +1,7 @@ import { useDataMutation, useDataEngine } from '@dhis2/app-runtime' import PropTypes from 'prop-types' import React, { useCallback, useEffect, useState } from 'react' -import { validateExpressionMutation } from '../../../api/expression.js' +import { validateIndicatorExpressionMutation } from '../../../api/expression.js' import i18n from '../../../locales/index.js' import { getCommonFields, InfoTable } from './InfoTable.js' import styles from './styles/InfoPopover.style.js' @@ -25,7 +25,7 @@ export const IndicatorInfo = ({ id, displayNameProp }) => { const engine = useDataEngine() const [getHumanReadableExpression] = useDataMutation( - validateExpressionMutation, + validateIndicatorExpressionMutation, { onError: setError } ) diff --git a/src/components/DataDimension/Info/ProgramIndicatorInfo.js b/src/components/DataDimension/Info/ProgramIndicatorInfo.js index 853a1599f..f529a0ca4 100644 --- a/src/components/DataDimension/Info/ProgramIndicatorInfo.js +++ b/src/components/DataDimension/Info/ProgramIndicatorInfo.js @@ -1,7 +1,7 @@ import { useDataMutation, useDataEngine } from '@dhis2/app-runtime' import PropTypes from 'prop-types' import React, { useCallback, useEffect, useState } from 'react' -import { validateExpressionMutation } from '../../../api/expression.js' +import { validateProgramIndicatorExpressionMutation } from '../../../api/expression.js' import i18n from '../../../locales/index.js' import { getCommonFields, InfoTable } from './InfoTable.js' import styles from './styles/InfoPopover.style.js' @@ -25,7 +25,7 @@ export const ProgramIndicatorInfo = ({ id, displayNameProp }) => { const engine = useDataEngine() const [getHumanReadableExpression] = useDataMutation( - validateExpressionMutation, + validateProgramIndicatorExpressionMutation, { onError: setError, }