Skip to content
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

New dependency system; added copy function to array action bar #683

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

borisvanschooten
Copy link

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.

{
    "options": {
        "x_dependencies": [
            {
                "field": "questions[]/type",
                "values": ["likert","vas"],
                "enables": [ "desc/nld_nld/anchors", "range"]
            }
        ]
    }
}

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.

@ricardoee
Copy link

ricardoee commented Nov 14, 2018

One major limitation I'veexperienced with Alpaca is, it's not possible to check if a value is, for example, > n.

I have to list all the numbers i.e. [0,1,2,3,4,5,6,7,8,9,...] . Not much good if the number is in the thousands!

Are you able to add this functionality into this at all?

@borisvanschooten
Copy link
Author

borisvanschooten commented Nov 15, 2018

@ricardoee it shouldn't be too hard to add < <= > >= comparisons. I don't need them for my project though. I don't see much point in putting work in it if the pull request weren't accepted.

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

Successfully merging this pull request may close these issues.

3 participants