-
Notifications
You must be signed in to change notification settings - Fork 391
[WIP] Handle nested array #995
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
[WIP] Handle nested array #995
Conversation
@eneufeld Requesting feedback |
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.
looks good
why do we need the app stuff though?
const copy = state.slice(); | ||
_.remove( | ||
copy, | ||
entry => entry.tester === action.tester && _.eq(entry.uischema, action.uischema) |
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.
shouldn't the tester be unique? or the uischema?
import { ADD_UI_SCHEMA, REMOVE_UI_SCHEMA } from '../actions'; | ||
import { JsonSchema, UISchemaElement } from '..'; | ||
|
||
export type UISchemaTester = (schema: JsonSchema, schemaPath: string, path: string) => number; |
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 pass in the data?
packages/core/src/reducers/index.ts
Outdated
export const findUISchema = state => (schema: JsonSchema, schemaPath: string, path: string) => { | ||
const uiSchema = findMatchingUISchema(state.jsonforms.uischemas)(schema, schemaPath, path); | ||
if (uiSchema === undefined) { | ||
return getUiSchema(state); |
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.
Return generated UI schema instead of registered one.
export const findMatchingUISchema = | ||
state => | ||
(jsonSchema: JsonSchema, schemaPath: string, path: string): UISchemaElement => { | ||
const match = _.find(state, entry => entry.tester(jsonSchema, schemaPath, path)); |
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.
Use same logic as in JsonForms renderer (which is maxBy
)
Awesome! I'm going to pull down and validate some use cases today. |
I'm midway through debugging root cause but this doesn't yet support the issue identified in #994. I understand this is a WIP. First thing I encountered was just compile issue. I had to add the following to MaterialArrayLayout line 47:
Anything I can do to help? I can continue to debug unless there are known issues here that you're already aware of. |
Not sure which line you are referring, did you mean this one? |
Ah yes.... was |
Ok, what other issues are you experiencing, can I help? |
The test case for #994 I created still seems broken. Few minor ones...
|
How do you test this? Do you use the example package (which is just a copy of the seed) that has been included in this PR that contains the configuration from your fork? I've set it up in order to being able to test your use case. When starting it, it should look as follows: Thanks for pointing out the minor issues, we've fixed those already in #999 |
Must be my set up then.... I was using my own fork of the example, not the one that was part of the PR. |
I tried starting from a fresh clone and pull from the pr/995 and still seeing the same issue... Also validated I had the updated versions in my Looks like I need to dive in a bit deeper with debug tools. This is what I get with the UI SCHEMA
|
Ok, that looks a bit better, but it seems as if the custom UI schema hasn't been registered yet. Let's start by cloning & building:
If you run into an error similar to (I don't know why it pops up, we have to check):
edit
Now let's go through the actual changes in this PR and how they are supposed to work:
In store.dispatch(Actions.registerUISchema(
(jsonSchema, schemaPath) => {
return schemaPath === '#/properties/firstarray' ? 2 : NOT_APPLICABLE;
},
{
type: 'VerticalLayout',
elements: [
{
type: 'Control',
scope: '#/properties/name'
},
{
type: 'Control',
scope: '#/properties/objectarrayofstrings/properties/choices'
}
]
}
));
This is how we basically end up with the UI schema we have registered before. I hope this all make sense and it's a little bit more clear how all of this works. If this doesn't work for you or you keep having problems, please update your fork and I'll have a look. |
@edgarmueller - I just updated with the additional changes in the last commit and is working now for me! The only couple of very minor things I can see at this point are:
Otherwise this all looks really great! I am going to experiment a bit with additional control options and playing around with the ui schema registry. I'll provide PR's for any that seem worthwhile adding back to the framework. Awesome work on this and thanks for the support getting through the testing/validation. |
* Add UI schema registry reducer * Add material array layout
* Remove package version hoisting warnings
a39d479
to
97a7dc7
Compare
Great, happy to hear it works now! I've re-based the branch with |
closing in favor of #1013 |
This PR aims at coming up with a solution for #994 and adds a UI schema registry which allows registering a custom UI schema that might be used by any renderer. It is only used by the
MaterialArrayLayoutRenderer
, which has also been added with this PR.A basic react application which democases the proposed solution and serves as a playground in the future also has been added.