-
Notifications
You must be signed in to change notification settings - Fork 2
feat: expression builder (for validation rules) [DHIS2-20474] #719
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for dhis2-maintenance-app-beta ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| > | ||
| {descriptionToShow || i18n.t('(No Value)')} | ||
| </div> | ||
| )} |
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.
In the old expression builder we decided to incluse here an hidden field:
<TextAreaFieldFF
dataTest={`formfields-${fieldName}`}
input={input}
meta={meta}
inputWidth="400px"
disabled
className={styles.expressionHiddenInput}
/>
This was to make sure the field would be present on form submission, so the behavior would act consistently to other fields (e.g. the field would be validated and validation text would show, for example if expression is required).
I think it might useful to add here as well?
| }, [setIsEmpty, setValidationResponse]) | ||
|
|
||
| useEffect(() => { | ||
| const performInitialValidation = async (s: string) => { |
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.
would it not make sense to pull this put of tehe useEffect?
| } | ||
|
|
||
| return ( | ||
| <div className={styles.expressionListContainer}> |
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 think we need here some sort of onClick={e => {e.preventDefault(); e.stopPropagation();}} because otherwise the parent onClick gets called and setSelectedElementType gets invoked
| } | ||
|
|
||
| .elementListContainer { | ||
| background-color: white; |
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.
Maybe a bit of padding bottom here as well?
| padding-inline: var(--spacers-dp4); | ||
| padding-block-start: var(--spacers-dp4); | ||
| align-items: center; | ||
| font-size: 16px; |
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.
Maybe a bit of padding top/bottom here?
|
|
||
| return ( | ||
| <> | ||
| <div className={styles.preliminarySelect}> |
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.
maybe worth adding a box shadow here if ProgramJunction is not rendered, so it does not appear after a selection. but it's always there?
flaminic
left a comment
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.
Thank you Tom! looks great. Left a few minor comments
|
Thanks! Also while I was implementing your comments, I noticed that the saved expression could be invalid, and in that case the form said "No expression", so I've updated that to say "Invalid expression" if validation of existing value fails. If nothing is actually there, it will say "No expression"; if something valid is there, it will show the actual description. |




Background
This adds an update ExpressionBuilder (with list of variables for insertion) into validation rules form. See ticket description https://dhis2.atlassian.net/browse/DHIS2-20474. Note that I have updated the acceptance criteria after some discussion with David and Joe about behaviour.
After:

Overall notes
there is bug with app-runtime which prevents us from using normal mutation here (fix: text payload for validationRules expression mutation app-runtime#1420). Once that is merged, we can update app-runtime and then clean up to not use a direct invocation of fetch api[Now fixed in app-runtime. I'm leaving this note here because this is why there is now a resolution for app-runtime: the version in app-shell does not match the app-runtime version we need, so need to resolve]validationRuleElementTypes. The idea is that we define custom components for the various element types and then define an array of the the element types that we want to use for the paritcular implementation of the expression builder. For now, I am just importvalidationRuleElementTypesin the VariableSelectionBox.tsx file, but when adapting for indicators/program indicators this will be updated to have logic to pull the correct array of element definitions.UX notes
Other potential improvements
David, Joe, and I discussed some potential ideas for improvement that we will not address at the moment: