Addon to agentejo/Cockpit that renders layout component previews using component options.
Please note that only a subset of field types are handled at this time.
- LayoutComponents addon (for custom layout components with options JSON): https://github.com/agentejo/LayoutComponents
Clone this repo into addon/CockpitLayoutComponentPreviews in your cockpit root directory.
Add a ´preview´ key with an array of preview objects to the layout component options JSON.
Prints the field label if the field value is true
.
field
name of the boolean fieldbadge
render as a badge (default: false)
Example:
{
"preview": [
{
"field": "a_boolean_field",
"badge": true
}
]
}
Prints display value in a linked collectionlink item or for each in a set of items.
field
name of the collectionlink fieldbadge
render as a badge (overrideslabel
)label
will print the label iftrue
and has a single linked collection item and badge isfalse
(default: true)
Example:
{
"preview": [
{
"field": "a_collectionlink_field",
"label": false
}
]
}
Prints value of the field.
field
name of the fieldbadge
render as a badge (overrideslabel
)label
will print the label iftrue
Example:
{
"preview": [
{
"field": "a_text_or_number_or_select_field",
"badge": true
}
]
}
Prints asset info and a thumbnail of the asset is an image.
field
name of the asset fieldstyle
name of image style to use as thumbnail image (Requires https://github.com/pauloamgomes/ImageStyles addon)
Example:
{
"preview": [
{
"field": "an_asset_field",
"style": "thumbnail_style_name",
"newline": true
},
]
}
Strips the html and prints the first line with ellipsis.
field
name of the wysiwyg field
Example:
{
"preview": [
{
"field": "a_wysiwyg_field",
"newline": true
},
]
}
Prints the field specified with display
for each item in the repeater.
field
name of the repeater fielddisplay
name of field in each repeater item to printbadge
render as a badge
Example:
{
"preview": [
{
"field": "a_repeater_field",
"display": "field_in_repeater_item",
"badge": true
},
]
}
Prints a link to the file
field
name of the file field
Example:
{
"preview": [
{
"field": "a_file_field"
},
]
}
Prints the number of component(s) in the layout field.
field
name of the layout field
Example:
{
"preview": [
{
"field": "a_layout_field",
"newline": true
},
]
}
Prints the supplied text.
text
the text to print
Example:
{
"preview": [
{
"text": "The text that should be printed!"
},
]
}
Add newline: true
to any preview object to add linebreak after it is printed.