-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [DHIS2-17854] validate the assigned values from rules engine #3783
Conversation
src/core_modules/capture-core/components/D2Form/field/validators/validateAssignEffects.js
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/components/D2Form/field/validators/validateAssignEffects.js
Outdated
Show resolved
Hide resolved
...dules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/reducers/descriptions/form.reducerDescription.js
Show resolved
Hide resolved
src/core_modules/capture-core/reducers/descriptions/form.reducerDescription.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Tony Valle <[email protected]>
🚀 Deployed on https://deploy-preview-3783.capture.netlify.dhis2.org |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made a few structural suggestions that I hope is reasonable. Open to discuss if you disagree of course.
I'm also wondering, since we are dealing with potential async validations here, what are we doing to prevent the user from clicking save/complete while an async validation is running? I couldn't see this being handled properly, but I very much might have missed something.
src/core_modules/capture-core/components/D2Form/field/validators/validateField.js
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/components/D2Form/field/validators/validateField.js
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/components/D2Form/field/validators/validateField.js
Outdated
Show resolved
Hide resolved
src/core_modules/capture-core/components/D2Form/field/validators/validateAssignEffects.js
Outdated
Show resolved
Hide resolved
@@ -101,13 +108,19 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({ | |||
formFoundation, | |||
}); | |||
|
|||
const effectsWithValidations = await validateAssignEffects({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, we are validating all the form values in the formbuilder when opening the form, so it would probably be best to skip the assign validations here (and other places where we are opening forms)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I skipped the assign validations when opening all the forms. Thanks for the feedback!
It does indeed seem like this is handled. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🎉 Looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested successfully on 2.42,2.41.3,2.40.7,2.39.8 versions
## [101.19.1](v101.19.0...v101.19.1) (2024-12-05) ### Bug Fixes * [DHIS2-17854] validate the assigned values from rules engine ([#3783](#3783)) ([db9d6b8](db9d6b8))
🎉 This PR is included in version 101.19.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
DHIS2-17854
Tech summary
validateField
. The common function runs every time the rules engine finishes executing and before the assigned values are stored in Redux. To improve performance, only the last assigned value is validated, since it is the one stored in the reduxformsValues
key.switchMap
,from()
andof()
were used in the epics to handle the async validation checksstartLoadDataEntry
,startRunRulesPostUpdateField
, andstartRunRulesPostLoadDataEntry
will be dispatched before running the validations. These actions will add an entry indataEntriesInProgressList
that will show the waitForPromisesDialogOpen modal if necessary.