Skip to content

Commit

Permalink
chore: [ANDROAPP-6341] Use displayContent with fallback to content in…
Browse files Browse the repository at this point in the history
… rule actions (#3786)

* chore: [ANDROAPP-6341] Use displayContent with fallback to content in rule actions

* refactor common definition
  • Loading branch information
taridepaco committed Sep 5, 2024
1 parent 994bf84 commit 4ea354c
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
else -> ""
}

val contentToDisplay = displayContent() ?: content()

return when (programRuleActionType()) {
ProgramRuleActionType.HIDEFIELD ->
RuleAction(
Expand All @@ -111,7 +113,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -122,7 +124,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("location", location() ?: "indicators"),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -133,7 +135,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("location", location()!!),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand Down Expand Up @@ -178,7 +180,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)
}
Expand All @@ -190,7 +192,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -200,7 +202,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -211,7 +213,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -222,7 +224,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -234,7 +236,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("programStage", stageUid),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)
} ?: RuleAction(
Expand All @@ -249,7 +251,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
values = mutableMapOf(
Pair("field", field),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)

Expand All @@ -262,7 +264,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
Pair("field", field),
Pair("option", optionUid),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)
} ?: RuleAction(
Expand All @@ -279,7 +281,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
Pair("field", field),
Pair("optionGroup", optionGroupUid),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)
} ?: RuleAction(
Expand All @@ -296,7 +298,7 @@ fun ProgramRuleAction.toRuleEngineObject(): RuleAction {
Pair("field", field),
Pair("optionGroup", optionGroupUid),
).also { map ->
content()?.let { map["content"] = it }
contentToDisplay?.let { map["content"] = it }
},
)
} ?: RuleAction(
Expand Down

0 comments on commit 4ea354c

Please sign in to comment.