diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/ui/mapper/TEICardMapper.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/ui/mapper/TEICardMapper.kt index 4482d88eff..2dd670c8c8 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/ui/mapper/TEICardMapper.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/ui/mapper/TEICardMapper.kt @@ -93,13 +93,9 @@ class TEICardMapper( } private fun getTitle(item: SearchTeiModel): String { - return if (item.header != null) { - item.header!! - } else if (item.attributeValues.isEmpty()) { - "-" - } else { - val key = item.attributeValues.keys.firstOrNull() - val value = item.attributeValues.values.firstOrNull()?.value() + return item.header ?: run { + val key = item.attributeValues.keys.firstOrNull() ?: "-" + val value = item.attributeValues.values.firstOrNull()?.value() ?: "-" "$key: $value" } } diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/ui/mapper/TeiDashboardCardMapper.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/ui/mapper/TeiDashboardCardMapper.kt index 879877f4d9..8bc9e4b91d 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/ui/mapper/TeiDashboardCardMapper.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/ui/mapper/TeiDashboardCardMapper.kt @@ -81,7 +81,9 @@ class TeiDashboardCardMapper( ?.let { val attribute = it.filterAttributes().firstOrNull() val key = attribute?.first?.displayFormName() - val value = attribute?.second?.value() + val value = attribute?.second?.value()?.takeIf { attrValue -> + attrValue.isNotEmpty() + } ?: "-" "$key: $value" } ?: "-" @@ -102,7 +104,7 @@ class TeiDashboardCardMapper( if (it.first.valueType() == ValueType.PHONE_NUMBER) { AdditionalInfoItem( key = "${it.first.displayFormName()}:", - value = it.second.value() ?: "", + value = it.second.value()?.takeIf { attrValue -> attrValue.isNotEmpty() } ?: "-", icon = { Icon( imageVector = Icons.Filled.PhoneEnabled, @@ -246,5 +248,4 @@ class TeiDashboardCardMapper( this.filter { it.first.valueType() != ValueType.IMAGE } .filter { it.first.valueType() != ValueType.COORDINATE } .filter { it.first.valueType() != ValueType.FILE_RESOURCE } - .filter { it.second.value()?.isNotEmpty() == true } }