-
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
base: master
Are you sure you want to change the base?
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 <79843014+superskip@users.noreply.github.com>
🚀 Deployed on https://deploy-preview-3783--dhis2-capture.netlify.app |
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.
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.
Can we move this file to capture-core/utils/validation
(new directory) and rename to validateValue.js
(and update the function to validateValue). You will also have to move getValidators.js
etc.
In addition, move capture-core/utils/validators
into the folder created above (capture-core/utils/validation/validators
...)
}; | ||
|
||
export const validateField = async ( | ||
{ validators }: { validators?: Array<ValidatorContainer> }, |
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.
Can we change the input here to only be the validators and not use object destructering.
{ validators }: { validators?: Array<ValidatorContainer> }, | ||
value: any, | ||
validationContext: ?Object, | ||
onIsValidatingInternal: ?Function, |
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.
Hard to find a good name for this one (onIsValidatingInternal). Can we change the name of this callback to postProcessAsyncValidatonInitiation
? Quite a mouthful, I know, but would like to have something a bit more describing.
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.
Can we move this file to capture-core/rules
?
Hi @JoakimSM, I implemented the suggested structural changes. Can you have a look? Thank you! |
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.