Bindings and actions
Bindings
Every property can contain a binding: {{ expression }}. Standing alone it keeps the type of the result (number, list, yes/no); inside text it is inserted as text – e.g. Hello {{user.email}} or {{query.tasks.total}} tasks.
Expressions are a safe subset of JavaScript, without eval: numbers, texts, true/false/null, lists […], objects {…}, a.b, a[b], a?.b, ! - + * / %, comparisons, && || ??, condition ? a : b and calls of the helper functions and some text/list methods (toUpperCase, includes, slice, join …). There is no window, no fetch and no functions of your own.
| Name | Content |
|---|---|
state.<name> |
app variables (tab App → Variables) |
el.<id> |
values of the elements (see Controls) |
query.<name> |
records, record, total, loading, error, data of the last run |
url.<name> |
parameters in the address of the page |
user |
id, email, role – null in public apps without login |
page, app |
current page (id, name, path), app (name, slug) |
row, item, values, value |
in events: selected row, item, form values, new value |
Helpers: len, upper, lower, str, num, round(x, digits), min, max, json, isEmpty, contains, first, pluck(list, field), sum(list, field), count, now, today, date, datetime, number(x, digits), currency(x, 'EUR', digits), fileUrl(query, file, thumbnail) – the address of a file of an attachment column (file = file id or the attachment field itself, thumbnail = the preview image), e.g. <img src="{{fileUrl('references', item.cover, true)}}"> or as the target of Open link. The query must be a reading query of the app that reaches the file’s table – dates and numbers in the interface language.
In the preview of the draft a bar at the top lists faulty bindings.
Actions
Events (click, submit, select, change, menu entry) run steps one after another. Every step can have a condition Only if. If a query fails, the chain stops with a message.
| Step | Parameters |
|---|---|
| Run query | query, parameters, form (its values as parameters) |
| Reload query | query (with the last parameters) |
| Set variable | name, value |
| Open page | page, parameters (in the address) |
| Open / close dialog | dialog |
| Show message | text, kind (info, ok, error) |
| Open link | address (http(s), mailto, tel or path), new tab |
| Reset form | form |
| Fill form | Form, values (object name → value, e.g. {{query.record.record}}); each input takes the value of its name or of its field |
| Export CSV | Element (a table, list or chart on the current page); downloads its data as CSV, like the CSV button |
| Ask for confirmation | Title, text, button label, dangerous; stops the chain when cancelled |
| Script | statements |
Scripts
A script consists of statements separated by line breaks or ;: assignments to state.… and el.<id>.value (also +=, -=) and if (…) { … } else { … }. It runs in the browser in the same sandbox as bindings. Example of a toggle:
state.onlyOpen = !state.onlyOpen
if (!state.onlyOpen) { el.search.value = '' }
Large editor: the ⤢ icon next to Script opens the code editor in a large window – with highlighting, line numbers and a syntax check while you type (the error is underlined where it is, the line is shown on top). Ctrl+Space suggests names: after state. the app variables, after el. the elements, after query. the queries, otherwise the helpers. Apply (or Ctrl+S) writes the script back, Cancel discards the changes. The same icon sits next to the HTML field of the HTML element: there with HTML highlighting and tag completion; the {{ … }} placeholders are checked and completed (Ctrl+Space inside {{ suggests record, state., el., query. and the helpers).
Logic that needs data of other tables or external systems belongs on the server: in a workflow or a custom endpoint.