From d3cf8d4941771bb9cf6b10ef16c7d06948161239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Miguel=20Rubio?= Date: Thu, 16 May 2024 13:14:58 +0200 Subject: [PATCH] fix: Save attribute option combo (#3634) * fix: [ANDROAPP-6160] update selected options before getting catcombo uid Signed-off-by: andresmr * fix: [ANDROAPP-6160] update version name 2.9.1.1 and version code 131 Signed-off-by: andresmr --------- Signed-off-by: andresmr --- .../eventDetails/domain/ConfigureEventCatCombo.kt | 2 +- .../eventDetails/providers/InputFieldsProvider.kt | 2 +- .../eventDetails/domain/ConfigureEventCatComboTest.kt | 6 ++++++ gradle/libs.versions.toml | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt index 093f8a971b..c84ac29857 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt @@ -19,9 +19,9 @@ class ConfigureEventCatCombo( repository.catCombo().apply { val categories = getCategories(this?.categories()) val categoryOptions = getCategoryOptions() + updateSelectedOptions(categoryOption, categories, categoryOptions) val catComboUid = getCatComboUid(this?.uid() ?: "", this?.isDefault ?: false) val catComboDisplayName = getCatComboDisplayName(this?.uid() ?: "") - updateSelectedOptions(categoryOption, categories, categoryOptions) return flowOf( EventCatCombo( diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt index 69c297b4a4..8c668b5044 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt @@ -213,7 +213,7 @@ fun ProvideCategorySelector( modifier: Modifier = Modifier, eventCatComboUiModel: EventCatComboUiModel, ) { - var selectedItem by remember { + var selectedItem by remember(eventCatComboUiModel.eventCatCombo.selectedCategoryOptions) { mutableStateOf( eventCatComboUiModel.eventCatCombo.selectedCategoryOptions[eventCatComboUiModel.category.uid]?.displayName() ?: eventCatComboUiModel.eventCatCombo.categoryOptions?.get(eventCatComboUiModel.category.uid)?.displayName(), diff --git a/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt b/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt index 2a6d30821e..087ab9b827 100644 --- a/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt +++ b/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt @@ -8,6 +8,7 @@ import org.hisp.dhis.android.core.category.CategoryCombo import org.hisp.dhis.android.core.category.CategoryOption import org.hisp.dhis.android.core.category.CategoryOptionCombo import org.hisp.dhis.android.core.event.Event +import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Before @@ -70,12 +71,17 @@ class ConfigureEventCatComboTest { whenever( repository.getCatOption(CATEGORY_OPTION_UID), ) doReturn categoryOption + whenever( + repository.getCategoryOptionCombo(CATEGORY_COMBO_UID, listOf(CATEGORY_OPTION_UID)), + ) doReturn CATEGORY_OPTION_COMBO_UID // When catCombo is invoked val eventCatCombo = configureEventCatCombo.invoke(selectedCategoryOption).first() // Then should be completed assertTrue(eventCatCombo.isCompleted) + // And the EventCatCombo uid should be set + assertEquals(eventCatCombo.uid, CATEGORY_OPTION_COMBO_UID) } @Test diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ff295f775f..7bbf3ca5b6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,8 @@ ndk = "21.4.7075529" sdk = "34" minSdk = "21" -vCode = "130" -vName = "2.9.1" +vCode = "131" +vName = "2.9.1.1" kotlinCompilerExtensionVersion = "1.5.6" gradle = "8.2.0" kotlin = '1.9.21'