Skip to content

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

Merged
merged 1 commit into from
Sep 21, 2016

Conversation

joelwkent
Copy link
Member

@joelwkent joelwkent commented Jul 26, 2016

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

  • I have read and understand the CONTRIBUTIONS.md file
  • I have searched for and linked related issues
  • I have created test cases to ensure quick resolution of the PR is easier
  • I am NOT targeting main branch
  • I did NOT include the dist folder in my PR

@json-schema-form/angular-schema-form-lead

@raquintero
Copy link

Has this feature made it into the core release yet? I need this tomorrow for a demo!

@Anthropic
Copy link
Member

@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.

@raquintero
Copy link

@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.

@Anthropic
Copy link
Member

Anthropic commented Oct 14, 2016

@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.

Anthropic added a commit that referenced this pull request Oct 16, 2016
@scottux
Copy link
Contributor

scottux commented Mar 13, 2018

I wish this was documented, I am glad I verified before making a PR.

@scottux
Copy link
Contributor

scottux commented Mar 13, 2018

Figured why just gripe about it, so I opened this #959

@Anthropic
Copy link
Member

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!

@scottux
Copy link
Contributor

scottux commented Mar 21, 2018

Glad you are feeling better. I have been using this package heavily for a project, so expect to hear more :)

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

Successfully merging this pull request may close these issues.

4 participants