gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

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

Open borisvanschooten opened 5 years ago

borisvanschooten commented 5 years ago

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:

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 commented 5 years ago

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 commented 5 years ago

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