Skip to content

Commit

Permalink
fix: [DHIS2-17054] handle empty expression value (#3635)
Browse files Browse the repository at this point in the history
Co-authored-by: Tony Valle <79843014+superskip@users.noreply.github.com>
  • Loading branch information
simonadomnisoru and superskip committed Jun 6, 2024
1 parent e93da19 commit 08291fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,15 @@ export function getRulesEffectsProcessor(
}

function processDisplayKeyValuePair(effect: ProgramRuleEffect): any {
const data = effect.data !== undefined ? effect.data : '';

return {
type: effectActions.DISPLAY_KEY_VALUE_PAIR,
id: effect.location,
displayKeyValuePair: {
id: effect.id,
key: effect.displayContent,
value: typeof effect.data == 'number' ? numberToString(effect.data) : String(effect.data),
value: typeof data === 'number' ? numberToString(data) : String(data),
...effect.style,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ const styles = {
marginTop: 0,
},
listItem: {
marginBottom: spacersNum.dp8,
'&::marker': {
color: colors.grey500,
},
'& + &': {
marginBottom: 0,
},
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ test('expressions with d2Functions in tracker program', () => {
location: 'feedback',
programRuleActionType: 'DISPLAYKEYVALUEPAIR',
},
{
id: 'jhflkgjh45',
displayContent: 'key with undefined value',
data: undefined,
location: 'feedback',
programRuleActionType: 'DISPLAYKEYVALUEPAIR',
},
{
id: 'Tx4gHcLselM',
displayContent: 'd2:oizp( 10000000 ) = ',
Expand Down Expand Up @@ -778,6 +785,15 @@ test('expressions with d2Functions in tracker program', () => {
value: '15',
},
},
{
type: 'DISPLAYKEYVALUEPAIR',
id: 'feedback',
displayKeyValuePair: {
id: 'jhflkgjh45',
key: 'key with undefined value',
value: '',
},
},
{
type: 'DISPLAYTEXT',
id: 'feedback',
Expand Down

0 comments on commit 08291fa

Please sign in to comment.