Extension:VisualData/Queries in forms

Queries in forms edit

VisualData' Schema Builder supports queries on all option inputs [1] plus "query" widgets like Lookup element and MenuTagSearchMultiselect, a lookup element for multiple items displayed as tags.

The interface, accessible once selecting the correct property type/format and input, is the following:

 


by which it is possible to create relatively easily option input widgets with options taken from json-data, auto-completion inputs with the same data, and dependent values inputs.


Here is the classical example of the country-state-city dependency (see here for a live demo) :


 


The first field of the form (country) is a OOUI DropdownInputWidget with items taken from a template created using the following settings:

 


The second field (state) is a LookupElement with query

[[name::<country>]][[states/name::<value>~]]

where <country> is the name of the first field and <value> is the value being inserted in the input. The requested printout/property path is states/name. The query therefore will search json-data related to the schema "Country" with value of the property name equal to the value of the first field, and value of the property states/name equal to the input value of the state input.

The third field (city) uses this query

[[name::<country>]][[states/name::<state>]][[states/cities/name::<value>~]]

The query as above will search json-data related to the schema "Country" with value of the property name equal to the value of the first field, value of the property states/name equal to the second field, and value of the property states/cities/name equal to the city input value. The requested printout in this case is states/cities/name.

The option value formula (in this case <states/name>) represents the value of each option where the property path between angular brackets will be replaced by its actual value for each result entry. For instance "state <states/name>" will show a dropdown menu with values: "state a", "state b", etc.

It is also conditionally available an "options label formula" input by which to distinguish the values and the labels for each option. (available only for the input widgets allowing to distinguish between value and label). For instance one may use the following parser function:

{{#switch: {{{1}}}
 | AF = Afghanistan
 | AL = Albania
 | DZ = Algeria
 | ...
}}

as "options label formula" in order to display the country name where the requested printout is the country code.


See also edit


  1. * OO.ui.DropdownInputWidget
    • OO.ui.ComboBoxInputWidget
    • OO.ui.MenuTagMultiselectWidget
    • ButtonMultiselectWidget
    • OO.ui.RadioSelectInputWidget
    • OO.ui.CheckboxMultiselectInputWidget'