Layout DSL
Layout DSL is still under development and unstable
Layout DSL can be changed with layout-engine. Default layout-engine described here - aidbox.sdc/Hiccup
.
There are three types of layout nodes:
You can also set Layout rules or Customize node view.
Container node
Container node is a node that contains several children elements.
Typical description of node:
children - an array of child elements
File input
Allows user to attach a file to the document. Must be binded to a key with aidbox.sdc/attachment
type in document.
Media viewer
Gives ability to show some media content from diferent sources:
static url
files attached to document
You can also adjust :width
and :height
.
Currently supported content types:
image
video
PDF
Show static media content
Show attachments from the document
Label node
To show some text or field from document as static text, use aidbox.sdc/label
node
To show field from document as static text use :bind
key
Input node
Minimal example of input node:
bind - binding to SDCDocument field
Input node type
By default Aidbox FormLayouts supports five types of inputs:
text input
number input
choice
quantity
calculated field
Aidbox Forms has input-node inference logic based on special properties of the field schemas. But you also have ability to force some input types by specifying sdc-type in SDCDocument field
Text input
To define text input just define your field as zen/string
:
And bind some node in layout to this field:
Number input
Same as text input but use zen/number
in SDCDocument definition:
Choice & quantity input
Since choice and quantity types are usually represented as zen/map
in SDCDocument we should help input-type inference engine to select correect input-type by specifing additional properties of node or specify input-type directly by special key: sdc-type
in SDCDocument definition:
Example:
Subforms
If you need to to group input fields or handle multiple readings of some field, you can use subforms.
For example if need to store blood pressure in a map with two keys: systolic, diastolic you can declare your document in such way:
Then in form definition we can use subforms with their relative paths. We state that subforms binds to blood pressure map. Then all child elements in this subforms will be binded to fields in this blood-pressure
map
Collection subforms
If you have vector fields in your Document, you might need to use collection subforms to capture values.
Just declare your field as zen/vector
in the document:
And in subform definition set collection=true
Layout rules
For each node we can use two types of rules:
:sdc/disable-when
- disables node when calculating rule returns true (any non-nil value counts as true value):sdc/display-when
- displays node if calculating result returns true
Usage:
Customize node view
If you want to show something different than usual select component, you can customize visual view of node using :control
field.
Your DSL interperter should understand this :control
field
Last updated