Skip to content
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

Flesh out anyOf support #9

Open
romancow opened this issue Sep 14, 2023 · 1 comment
Open

Flesh out anyOf support #9

romancow opened this issue Sep 14, 2023 · 1 comment
Assignees

Comments

@romancow
Copy link
Collaborator

Currently support for anyOf is a bit limited. I believe it's just a dropdown that switches child fields based on which "anyOf" option is selected. When a new one is selected, the previous set values persist. These should probably be "cleared out" whenever a new option is selected.

Actually, this would ideally be how the "oneOf" would work and "anyOf" would allow one to select multiple options and set the values for each of these (and clear out associated values when unselected). There are a few complications here to keep in mind - like there can be values for say, an object type, that are not part of the anyOf options. Also the different options could have overlapping values, where we probably want one field for this. Likewise you could have anyOfs without actual properties like outlined in issue #6 .

Probably want to look at how other similar libraries handle this (e.g. (react-jsonschema-form)[https://rjsf-team.github.io/react-jsonschema-form/] and (JSONForms)[https://jsonforms.io/]).

@romancow romancow self-assigned this Sep 14, 2023
@romancow
Copy link
Collaborator Author

I think the best way to go about "full" anyOf support, would be to replace the current select dropdown with a similar "multiselect" dropdown. SMUI does not currently have a multiselect like this, so we'd have to create custom one, though I don't think this would be too hard (we're already patching the current select component). I've already created something similar for the webgme-taxonomy dashboard search filters.

I think then we could use the existing json-schema-merge-allof dependency to merge all the selected anyOfs with any properties. This would also address #6 . This "merged" schema" would only be present/referenced in the control itself, and not a change made to the schema object as a whole.

When an anyOf item is unselected, we would then recalculate the "merged" schema, then compare all the current property keys with the current data value, removing any keys in data nor present in the new schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant