From bc3113743472358b0382585cbd6772a8d884a3d6 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 11 Apr 2024 11:54:00 +0200 Subject: [PATCH] fix: [ANDROAPP-6062] clear search fields when required attributes to search --- .../usescases/searchTrackEntity/SearchTEIViewModel.kt | 8 +++++++- .../searchparameters/SearchParametersScreen.kt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt index 7dee0e173ec..7fe03eadb20 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt @@ -275,7 +275,11 @@ class SearchTEIViewModel( val updatedItems = uiState.items.map { (it as FieldUiModelImpl).copy(value = null, displayName = null) } - uiState = uiState.copy(items = updatedItems) + uiState = uiState.copy( + items = updatedItems, + searchedItems = mapOf(), + ) + searching = false } private fun updateSearch() { @@ -461,6 +465,8 @@ class SearchTEIViewModel( ) uiState = uiState.copy(minAttributesMessage = message) uiState.updateMinAttributeWarning(true) + setSearchScreen() + _refreshData.postValue(Unit) } } } diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt index 5b7a8573612..af52d14a5b6 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt @@ -144,6 +144,7 @@ fun SearchParametersScreen( message = message, duration = SnackbarDuration.Short, ) + uiState.updateMinAttributeWarning(false) } } }