feat: support custom forms with plugins #346
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a Proof of Concept for the idea of using plugins to host and run custom forms. It's not production-ready (nor recommended) but the PoC was built to serve as a basis for evaluating the plugin route when discussing alternatives for implementing custom forms.
The custom form plugin lives here: https://github.com/kabaros/dhis2-custom-form-plugin/blob/main/src/App.js.
To test the custom form plugin, run Aggregate the Data Entry app from this branch as usual (
yarn install && yarn start
), then checkout and run the custom form plugin withyarn install && yarn start
then navigate to any existing custom form (i.e. TB Facility Reporting Form).PoC conclusion
My recommendation after this PoC is to not go the plugin route at all. We should not make this route possible, because:
(I will write these notes in more details in a technical document about custom forms, but this is tldr; for the plugins usecase.)
Screenshots
Custom form running inside a plugin. It uses the styles from the custom form (the ugly yellow + form design) and it - dangerously - runs the JavaScript scripts defined in the form (in this case, to set the input background to green), and communicates data to/from the parent container (for context selection for example).