Skip to content

Commit

Permalink
fix: [ANDROAPP-6667] form action with warning
Browse files Browse the repository at this point in the history
Signed-off-by: Manu Muñoz <[email protected]>
  • Loading branch information
mmmateos committed Dec 20, 2024
1 parent 70179db commit bb4edcc
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions form/src/main/java/org/dhis2/form/ui/FormView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import org.dhis2.maps.views.MapSelectorActivity.Companion.LOCATION_TYPE_EXTRA
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.DialogButtonStyle
import org.dhis2.ui.dialogs.bottomsheet.FieldWithIssue
import org.hisp.dhis.android.core.arch.helpers.FileResourceDirectoryHelper
import org.hisp.dhis.android.core.common.ValueType
Expand Down Expand Up @@ -425,8 +426,7 @@ class FormView : Fragment() {
},
onMainButtonClicked = { bottomSheetDialog ->
manageMainButtonAction(
fieldsWithIssues,
result.eventResultDetails.eventStatus == EventStatus.COMPLETED,
model.mainButton,
bottomSheetDialog,
)
},
Expand Down Expand Up @@ -462,17 +462,17 @@ class FormView : Fragment() {
}

private fun manageMainButtonAction(
fieldsWithIssues: List<FieldWithIssue>,
isEventCompleted: Boolean,
mainButtonModel: DialogButtonStyle?,
bottomSheetDialog: BottomSheetDialog,
) {
if (fieldsWithIssues.any { it.issueType.shouldShowError() }) {
bottomSheetDialog.dismiss()
} else if (isEventCompleted) {
onFinishDataEntry?.invoke()
} else {
viewModel.completeEvent()
onFinishDataEntry?.invoke()
when (mainButtonModel) {
DialogButtonStyle.CompleteButton -> {
viewModel.completeEvent()
onFinishDataEntry?.invoke()
}
else -> {
bottomSheetDialog.dismiss()
}
}
}

Expand Down

0 comments on commit bb4edcc

Please sign in to comment.