Separate validationResult and constraintValidationResult#7038
Separate validationResult and constraintValidationResult#7038grzesiek2010 merged 2 commits intogetodk:masterfrom
Conversation
8eb7c15 to
6c7de7f
Compare
The observer in This means that when an error occurs during validation in Maps, the observer in |
There was a problem hiding this comment.
The observer in FormFillingActivity ignores null values:
Ah and we don't handle success cases in validateAnswerConstraint. That will actually have to change for #6970, but I agree with you that it's weird for the validation state to be shared between the "page" and the individual question at this point.
What do you think about introducing a QuestionViewModel that exists for the lifecycle of the WidgetAnswerDialogFragment and talks directly to the FormController instead of holding this question "detail" state in FormEntryViewModel? I'm thinking something like:
class QuestionViewModel(index: FormIndex, formSessionRepository: FormSessionRepository, sessionId: String) : ViewModel {
fun getValidationResult(): LiveData<ValidationResult> {
...
}
fun getPrompt(): FormEntryPrompt {
...
}
fun validate(answer: IAnswerData?) {
...
}
}That could also be a follow-up I guess, but it seems like the state that shouldn't be shared with the full form session should live in its own place. WidgetAnswerDialogFragmetn would still need to talk to FormEntryViewModel to answer the question, but that's state we do want to share.
6c4ef7f to
0a6f1c3
Compare
0a6f1c3 to
d7c7789
Compare
I was also thinking about that. Done. |
|
Tested with Success! Verified on devices with Android 10 Verified cases:
|
|
Tested with succes Verified on Android 16 |
Closes #7033
Why is this the best possible solution? Were any other approaches considered?
We had a single
validationResultLiveData observed byFormFillingActivityand the map fragment, used for two different cases: validating saved answers in the form view and validating polygons on the map. Initially, it seemed reasonable to reuse the sameLiveDatafor both, but over time the two cases started to diverge.We stopped saving answers when validating polygons, and later decided that only constraint errors were needed in that flow. As a result, sharing the same
LiveDatacaused more problems than benefits.We also don’t want to update the form view (e.g. display errors) when validation occurs in the map flow, so separating these cases turned out to be the best solution.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
There should now be no relationship between the errors displayed on the map and those shown in the form view, meaning that these two cases should not affect each ot. We already know how tricky these cases can be, so we need to be careful and test all related scenarios.
Do we need any specific form for testing your changes? If so, please attach one.
The form is linked in the issue.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest