New dependency system; added copy function to array action bar #683
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Copy function adds some basic copy/paste functionality to array fields.
Dependencies (having one field appear only if another field has a specific value) are essential to how I use forms in my application. The existing Alpaca dependency facilities have serious limitations and are not easy to specify. So, I created a new dependency system that is both powerful and concise. Dependencies are specified as part of the options json, using a separate field "x_dependencies". This is an array of objects, with the following fields:
"field" : path to field that is to be checked (no leading slash). Use "[]" to indicate all elements of an array.
"values": array of values against which field is checked.
"enables": array of relative paths to fields that are to be enabled when field is equal to one of the values. The path root is the parent of the element indicated by field. So, dependencies can refer to siblings of the field element, or to elements deeper in the tree. "[]" can again be used to specify all elements of an array.
Example.
This checks if the type field of each element of the questions array is equal to either of the two given strings. If true, the range field in the same element and the desc.nld_nld.anchors subfields are enabled. If false, they are disabled (hidden).
The current system is limited to showing and hiding fields. No form validation is performed.