From 2a792aa8e8a55bca7e4e1e31783439d5654fcb39 Mon Sep 17 00:00:00 2001 From: Pablo Pajuelo Cabezas Date: Mon, 16 Dec 2024 14:43:12 +0100 Subject: [PATCH] fix: [ANDROAPP-6707] Unable to complete event --- form/src/main/java/org/dhis2/form/ui/FormView.kt | 5 +---- .../java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/form/src/main/java/org/dhis2/form/ui/FormView.kt b/form/src/main/java/org/dhis2/form/ui/FormView.kt index 83388f2477..168992af15 100644 --- a/form/src/main/java/org/dhis2/form/ui/FormView.kt +++ b/form/src/main/java/org/dhis2/form/ui/FormView.kt @@ -75,7 +75,6 @@ import org.dhis2.ui.ErrorFieldList import org.dhis2.ui.dialogs.bottomsheet.BottomSheetDialog import org.dhis2.ui.dialogs.bottomsheet.BottomSheetDialogUiModel import org.dhis2.ui.dialogs.bottomsheet.FieldWithIssue -import org.dhis2.ui.dialogs.bottomsheet.IssueType import org.hisp.dhis.android.core.arch.helpers.FileResourceDirectoryHelper import org.hisp.dhis.android.core.common.ValueType import org.hisp.dhis.android.core.common.ValueTypeRenderingType @@ -467,9 +466,7 @@ class FormView : Fragment() { isEventCompleted: Boolean, bottomSheetDialog: BottomSheetDialog, ) { - val errorsInField = - fieldsWithIssues.isNotEmpty() || fieldsWithIssues.any { it.issueType == IssueType.ERROR } - if (errorsInField) { + if (fieldsWithIssues.any { it.issueType.shouldShowError() }) { bottomSheetDialog.dismiss() } else if (isEventCompleted) { onFinishDataEntry?.invoke() diff --git a/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt b/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt index 807f43d629..30ee351719 100644 --- a/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt +++ b/ui-components/src/main/java/org/dhis2/ui/dialogs/bottomsheet/FieldWithIssue.kt @@ -13,4 +13,7 @@ enum class IssueType { WARNING, ERROR_ON_COMPLETE, WARNING_ON_COMPLETE, + ; + + fun shouldShowError() = this == ERROR || this == ERROR_ON_COMPLETE || this == MANDATORY }