-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor(modelSingleSelect): refactor modelSingleSelect to be more ergonomic #465
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for dhis2-maintenance-app-beta ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
We still want this - but removing it from this PR
flaminic
approved these changes
Dec 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refactor
ModelSingleSelect
to be more ergonomic. The API of passinguseOptions
-hooks are not very ergonomic, and I'm pretty sure it violates the rule of hooks.However, most importantly this will now preserve the
Model
. Previously we had toformat
andparse
back and forth to the id. But I think it's very important that we have the ability to store complex objects in the form-store (as opposed to just the id) - because we have logic that need more information from other fields. All other forms thandataElements
follow this idea.This mostly follows the same composition as
ModelTransfer
:BaseModelSingleSelect
translates a Model (id and displayName) to be used with our SearchableSingleSelect.ModelSingleSelect
deals with fetching data. It takes a simplequery
and fetches an inifinite list with support for "search".PartialLoadedDisplayableModel
. This makes it possible for this component to fetch the label if you just have access to "id" of the model. This is useful for our filters in the List (where we just have IDs in URL on first render) - and for eg.selected
-models in the list.ModelSingleSelectField
is used to compose the selector with a final-form connected field. We mostly use selectors in forms, and this greatly reduces boilerplate for such fields.