-
Notifications
You must be signed in to change notification settings - Fork 5
View Types
Each object in the viewModel element above should have the following structure:
{
"type":<view type. On of the supported view types described below>
"source":<reference to the name field in a dataType definition or a literal string>
"items":<array of nested view items or literals>
"title":<Label displayed for the element>
"boxed":<boolean. If true will display this element within a box>
}
An element can be a display element or a view of an item in the dataModel.
Layout elements are used to format or layout the form and group elements in a more readable fashion.
The layout elements are row
, col
, template
, section
, repeat
, table
and grid
The literal type element can be used to display fixed text or HTML and is not tied to a source data type.
Any other element type is used to render a data type.
Each view type parameter is described in the section Supported view types below with the particulars of its use however parameters that are applicable to every view type are described here and are called general parameters.
String. Used to specify the CSS class to be added to the HTML rendered for a view type.
When using this parameter you must ensure that the classes are defined in the web application hosting the form.
String. This parameter will translate to width HTML attribute, as such it must be used with the sporadically, class would be preferred).
It will be handy usually for the columns view types for a table where more precise control of the column widths is required.
String. The name of the field.
Boolean. Whether the field should be readonly when the form is in edit mode. Useful for computed fields.
String. Name of the data type bound to this view type. In the case of nested view types, like a table, source must be a type that allow nested data types like list.
Object. Contains custom configuration specific to the view type.
- literal
- row
- col
- section
- repeat
- table
- text
- textarea
- readOnlyText
- selectOne
- selectManyCombo (text)
- select2 (text)
- link (text)
- selectMany (stringList)
- select2Many (stringList)
- selectManyCombo (stringList)
- number (number)
- currency (number)
- wordCloud (set)
- image (image)
- imageDialog (image)
- embeddedImage (image)
- document (document)
- autocomplete (species)
- speciesSelect (species)
- speciesSearchWithImagePreview (species)
- date (date)
- time (date)
- geoMap (geoMap)
- feature (feature)
- boolean (boolean)
Display text in source element, including html verbatim
None. This view type does not use any backing data type.
String. If absent or the value is 'edit' the value won't be displayed in read only mode. Thi is designed to allow to display instructional text when filling in forms, such instructions ase not required while viewing forms.
{
"source": "<a href='https://www.ala.org.au/faq/species-identification/' target='_blank'>Species identification FAQ</a>",
"type": "literal"
}
Contained items
for this type will be displayed in a separate row.
It corresponds with Bootstrap row-fluid
element.
None. This view type does not use any backing data type.
List of view types to be displayed each in a separate row
{
"computed": null,
"type": "row",
"items": [
{
"source": "<a href='https://www.ala.org.au/faq/species-identification/' target='_blank'>Species identification FAQ</a>",
"type": "literal"
}
]
}
Contained items
for this type will be displayed in a separate column.
To achieve its intended purpose, a col type should be nested within a row type.
It corresponds with Bootstrap span-n
element. The actual value for n will be calculated by the parent row divided by the number of siblings (items
) for this col.
None. This view type does not use any backing data type.
List of view types to be displayed each in a separate column
{
"type": "row",
"items": [{
"type": "col",
"items": [{
"type": "row",
"items": [{
"type": "col",
"items": [{
"preLabel": "Recorded by",
"source": "recordedBy",
"type": "text"
}]
}]
}, {
"type": "row",
"items": [{
"type": "col",
"items": [{
"preLabel": "Date",
"source": "surveyDate",
"type": "date"
}]
}]
}, {
"type": "row",
"items": [{
"type": "col",
"items": [{
"preLabel": "Time",
"source": "surveyStartTime",
"type": "time"
}]
}]
}, {
"type": "row",
"items": [{
"type": "col",
"items": [{
"preLabel": "Individuals",
"source": "individualCount",
"type": "number"
}]
}]
}]
}, {
"type": "col",
"items": [{
"preLabel": "Notes",
"source": "notes",
"type": "textarea",
"rows": 5
}]
}]
}
Contained items
for this type will be displayed within a box.
The purpose of this type is to facilitate grouping different elements of the form into "visual" groups or sections.
Depending on whether boxed
parameter is available and set to true it will change the CSS styles for the generated HTML output.
None. This view type does not use any backing data type.
List of view types contained within this section
Boolean. Display a border for this section.
Example 1
{
"boxed": true,
"title": "Location",
"type": "section",
"items": [{
"computed": null,
"type": "row",
"items": [{
"orientation": "horizontal",
"source": "location",
"type": "geoMap",
}]
}]
}
In Example 1, given that boxed is true the form generated will have a containing div element with CSS style boxed-heading
the title will be contained in the attribute data-content that can be used by the style to output the style as it suits.
The HTML output for the above example will look like this below:
<div class="boxed-heading" data-content="Location">
...
</div>
Example 2
{
"boxed": false,
"title": "Location",
"type": "section",
"items": [{
"computed": null,
"type": "row",
"items": [{
"orientation": "horizontal",
"source": "location",
"type": "geoMap",
}]
}]
}
In Example 2, given that boxed is false the form generated will have a containing div element with CSS style row-fluid output-section
the title will be prepended in an HTML h4
element. As with the previous example the CSS styles can be customised to suit your needs.
The HTML output for the above example will look like this below:
<h4>Location</h4>
<div class="row-fluid output-section">
...
</div>
repeat
is used to display a data list
of elements and when in edit mode it provides controls to add and remove elements.
list
Boolean that controls whether elements can be added/removed to its data model list
Text to display for remove button, only applicable when userAddedRows
is set to true and form is in edit mode.
Default value Remove Section
Text to display for remove button, only applicable when userAddedRows
is set to true and form is in edit mode.
Default value Add
{
"source": "outcomes",
"items": [
{
"items": [
{
"items": [
{
"source": "outcome",
"preLabel": {
"computed": "\\'Outcome \\' || (index + 1)"
},
"type": "text",
"readonly": true
},
{
"source": "status",
"preLabel": "Status of outcome",
"type": "selectOne"
},
{
"source": "outcomeNotAchievedReason",
"preLabel": "If the outcome was not achieved, what are the reasons?",
"type": "textarea"
},
{
"source": "outcomeResult",
"preLabel": "Describe the state of change detected between the baseline established at the commencement and follow-up monitoring",
"type": "textarea"
}
],
"type": "col"
}
],
"class": "output-section",
"type": "row"
}
],
"type":"repeat"
}
table
is used to display a data list
of elements in a tabular fashion. Each element of source
list
will be displayed in a separate row. What columns get displayed are specified by the columns
section. A table can optionally display additional rows, used as summary for example, by using the footer
parameter.
Finally a table can display a footer
.
list
It's an array of nested view model elements.
The elements source
refer to nested elements of the source
domain model for the table
.
The columns
parameter will drive 2 aspects of the table:
- Table Headers
- Contents for each column
For each element of columns array the following will be used to display a header for a column:
-
title
Is the text for the header -
width
Is the column width expressed as percentage. The sum for all elements should add up to 100% - The tooltip text for the help is sourced from the
description
property for thesource
dataType.
The columns for each row will be displayed as per the standard format used for each view type.
It is worth nothing that data layout types can't be used as a column element.
The only element of footer
is the element array rows
####### columns Very similar to the top level columns parameter for a table, this is an array of view types. The type of each element should not be a layout element.
More often than not each entry in columns will be a literal type or a type that can be computed in order for example to display and store aggregate data.
Integer. Number of rows to print when printing a blank form.
Boolean. Enable buttons to edit rows.
Boolean. Add controls to delete rows.
If the form itself is in read only mode this parameter has no effect.
Boolean. Hides button at the bottom of the table to load data into a table from a file.
Boolean. Shows button at the bottom of the table to add rows to the table.
TBC
Display a text box.
text.
This view type has no specific parameters
Display a text area.
This view type has no specific parameters
text.
Integer. Number of rows to display. Applicable only in edit mode.
Integer. Number of rows to display. Applicable only in edit mode.
Display the value of a text data model.
This is useful when displaying computed fields.
The difference between using readonlyText and literal is that the later is only for static text not bound to a data model field.
text.
This view type has no specific parameters
TBC Example does not show anything, possibly defaultValue need some KO trigger/event to be fired to be shown in the form.
Allows to select a value from a text list.
The source must specify the list of accepted values as part of the constraints parameter.
text.
This view type has no specific parameters