Skip to content

Layout

This is the basic layout structure of Brezel.

See LayoutSpec and layout structure.

  • identifier: string
  • position: int
  • icon: string
  • loaded_on_create_webhook: string (webhook event to call when this tab is loaded in module/create)
  • rows: array
  • cols: array
  • span: int
  • borderless: boolean
  • transparent: boolean
  • class: string
  • style: object

vertical_labels, no_labels and no_padding belong to field_group options, not column options.

  • components: array

A field_group renders the fields listed in options.fields. An entry can be a field identifier, a field object or an array of fields. An array renders its fields side by side in one row:

{
"type": "field_group",
"options": {
"show_combined_fields_label": true,
"fields": [
"name",
["weight_min", "weight_max"],
["carrier", "carrier_product"]
]
}
}

Without show_combined_fields_label, the default table mode labels the row with the label of its first field and shows no labels for the single fields. With vertical_labels, the row has no label, and each field shows its own label. With show_combined_fields_label: true, the row gets its own label, and each field in the row shows its own label above the input as a small label. The row label key uses the first field of the row:

<translation prefix>.fields.combined_<first field identifier>

For a module layout, the prefix is modules.<module>, so the rows above need modules.<module>.fields.combined_weight_min and modules.<module>.fields.combined_carrier. Inside a nested layout component, the prefix is extended by .layouts.<layout identifier>. Rows in a list field layout use the module prefix.

Add the key in every language. If the active language does not have the key, the SPA does not use the fallback locale. It builds a label from the last key segment, for example “Combined carrier”. An empty string ("") hides the row label on purpose. If all fields in a row are hidden_from_frontend, the row gets no label.

  • hidden_from_frontend Tabs, Rows, Cols and Components can be hidden from the frontend. This can be attached to a boolean condition.
{
"type": "text",
"options": {
"recipes": {
"hidden_from_frontend": "(Mahnungsstufe == 'final') ? false : true"
}
},
"identifier": "Zinsen"
}

This text field will only show up in the modal if the user selected “final” in Mahnungsstufe.

You can define which module page to land on after login by defining a menu entry like so:

[
{
"resource_menu": "main",
"resource": {
"name": "main",
"elements": [
{
"name": "dashboard",
"type": "entry",
"default": true
},
"addresses",
"shipments",
"billings",
"invoice",
"shop",
{
"name": "settings",
"type": "entry",
"recipes" : {
"visible": "user().id == 1 ? true : false",
"icon": "1 == 2 ? 'icon-name' : 'other-icon'"
}
}
]
}
}
]

In this case, the module “dashboard” is opened upon login. You can also use recipes to e.g. set the visibility or change the icon of an menu element.

You can use a layout to add components to the top bar. Just create a layout file like ‘top_bar.bake.json’ and set the type to “top_bar”.

[{
"resource_layout": "top_bar_layout",
"resource": {
"identifier": "top_bar_layout",
"type": "top_bar",
"spec": {
"tabs": [
{
"rows": [
{
"cols": [
{
"span": 24,
"components": [
{
"type": "widget",
"options": {
"view": "topbar.widget",
"widget": "custom"
}
}
]
}
]
}
]
}
]
}
}
}]

You can add custom content to the affix that is rendered on top of entity pages and contains the standard buttons and entity title. It is basically a layout row as described above, so defining it is the same as defining a row in a layout. To add content to the affix, add a property called affix to your layout spec.

{
"spec":
{
"affix": {
"cols": [
{
"options": {
"borderless": true
},
"components": [
{
"type": "buttons",
"options": {
"buttons": [
{
"icon": "save",
"identifier": "save",
"action": "save",
"style": "primary"
}
]
}
}
]
}
]
},
"tabs": []
}
}

You can define custom buttons which will be displayed in the top bar, or hidden in a list which opens on click on “actions”. To do so, the property name of the button object should be the same as your workflow webhook name which you want to trigger on click. You can also choose to hide standard buttons.

They have the following properties:

  • icon: string
  • style: string
  • forceTitle: boolean if this is not set or false, only the icon will be displayed.
{
"resource": {
"identifier": "example_module",
"title": "title_field",
"icon": "field-time",
"buttons": {
"print": {
"display": false
},
"myWorkflowTrigger": {
"icon": "check-circle",
"style": "default",
"forceTitle": true
}
}
}
}