-
Notifications
You must be signed in to change notification settings - Fork 391
Nested arrays not finding data to render #994
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
Comments
Thanks for the repro. I think part of the problem here is that a pointer to a nested array within the schema needs to be bound to the data instance at runtime which is ambiguous in this case since we can't specify indices in the schema, so it's not clear to what this should be bound to; to resolve this ambiguity, we would also need to render the outer array or somehow bind it implicitly to an index, I think. So what would be your expectation? |
I agree... binding or otherwise explicitly referencing an index isn't desirable in this case. (It may be in other cases, but would be a departure from your current more declarative design). If you consider an array as just a grouping mechanism, then it corresponds more closely to one of the layout elements (Horizontal or Vertical) rather than an explicit control. Your approach to arrays binds the view and control together explicitly in the I think the right approach is to treat an array as just a grouping mechanism (similar to a MUI FormGroup, RadioGroup, List, or Select (with multiple set to true). These are really just additional Horizontal or Vertical layout elements plus some controls for selecting/deselecting, adding/removing, etc. The simplest could even be just a couple of 's for wrapping the contents below into some HTML.
My initial thought is 2 controls - an I'm happy to help implement this in a PR today if we can decide on a direction here. My immediate goal is to get the lower array into a |
Yes, I think we did something similar in the past, e.g. the vanilla |
Yes, this is related to #992, looks like. However, I don't see this as just a problem of what to render for each element of the array but also of the grouping control for the array itself - List, RadioGroup, etc Thinking aloud... I'd argue that you have 2 types developer scenarios of jsonforms to consider:
Maybe I'm oversimplifying, but my use cases fall squarely into the latter bucket. I have some complex JSON that I may have little to no control over how it is generated but need to get it into something that can be displayed easily. The alternative to this is to use something like jsonpath to transform something complex into and out of a simplified format that is more easily consumable by a UI framework. But I'd rather avoid additional mangling of the source JSON if I can avoid it. This is a long-winded answer, but I think the approach of keeping the schema and uischema relatively simple and approachable allows more adoption (and contributors!), but for more complex scenarios or custom components, adding the ui schema registry seems like the right approach. In my case, I would register the IMHO... In terms of default testers for this (scenario #1), I think you end up with the majority of the time, LEAF arrays get rendered using an |
I agree with everything you say, so I think we'll need to add the UI schema registry first step to support your use case properly. If you want to start working on this, we'd welcome any contribution, of course. I'm off for today and probably also tomorrow, but I'll get back to you as soon as I can if you should have any questions. |
Ok, good that we're in alignment on this. The schema ui registry may be a bit more than I'm able to bite off in the next few days but I'll see what I can do to help. Might be that I take the more imperative approach in the short term and see how that could expand into the ui schema registry. |
According to Eugen's comment it seems like we already have a UI schema registry, but in the editor package, so we might want to move it to core package. |
* Add UI schema registry reducer * Add material array layout
I've had a look at this yesterday and created PR #995 that demonstrates how this could look like. The actual layout renderer is ugly and tests are missing, but I think it contains everything what's necessary. Would you mind having a look if you find the time? Does this cover your use case properly? |
* Add UI schema registry reducer * Add material array layout
* Add UI schema registry reducer This allows to register, unregister and retrieve uischemas. The user can now configure how the detail in an ArrayLayout renderer should look like.
* Add UI schema registry reducer This allows to register, unregister and retrieve uischemas. The user can now configure how the detail in an ArrayLayout renderer should look like.
* Add UI schema registry reducer This allows to register, unregister and retrieve uischemas. The user can now configure how the detail in an ArrayLayout renderer should look like.
Add a new array renderer to material which renders all its children below each other. This renderer is only used if the array being rendered contains another array in its path.
* Add UI schema registry reducer This allows to register, unregister and retrieve uischemas. The user can now configure how the detail in an ArrayLayout renderer should look like.
Add a new array renderer to material which renders all its children below each other. This renderer is only used if the array being rendered contains another array in its path.
This was fixed with #1013 and has been released with 2.0.2. We've also added some documentation about the usage in the Providing UI schemas section. If there's anythings unclear, let us know. |
Hi, from your description in Providing UI schemas I can see how to register and retrieve an ui schema, but my problem is to modify the length of the different fields in an array. Can you please give a hint how registering an ui schema helps with that? Thanks, Günther |
Hi @guenthermahr, what exactly do mean by length? Is it just CSS styling? If so, Custom Renderers might be the way a go, but it depends on what exactly you are trying to achieve (and which renderer set you are using). Or did you mean something different? If you could elaborate a bit more, I think we are able to help. |
I have replicated this on my own fork
First one is broken where "firstarray" is an array. 2nd one works where "firstarray" is an object.
The text was updated successfully, but these errors were encountered: