-
Notifications
You must be signed in to change notification settings - Fork 649
arrayIndices to allow conditions to access the array index in nested arrays #742
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
arrayIndices to allow conditions to access the array index in nested arrays #742
Conversation
Has this feature made it into the core release yet? I need this tomorrow for a demo! |
@raquintero no the webpack babel branch is a newer version of the code and is still in progress. You can get the entire built version from the bootstrap decorator's webpack-babel branch and test if that will work for your demo, or otherwise copy these changes into your current version. I am looking into making some more significant inroads into the array behaviours soon, but not by tomorrow unfortunately. |
@Anthropic Thank you for the quick response sir!!! Nested arrays, conditional behavior, lack of OneOf:AnyOf support, the seemingly closed nature of retrieving absolute path, and not being able to use a function as attributes, are my biggest headaches so far. Other issues, such as adding unique id's, i18n support, applying tooltips/help support I've been able to work around by extending the decorators. |
@raquintero many of those are on the todo list, not sure about functions as attributes though. If you think it is a valid use case you could create an issue for discussion. Keep in mind that the schema itself is defined by json-schema.org and can't be changed from that but we do maintain the form definition. |
I wish this was documented, I am glad I verified before making a PR. |
Figured why just gripe about it, so I opened this #959 |
Thanks @scottux, I've been resting after a medical emergency little while back (I'm fully recovered as of today) it made me happy to see a PR for docs, thank you so much for taking the time, it always means a lot to me to know there's others that are willing to put some time in to help me, cheers! |
Glad you are feeling better. I have been using this package heavily for a project, so expect to hear more :) |
Description
When using nested arrays it is not possible to have a condition that targets specific elements in the nested array. ArrayIndex only gives you access to the inner most array index. I raised this as issue #596
Therefore I have added an additional property available in conditions that is similar to arrayIndex called arrayIndices which is an array of the array indices.
It can be used in a condition like this:
"condition": "model.grandParent[arrayIndices[0]].parent[arrayIndices[1]].child[arrayIndices[2]].age > 18
I have not altered arrayIndex to ensure it continues to work as is.
I have added a test to \tests\directives\schema-form-tests.js that uses a 3 deep array of the structure array.object.array.object.object.array.object (so arrays in arrays, and objects in objects). The test form contains conditions targeting elements all levels of the structure.
Fixes Related issues
#596
Checklist
@json-schema-form/angular-schema-form-lead