@protobase/cli 0.40.8 → 0.40.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/package.js +1 -1
- package/package.json +6 -6
- package/skills/protobase/references/getting-started.md +8 -8
- package/skills/protobase/references/guides/api-functions.md +12 -12
- package/skills/protobase/references/guides/billing-page.md +2 -2
- package/skills/protobase/references/guides/create-page.md +5 -5
- package/skills/protobase/references/guides/deploy.md +6 -6
- package/skills/protobase/references/guides/export-a-list.md +2 -2
- package/skills/protobase/references/guides/field-type.md +2 -2
- package/skills/protobase/references/guides/first-composed-page.md +4 -4
- package/skills/protobase/references/guides/first-plugin.md +3 -3
- package/skills/protobase/references/guides/import-records.md +1 -1
- package/skills/protobase/references/guides/mobile-app.md +11 -4
- package/skills/protobase/references/guides/plugin-build.md +5 -5
- package/skills/protobase/references/guides/record-card.md +3 -3
- package/skills/protobase/references/guides/remote-resources.md +10 -10
- package/skills/protobase/references/guides/table-to-admin.md +5 -5
- package/skills/protobase/references/guides/theme-an-app.md +4 -4
- package/skills/protobase/references/reference/access.md +9 -9
- package/skills/protobase/references/reference/ai.md +6 -6
- package/skills/protobase/references/reference/api.md +25 -25
- package/skills/protobase/references/reference/app-identity.md +4 -4
- package/skills/protobase/references/reference/architecture.md +1 -1
- package/skills/protobase/references/reference/assistant.md +6 -6
- package/skills/protobase/references/reference/auth.md +20 -20
- package/skills/protobase/references/reference/blocks.md +13 -13
- package/skills/protobase/references/reference/bottom-bar.md +5 -5
- package/skills/protobase/references/reference/cli.md +63 -63
- package/skills/protobase/references/reference/client.md +5 -5
- package/skills/protobase/references/reference/comments.md +8 -8
- package/skills/protobase/references/reference/custom-components.md +18 -18
- package/skills/protobase/references/reference/data-config.md +26 -26
- package/skills/protobase/references/reference/email.md +8 -8
- package/skills/protobase/references/reference/events.md +5 -5
- package/skills/protobase/references/reference/files.md +7 -7
- package/skills/protobase/references/reference/forms.md +6 -6
- package/skills/protobase/references/reference/history.md +7 -7
- package/skills/protobase/references/reference/installable-app.md +1 -1
- package/skills/protobase/references/reference/jobs.md +5 -5
- package/skills/protobase/references/reference/layouts.md +11 -11
- package/skills/protobase/references/reference/live.md +4 -4
- package/skills/protobase/references/reference/mcp.md +5 -5
- package/skills/protobase/references/reference/plugins.md +20 -20
- package/skills/protobase/references/reference/remote-resources.md +15 -15
- package/skills/protobase/references/reference/sidebar.md +1 -1
- package/skills/protobase/references/reference/supabase-realtime.md +2 -2
- package/skills/protobase/references/reference/supabase-rest.md +2 -2
- package/skills/protobase/references/reference/supabase-storage.md +1 -1
- package/skills/protobase/references/reference/theme.md +5 -5
- package/skills/protobase/references/reference/ui-config.md +60 -60
- package/skills/protobase/references/reference/user-menu.md +3 -3
- package/skills/protobase/references/reference/versioning.md +5 -5
- package/skills/protobase/references/reference/webhooks.md +7 -7
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Views in ui.ts, with names, list columns, editing in the list, sorting records by hand (also an invoice's items), filters, charts (graphs of records per day or per value), exports to Excel and CSV, record layouts, related records (in a section or as dots in a list column), field hints, actions (with a dialog of inputs when they ask for some) and views per role.
|
|
6
6
|
|
|
7
|
-
A **view** says how the admin shows one resource: what its records are called, which columns the list has, which filters sit above it, how the record page is laid out, and which buttons it offers. It lives in `config/<resource>/ui.ts`; by convention every export of a `ui.ts` is picked up, and `config/index.ts` may export views too. A view only presents: what a user may see and do is decided by the [data config's access rules](data-config.md#access)
|
|
7
|
+
A **view** says how the admin shows one resource: what its records are called, which columns the list has, which filters sit above it, how the record page is laid out, and which buttons it offers. It lives in `config/<resource>/ui.ts`; by convention every export of a `ui.ts` is picked up, and `config/index.ts` may export views too. A view only presents: what a user may see and do is decided by the [data config's access rules](data-config.md#access), and `/api/meta` removes from each user's view every field they cannot read.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
import { view } from '@protobase/schema'
|
|
@@ -13,7 +13,7 @@ import type { repairs } from './data'
|
|
|
13
13
|
export const repairsView = view<typeof repairs>('repairs')
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
[`view<typeof resource>(name)`](https://docs.protobase.net/api/schema/functions/view/)
|
|
16
|
+
[`view<typeof resource>(name)`](https://docs.protobase.net/api/schema/functions/view/) takes the resource's type, so every field reference below (`r.status`) is checked by TypeScript. A view is immutable: each [method](https://docs.protobase.net/api/schema/interfaces/viewbuilder/) returns a new view, so one view can build on another. The examples are the files of the [bike shop guide](../guides/table-to-admin.md), where each step builds on the last.
|
|
17
17
|
|
|
18
18
|
## Names and columns
|
|
19
19
|
|
|
@@ -49,17 +49,17 @@ export const repairsView = view<typeof repairs>('repairs')
|
|
|
49
49
|
| --- | --- |
|
|
50
50
|
| `.names({ singular, plural })` | "New repair", "Repairs" in the sidebar, breadcrumbs and browser tabs. Default: the resource name in words. |
|
|
51
51
|
| `.title((r) => r.number)` | The field that names a record: in breadcrumbs, browser tabs, the record page's heading, relation links and search results. |
|
|
52
|
-
| `.searchResult((r) => ({ title?, subtitle? }))` | A record in the [global search](client.md#global-search)
|
|
52
|
+
| `.searchResult((r) => ({ title?, subtitle? }))` | A record in the [global search](client.md#global-search): `title` is one field or several joined by spaces (`[r.first_name, r.last_name]`, default: `.title`), `subtitle` the line under it (default: the first search field not in the title), replaced by the search field the text matched when neither line shows it. |
|
|
53
53
|
| `.list((r, d, c) => ({ columns, sort?, search?, filter?, editable?, displays?, default? }))` | The list's columns in order, fields or [related records](#related-records-in-a-list) (`c.related`); the `filter` it [opens with](#a-filter-the-list-opens-with); its starting `sort` as `[[field, 'asc' \| 'desc'], ...]`, on `.sortable()` fields; the fields the search box suggests, among the resource's `.search` fields, which decide what search matches on the server; the columns [edited in their cell](#editing-in-the-list); other ways to show it, see [List displays](#list-displays). `protobase build` fails on a sort or search field outside those. |
|
|
54
54
|
| `.fields((r) => ({ name: r.name.label(...) }))` | Hints per field, below. Calls add up. |
|
|
55
55
|
| `.help(text)` | A line under the list's title. |
|
|
56
|
-
| `.nav({ group, order, hidden, recent })` | Where the resource sits in the sidebar, and its [recent-record group](sidebar.md#recent-records)
|
|
56
|
+
| `.nav({ group, order, hidden, recent })` | Where the resource sits in the sidebar, and its [recent-record group](sidebar.md#recent-records). |
|
|
57
57
|
| `.icon(name)` | Carried in `/meta` for apps that render their own shell; the admin picks sidebar icons by resource name. |
|
|
58
58
|
| `.listOf((r) => r.listing_id)` | The list page shows the records this relation points at instead of the resource's own rows, such as the listings among a member's favorites. See [Favorites](#favorites). |
|
|
59
59
|
| `.signIn({ title, description, benefits?, icon?, signUp? })` | What a visitor who is not signed in is told about the resource, in place of its list and by a card's favorite button. See [Sign-in prompts](#sign-in-prompts). |
|
|
60
|
-
| `.form((r) => ({ name, fields, thanks, title?, perMinute? }))` | A public form at `/-/forms/<name>` that creates a record for anyone, signed in or not, behind a rate limit and a bot check. See [Public forms](forms.md)
|
|
60
|
+
| `.form((r) => ({ name, fields, thanks, title?, perMinute? }))` | A public form at `/-/forms/<name>` that creates a record for anyone, signed in or not, behind a rate limit and a bot check. See [Public forms](forms.md). |
|
|
61
61
|
|
|
62
|
-
A browser tab names what it shows, then the app's name ([`appName`](auth.md#configuration))
|
|
62
|
+
A browser tab names what it shows, then the app's name ([`appName`](auth.md#configuration)): `Nordlicht GmbH · Companies · Protobase` on a record page, the plural on a list, `New company · Companies · Protobase` on the create form, and a composed page's title on that page.
|
|
63
63
|
|
|
64
64
|
A click on a row of a list's table opens its record. Its title cell, the `.title` column or else the first, is a link to the record, so Cmd- or Ctrl-click, a middle click and the browser's link menu open it in a new tab or copy its address; embedded lists and the table of a list sorted by hand do the same.
|
|
65
65
|
|
|
@@ -73,12 +73,12 @@ Field hints:
|
|
|
73
73
|
| `.multiline()` | A text of several lines, such as a description: forms edit it in a box that grows with the text, so the page scrolls rather than the box, and the record page, a page's field blocks and a card's subtitle keep its line breaks (a card shows the first three lines). On the record page and the create form it takes the whole width of its section. Only a text field takes it; the list's table shows the text on one line. |
|
|
74
74
|
| `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page, a page's field blocks and the sidebar show it rendered as GitHub does, line breaks kept; raw HTML shows as text, links and images keep only http(s), mailto, tel and relative addresses, and links open in a new tab. A card's subtitle shows its first three lines rendered, its links as text; the list's table and a card's other lines show its text on one line without the marks. On the record page and the create form it takes the whole width of its section. Only a text field takes it, and the renderer loads with the first markdown shown. |
|
|
75
75
|
| `.prefix(text)`, `.suffix(text)`, `.decimals(n)` | Money and measures: `€` and `2` show `€1,234.50`, `.suffix(' m²')` shows `120 m²`. They show wherever the number does: records, cards, table cells, forms and the range filter. |
|
|
76
|
-
| `.icon(name)` | An icon before the value on a card's meta row: one of the names [actions](layouts.md#named-actions)
|
|
76
|
+
| `.icon(name)` | An icon before the value on a card's meta row: one of the names [actions](layouts.md#named-actions) take, such as `bed`, `calendar` or `cpu`, and above the value in a section of [key facts](#key-facts). Nowhere else shows it. |
|
|
77
77
|
| `.valueLabels({ value: text })` | How an enum's values read: `r.method.valueLabels({ ideal: 'iDEAL' })`. Only the enum's values are accepted. A value without a label shows as stored (`direct_debit`), so label every value that should read as words. |
|
|
78
78
|
| `.valueColors({ value: '#hex' })`, `.badgeShape('arrow')` | An enum's badges filled with a colour per value (the text turns white or black, whichever reads), and drawn as arrows pointing right, as on a rating scale. The property portal's energy label: `r.energy_label.format('badge').valueColors({ a: '#00a651', g: '#ed1c24' }).badgeShape('arrow')`. Only the enum's values are accepted. |
|
|
79
|
-
| `.widget(name, props?)` | Shows and edits the field with a [field type](plugins.md#field-types)
|
|
79
|
+
| `.widget(name, props?)` | Shows and edits the field with a [field type](plugins.md#field-types) of the project or a plugin, such as `r.status.widget('steps')` or `r.score.widget('rating', { max: 5 })`; `props` are plain data. Without it, or on a storage type it does not show, the field shows as it would without the hint. |
|
|
80
80
|
|
|
81
|
-
An enum's value labels show everywhere the admin shows its values: badges, select options, list and related-table cells, filter options and chips, record titles, the sidebar and search results. They are part of the view in `/api/meta`, so an app with its own screens can show them too, and [`enumLabel(value, labels)`](https://docs.protobase.net/api/schema/functions/enumlabel/)
|
|
81
|
+
An enum's value labels show everywhere the admin shows its values: badges, select options, list and related-table cells, filter options and chips, record titles, the sidebar and search results. They are part of the view in `/api/meta`, so an app with its own screens can show them too, and [`enumLabel(value, labels)`](https://docs.protobase.net/api/schema/functions/enumlabel/) from `@protobase/schema` reads a value the same way. A label for a value the enum does not have stops the server at startup, so renaming a value cannot leave a stale label behind.
|
|
82
82
|
|
|
83
83
|
The table's columns take their width from the first rows it shows, and keep it while it scrolls, filters and sorts: the `.title` column gets the largest share, other text a share as long as its values, and short values such as enums, booleans, numbers, amounts and dates their own width whole. A value cut short shows whole when hovered. On a desktop the title column is pinned to the left by default, with the column before it when it is the second, so it stays in view when the table scrolls sideways; the column menu unpins it, and the choice is kept. Embedded lists and a page's `Table` blocks size their columns the same way.
|
|
84
84
|
|
|
@@ -127,7 +127,7 @@ view<typeof products>('products').list((r) => ({
|
|
|
127
127
|
}))
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
A click on an editable cell chooses it instead of opening the record, and a second click, a double-click, Enter or F2 opens the field's editor in the cell: the one the record page uses, a [field type](plugins.md#field-types)
|
|
130
|
+
A click on an editable cell chooses it instead of opening the record, and a second click, a double-click, Enter or F2 opens the field's editor in the cell: the one the record page uses, a [field type](plugins.md#field-types)'s editor included. Enter, Tab or a click elsewhere saves the change, and Escape leaves the value as it was; a switch or a choice from a list saves as soon as it changes. The arrow keys move between the cells, Tab and Shift+Tab along the row, and Tab from an editor saves it and goes on to the row's next editable cell. Enter on a cell that is not editable opens its record. An editable title cell is no link to the record; the row's other cells still open it.
|
|
131
131
|
|
|
132
132
|
Each change is a `PATCH` of that one field with the row's ETag, so it is refused when someone else changed the record since the list loaded it. The cell shows the new value while it saves; when the server refuses, the cell gets its old value back, or the record's current one when someone else changed it, and a toast says why, such as the field's validation message.
|
|
133
133
|
|
|
@@ -137,7 +137,7 @@ An editable column is a field of the resource with an editor of one line that th
|
|
|
137
137
|
|
|
138
138
|
### Reordering by hand
|
|
139
139
|
|
|
140
|
-
Records with an order of their own, such as the products in the order a shop lists them or an invoice's items in the order it prints them, are put in order by dragging them. The resource names the integer field that holds the order with [`.position(...)`](data-config.md#resource)
|
|
140
|
+
Records with an order of their own, such as the products in the order a shop lists them or an invoice's items in the order it prints them, are put in order by dragging them. The resource names the integer field that holds the order with [`.position(...)`](data-config.md#resource), 1 the first; with `within`, a relation, each parent's records have an order of their own:
|
|
141
141
|
|
|
142
142
|
```ts title="docs-examples/reference/invoice-items.ts"
|
|
143
143
|
import { f, l, resource, view } from '@protobase/schema'
|
|
@@ -195,9 +195,9 @@ export const invoiceItemsView = view<typeof invoiceItems>('invoice_items')
|
|
|
195
195
|
|
|
196
196
|
The list of a resource ordered as one, such as the products, has a **Reorder** button beside its other buttons; a related section of records ordered within the page's record, such as the invoice's items, has one at the end of its title's line. **Reorder** shows every record in its order in the list's table, without the filters, search, chart and display switch, with a drag handle in each row where its checkbox was, and the page scrolls them; **Done** goes back. A row moves by dragging its handle, by a long press and drag on a touch screen, or from the keyboard: Space on a handle picks the row up, the up and down arrow keys move it, Space or Enter drops it and Escape puts it back, and a screen reader is told each step. The rest of the row still opens its record.
|
|
197
197
|
|
|
198
|
-
Each drop shows at once and is saved straight away: one [batch `reorder`](api.md#batch-writes)
|
|
198
|
+
Each drop shows at once and is saved straight away: one [batch `reorder`](api.md#batch-writes) sends only the stretch of records whose place changed, with the ETags they were listed with, and numbers them on from the record before them; it reaches further only where a gap or a tie left by an earlier write needs it, so a list of thousands saves a short move as a few records. Drops made while one saves are saved after it. A saved drop says so in a toast with **Undo**, which puts back the positions it changed; see [Dragging in the list](#dragging-in-the-list). A refusal, such as a record someone else changed since, puts the rows back as the server has them, with the reason. Every list of the resource reloads afterwards.
|
|
199
199
|
|
|
200
|
-
A user who may not update the resource or write the field gets no **Reorder**, and `/api/meta` leaves out `position` for one who cannot read its field or its `within`. A related section offers it only when it lists all of the parent's records: its `field` is the `within` relation, without a `filter` or `through`. The list page does not offer it for a resource ordered within a parent, since its list mixes the parents. The field must be `.sortable()` and `within` a `.filterable()` relation, checked when the config loads, and [`protobase doctor`](cli.md#doctor)
|
|
200
|
+
A user who may not update the resource or write the field gets no **Reorder**, and `/api/meta` leaves out `position` for one who cannot read its field or its `within`. A related section offers it only when it lists all of the parent's records: its `field` is the `within` relation, without a `filter` or `through`. The list page does not offer it for a resource ordered within a parent, since its list mixes the parents. The field must be `.sortable()` and `within` a `.filterable()` relation, checked when the config loads, and [`protobase doctor`](cli.md#doctor) checks that an index serves each read in the field's order, such as `(invoice_id, position)`. Records created later are not numbered for you: give them a position, or the next drop numbers them, after the others when the field is empty.
|
|
201
201
|
|
|
202
202
|
### Dragging in the list
|
|
203
203
|
|
|
@@ -248,7 +248,7 @@ Some records wait for others, such as a task blocked by another task. With `afte
|
|
|
248
248
|
|
|
249
249
|
`field` and `key` are filterable relations of the join resource to the ranked one: `field` holds the record that waits, `key` the record it waits for. `filter` narrows the join records and `while` the records waited for, both optional. The ranked resource needs a key of one field; the config is checked when it loads.
|
|
250
250
|
|
|
251
|
-
The server's [`reorder`](api.md#batch-writes)
|
|
251
|
+
The server's [`reorder`](api.md#batch-writes), and a create or update that writes the position, refuse an order that puts a record at or above a pending record it depends on, or one of those at or below it. Pairs already out of order, such as a dependency added after the ranking, do not block other moves. The list's `drag: { rank: true }` follows it on the table and the board without another option. Before it saves a drop, it reads the record's dependencies through the list API, so the join resource's `field` and `key` need an index. A card or row dropped above a record it depends on lands in the first place below that keeps the order, and a warning names that record by its title. On a board the ranks are those of every column, so a card whose dependency in another column ranks above its whole column takes the last place, with a rank just above that dependency. With no such place, it stays where it was, with the same warning.
|
|
252
252
|
|
|
253
253
|
#### Board drops
|
|
254
254
|
|
|
@@ -280,7 +280,7 @@ view('repairs').list((r) => ({
|
|
|
280
280
|
})).filters((r, w) => [w.facets(r.status)])
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
`filter` is an AIP-160 filter the list opens with when its address names none, whichever display it shows. Written in the form the widgets read (`status = "todo"` or `in(status, "todo", "doing")` on a facets field), it shows as the widgets' chips, which the person can clear or change; the change is kept in the page's address (an empty `?filter=` is a list cleared of it), and opening the list from the menu starts from the default again. A link's own filter replaces it, and so do "View all", a stat or a chart slice, which open on exactly what they counted. A board leaves out the columns a top-level `=` or `in(...)` clause on its field rules out. `protobase build` checks the filter against the resource, and [`protobase doctor`](cli.md#doctor)
|
|
283
|
+
`filter` is an AIP-160 filter the list opens with when its address names none, whichever display it shows. Written in the form the widgets read (`status = "todo"` or `in(status, "todo", "doing")` on a facets field), it shows as the widgets' chips, which the person can clear or change; the change is kept in the page's address (an empty `?filter=` is a list cleared of it), and opening the list from the menu starts from the default again. A link's own filter replaces it, and so do "View all", a stat or a chart slice, which open on exactly what they counted. A board leaves out the columns a top-level `=` or `in(...)` clause on its field rules out. `protobase build` checks the filter against the resource, and [`protobase doctor`](cli.md#doctor) checks that an index serves it.
|
|
284
284
|
|
|
285
285
|
## More than one list
|
|
286
286
|
|
|
@@ -295,7 +295,7 @@ view<typeof changelog>('changelog')
|
|
|
295
295
|
.filters((r, w) => [w.dateRange(r.closed_on)]))
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
-
`namedList(name, build)` adds another list of the same resource, with a sidebar entry of its own at `/<resource>?list=<name>`. The callback gets a fresh view and sets its `names` (the entry's label, required), `nav`, `help`, `list`, `filters` and `chart`; none of them come from the view's own list, so it has its own columns, opening filter and displays. Everything else stays the view's: field hints, title, actions, the record page, export, import, create and saved searches. A record opened from a named list lives at the resource's one address, `/<resource>/<key>`, and the sidebar marks the resource's main entry there. `protobase build` and [`protobase doctor`](cli.md#doctor)
|
|
298
|
+
`namedList(name, build)` adds another list of the same resource, with a sidebar entry of its own at `/<resource>?list=<name>`. The callback gets a fresh view and sets its `names` (the entry's label, required), `nav`, `help`, `list`, `filters` and `chart`; none of them come from the view's own list, so it has its own columns, opening filter and displays. Everything else stays the view's: field hints, title, actions, the record page, export, import, create and saved searches. A record opened from a named list lives at the resource's one address, `/<resource>/<key>`, and the sidebar marks the resource's main entry there. `protobase build` and [`protobase doctor`](cli.md#doctor) check a named list like the view's own list, and `/meta` prunes it the same way. The builder throws on a name that does not fit an address, a repeated name, a missing `names`, anything else set in the callback and `nav.recent`; a view with `listOf` or `searchesOf` cannot have named lists. A named list is not offered in the bottom bar, the user menu or a page's blocks.
|
|
299
299
|
|
|
300
300
|
## Filters and the chart
|
|
301
301
|
|
|
@@ -317,7 +317,7 @@ export const repairsView = named
|
|
|
317
317
|
.chart((r) => ({ field: r.booked_on, range: '30d', granularity: 'day' }))
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
`.filters((r, w) => [...])` puts widgets above the list, in order. Each needs a field that is `.filterable()`, which [`protobase build`](cli.md#build)
|
|
320
|
+
`.filters((r, w) => [...])` puts widgets above the list, in order. Each needs a field that is `.filterable()`, which [`protobase build`](cli.md#build) checks, and an index that serves it, as the [scan guard](api.md#safety) and [`protobase doctor`](cli.md#doctor) check; together they write the list's `?filter=`, so a filtered list can be bookmarked and shared.
|
|
321
321
|
|
|
322
322
|
| Widget | |
|
|
323
323
|
| --- | --- |
|
|
@@ -335,7 +335,7 @@ Every widget takes `secondary: true` (e.g. `w.facets(r.agent, { secondary: true
|
|
|
335
335
|
|
|
336
336
|
A list can show a graph of how many of its records fall on each hour, day, week or month, such as a daily graph of new listings. `.chart((r) => ({ field, range, granularity }))` draws records per day or week over a date or timestamp field above the list, following its filters: `range` is `7d`, `30d`, `90d`, `1y` or `all`, `granularity` `hour`, `day`, `week` or `month`.
|
|
337
337
|
|
|
338
|
-
It can show the list's records per value of a field instead, such as orders per status or revenue per customer: `.chart((r) => ({ groupBy: r.status, type: 'donut' }))`. `groupBy` is a filterable field that is no date, such as an enum, a boolean or a relation, with an index that serves it; `type` is `bar` (the default, the largest first) or `donut`; `sum: r.total` or `average: r.total` adds up a numeric field instead of counting (a donut takes no average); `limit` is how many values it shows, 10 by default. Each value links to the list filtered to it, and follows the list's filters, its own terms on `groupBy` included. A date, file or JSON `groupBy`, or a `sum` of a field that is no number, stops the server at startup, and a user who cannot read one of its fields sees no chart. A page shows the same with the [`Chart`](blocks.md#chart)
|
|
338
|
+
It can show the list's records per value of a field instead, such as orders per status or revenue per customer: `.chart((r) => ({ groupBy: r.status, type: 'donut' }))`. `groupBy` is a filterable field that is no date, such as an enum, a boolean or a relation, with an index that serves it; `type` is `bar` (the default, the largest first) or `donut`; `sum: r.total` or `average: r.total` adds up a numeric field instead of counting (a donut takes no average); `limit` is how many values it shows, 10 by default. Each value links to the list filtered to it, and follows the list's filters, its own terms on `groupBy` included. A date, file or JSON `groupBy`, or a `sum` of a field that is no number, stops the server at startup, and a user who cannot read one of its fields sees no chart. A page shows the same with the [`Chart`](blocks.md#chart) block.
|
|
339
339
|
|
|
340
340
|
## List displays
|
|
341
341
|
|
|
@@ -376,18 +376,18 @@ export const repairsView = daily
|
|
|
376
376
|
|
|
377
377
|
| Display | |
|
|
378
378
|
| --- | --- |
|
|
379
|
-
| `d.cards({ image?, title?, subtitle?, amount?, badge?, meta?, footer?, flags?, dots? }, { name?, label?, icon?, card?, photos?, favorite? })` | A card per record, opening it: `image`, a [file field](files.md)
|
|
380
|
-
| `d.map({ latitude, longitude, approximate?, exact?, radius?, area? }, { name?, label?, icon?, cards?, defaultRadius? })` | The matching records in the map's view, with how many there are below it; it asks again as it pans and zooms, through the list API's [`:map`](api.md#maps)
|
|
379
|
+
| `d.cards({ image?, title?, subtitle?, amount?, badge?, meta?, footer?, flags?, dots? }, { name?, label?, icon?, card?, photos?, favorite? })` | A card per record, opening it: `image`, a [file field](files.md), as a picture across the card's top (a raster image; anything else leaves the frame empty), then `title` (default: the view's `.title`) over `subtitle`, `badge` drawn as a badge with its value labels, `amount` the first of its fields with a value in bold (its suffix, such as ` /month`, not), such as a purchase price or else a rent, and a few small `meta` fields such as dates, each only when it has a value, after its field's `.icon` and as a badge when its field's format is `badge`. `footer` is a line at the card's bottom of its fields with a value, joined by bullets, such as a place and an agent. `flags` are boolean fields shown as small badges of their labels when true, such as a garden or parking. `dots` are [related columns](#related-records-in-a-list) of the list, each a line of its dots at the card's bottom. A relation shows the name of the record it points at. With `card`, a component declared with `component('RepairCard')` draws each card's content from the row of those fields instead (see [Record cards](custom-components.md#record-cards)). With `photos`, the picture steps through more photos, by swipe or arrows (see [Card photos](#card-photos)). With `favorite`, a heart in the card's top right corner saves the record (see [Favorites](#favorites)). Named `cards` unless `name` says otherwise. |
|
|
380
|
+
| `d.map({ latitude, longitude, approximate?, exact?, radius?, area? }, { name?, label?, icon?, cards?, defaultRadius? })` | The matching records in the map's view, with how many there are below it; it asks again as it pans and zooms, through the list API's [`:map`](api.md#maps). From far out it shows a count for each part of the map, which zooms in when chosen; close in, or with few records in view, the records themselves. Nearby records share a marker with their count; choosing one shows the record's card at the map's bottom, with arrows through the marker's records, and choosing the map elsewhere or closing the card clears it. The card is the one of the cards display `cards` names, else the list's first cards display, else the record's title. A record at an approximate position has a hollow marker and the area around it; see [Approximate positions](#approximate-positions). Named `map` unless `name` says otherwise. See [Maps](#maps). |
|
|
381
381
|
| `d.board({ by, title?, subtitle?, badge?, meta? }, { name?, label?, icon? })` | A column per value of the enum field `by`, each with how many records have it, and a card per record that opens it: `title` (default: the view's `.title`) over `subtitle`, with `badge` and a few small `meta` fields, as the built-in card of `d.cards` draws them. With the list's `drag: { board: true }`, dragging a card to another column, or moving it with the keyboard, saves the record with that column's value, or with `drag: { board: 'name' }` runs that [board drop](#board-drops)'s write; with `drag: { rank: true }`, cards are reordered within a column when the resource has a `.position()`. Named `board` unless `name` says otherwise. See [Boards](#boards). |
|
|
382
382
|
| `d.calendar({ start, end?, title? }, { name?, label?, icon? })` | The records on the days from their date or timestamp field `start` to `end`, or on their start day alone, in a month grid or a week grid, each event a link to its record showing `title` (default: the view's `.title`). Dragging an event to another day, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `calendar` unless `name` says otherwise. See [Calendars](#calendars). |
|
|
383
383
|
| `d.timeline({ start, end?, group?, title? }, { name?, label?, icon? })` | A Gantt-style timeline: each record a row with a bar from its date or timestamp field `start` to `end`, or on its start day alone, over a week, a month or a quarter, in lanes by the values of `group`. Each bar is a link to its record showing `title` (default: the view's `.title`). Dragging a bar along its row, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `timeline` unless `name` says otherwise. See [Timelines](#timelines). |
|
|
384
|
-
| `d.custom(Component, { name, label, fields, props?, icon? })` | The rows drawn by a [custom component](custom-components.md#list-displays)
|
|
384
|
+
| `d.custom(Component, { name, label, fields, props?, icon? })` | The rows drawn by a [custom component](custom-components.md#list-displays). `fields` are the fields it shows, loaded with the names of the records relations point at; `props` are plain data, with `r.field` where it takes a field. |
|
|
385
385
|
|
|
386
386
|
With displays, the list page has a switch at the right of its title: the table first, then each display by its `label`, with its `icon` (`table`, `cards`, `kanban`, `board`, `list`, `calendar` or `timeline`). Below the `md` breakpoint (768px) the switch is a menu of the same choices. The choice is in the address, `/repairs?display=cards`, so a reload, a bookmark or a shared link opens the same display; `default` names the display `/repairs` opens in, the table when it is left out. On a phone, below Tailwind's `sm` breakpoint (640px), a list with a cards display opens in it instead: the `default` when that is a cards display, else the first. A list without one opens in a built-in **List** there: a row per record with its `.title`, the first enum column as a badge on its right, and the next two columns but booleans on a muted line below, at `?display=rows`. The display menu offers the table beside it. A `?display=` in the address wins on any screen. A display without column headers has a sort menu over the sortable fields it shows, beside the filters, or below `md` in the filters sheet, whose button sits left of the search box. Selecting rows, deleting them in bulk and the row menu stay on the table, which every list keeps.
|
|
387
387
|
|
|
388
388
|
The table, the cards, a board, a calendar and a timeline scroll with the page, which is as tall as all their rows, with the browser's own scrolling: only the rows and cards in view are drawn and loaded, so a list of any length scrolls at once. Coming back to the table or the cards, by Back or by a link to the same list, shows the same rows at the same height, after a reload too; another sort or filter starts at the top. The table's header stays below the top bar while the page scrolls. Every card is as tall as the tallest one drawn at that width. A custom display scrolls with the page as well, as every other page of the app does; the map fills the screen between the top bar and a phone's bottom bar instead, and does not scroll. Where scrollbars take room, as on Windows, the page keeps room for one even while it fits, so the cards keep their width as the scrollbar comes and goes.
|
|
389
389
|
|
|
390
|
-
Display names are checked when the config loads: unique, not `table`, and `default` names one. Their fields are checked when the server starts, and may not be [sensitive](data-config.md#sensitive-fields)
|
|
390
|
+
Display names are checked when the config loads: unique, not `table`, and `default` names one. Their fields are checked when the server starts, and may not be [sensitive](data-config.md#sensitive-fields). In `/api/meta`, a user's displays lose the fields they cannot read, and a custom display whose `props` name one is left out; the list then opens in the table when its default display went.
|
|
391
391
|
|
|
392
392
|
### Boards
|
|
393
393
|
|
|
@@ -395,9 +395,9 @@ Display names are checked when the config loads: unique, not `table`, and `defau
|
|
|
395
395
|
|
|
396
396
|
Each column reads its own records through the list API, with the list's filter, search and order and its value added, such as `(search("brompton")) AND status = "ready"`, page by page with **Show more** at its bottom. A filter on `by` itself leaves the other columns empty. The sort menu orders the cards in every column, unless the resource has a position. In an embedded list each column shows its first records, up to the list's limit, and **View all** opens the whole board.
|
|
397
397
|
|
|
398
|
-
With the list's `drag: { board: true }` (see [Dragging in the list](#dragging-in-the-list)), a card moves to another column by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on a card picks it up, the left and right arrow keys move it between columns, Space or Enter drops it and Escape puts it back; a screen reader is told each step. A move is one update of the record, `by` set to the column's value with the ETag the card was listed with, the same request a named [`a.update`](layouts.md#named-actions)
|
|
398
|
+
With the list's `drag: { board: true }` (see [Dragging in the list](#dragging-in-the-list)), a card moves to another column by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on a card picks it up, the left and right arrow keys move it between columns, Space or Enter drops it and Escape puts it back; a screen reader is told each step. A move is one update of the record, `by` set to the column's value with the ETag the card was listed with, the same request a named [`a.update`](layouts.md#named-actions) sends. So the resource's [access rules](access.md) and `validate` decide: the card shows in its new column at once, a refused move puts it back with the server's reason, such as `validate`'s message, and a record changed by someone else since it was listed is refused too, as a stale ETag is. Every list of the resource reloads afterwards. A user who may not update the resource, or the `by` field, or a record its [row filters](access.md#restricted-model-and-row-filters) keep them from updating, can open its card but not move it.
|
|
399
399
|
|
|
400
|
-
A resource with a [`.position(...)`](data-config.md#resource)
|
|
400
|
+
A resource with a [`.position(...)`](data-config.md#resource) and no `within` has its board's columns in that order instead of the list's, so the board has no sort menu:
|
|
401
401
|
|
|
402
402
|
```ts title="docs-examples/reference/ranked-board.ts"
|
|
403
403
|
import { f, resource, view } from '@protobase/schema'
|
|
@@ -427,9 +427,9 @@ export const tasksView = view<typeof tasks>('tasks')
|
|
|
427
427
|
}))
|
|
428
428
|
```
|
|
429
429
|
|
|
430
|
-
With the list's `drag: { rank: true }`, a card then moves within its column by dragging it, or from the keyboard: Space, the up and down arrow keys, and Space again. In another column it lands where it is dropped, before the card under it or after the last one; the left and right arrow keys put it at the top. A screen reader is told the column and the place. A drop is one [batch write](api.md#batch-writes)
|
|
430
|
+
With the list's `drag: { rank: true }`, a card then moves within its column by dragging it, or from the keyboard: Space, the up and down arrow keys, and Space again. In another column it lands where it is dropped, before the card under it or after the last one; the left and right arrow keys put it at the top. A screen reader is told the column and the place. A drop is one [batch write](api.md#batch-writes): in another column first the update of `by` with the card's ETag, then a `reorder` numbering the column's cards 1, 2, 3, ... down to the last one that moved, each with its ETag. So access, `validate` and a stale ETag refuse it as they do a column move, and a refusal puts the cards back with the reason. The numbers are per column after a drop, so a unique index on the position alone would clash, while one that includes `by` is fine. Changing the order takes the right to update the position field, as **Reorder** does; a user without it, or a board without `rank`, moves cards between columns only, as on a board without a position, and one without `board` keeps each card in its column. A resource without a position, or with `within`, keeps the list's order.
|
|
431
431
|
|
|
432
|
-
`by` must be a filterable enum field, checked when the config loads and when the server starts, since each column filters by it. [`protobase doctor`](cli.md#doctor)
|
|
432
|
+
`by` must be a filterable enum field, checked when the config loads and when the server starts, since each column filters by it. [`protobase doctor`](cli.md#doctor) checks that an index serves each column's filter in the list's order, or the position's, as it does the list's. In `/api/meta`, a user who cannot read `by` gets the list without the board, opening in the table when it was the default, and a card loses the fields they cannot read.
|
|
433
433
|
|
|
434
434
|
### Calendars
|
|
435
435
|
|
|
@@ -437,9 +437,9 @@ With the list's `drag: { rank: true }`, a card then moves within its column by d
|
|
|
437
437
|
|
|
438
438
|
The calendar reads the days it shows alone through the list API, with the list's filter and search and the days added, in start order: `(search("brompton")) AND (booked_on >= "2026-09-28" AND booked_on < "2026-11-02")`, and with an `end` also the records starting before the first day and ending on or after it, `OR (booked_on < "2026-09-28" AND ready_on >= "2026-09-28")`. It loads at most 500 records for a month or week, and says so when more match, asking for a narrower filter. Its order is fixed, so it has no sort menu. A record without a `start` value is on no day, and does not show.
|
|
439
439
|
|
|
440
|
-
An event moves to another day by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on an event picks it up, the left and right arrow keys move it a day and the up and down keys a week, Space or Enter drops it and Escape puts it back; a screen reader is told each day. A move is one update of the record with the ETag the event was listed with, `start`, and `end` when it has one, moved by the same days, a timestamp keeping its time of day. So the resource's [access rules](access.md)
|
|
440
|
+
An event moves to another day by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on an event picks it up, the left and right arrow keys move it a day and the up and down keys a week, Space or Enter drops it and Escape puts it back; a screen reader is told each day. A move is one update of the record with the ETag the event was listed with, `start`, and `end` when it has one, moved by the same days, a timestamp keeping its time of day. So the resource's [access rules](access.md) and `validate` decide, as they do a board's moves: the event shows on its new day at once, and a refused move puts it back with the server's reason. A user who may not update the resource, `start` or `end`, or the record, can open its event but not move it.
|
|
441
441
|
|
|
442
|
-
`start` must be a filterable date or timestamp field, and `end` a filterable field of the same type, checked when the config loads and when the server starts. [`protobase doctor`](cli.md#doctor)
|
|
442
|
+
`start` must be a filterable date or timestamp field, and `end` a filterable field of the same type, checked when the config loads and when the server starts. [`protobase doctor`](cli.md#doctor) checks that indexes serve the days' filter on `start`, and on `end` when it is set. In `/api/meta`, a user who cannot read `start` gets the list without the calendar, opening in the table when it was the default, and one who cannot read `end` or `title` gets the calendar without them.
|
|
443
443
|
|
|
444
444
|
### Timelines
|
|
445
445
|
|
|
@@ -453,13 +453,13 @@ A bar moves along its row by dragging it, by a long press and drag on a touch sc
|
|
|
453
453
|
|
|
454
454
|
### Card photos
|
|
455
455
|
|
|
456
|
-
`photos: { resource, field, image, sort? }` names where a card's further photos come from: the records of `resource` whose relation `field` points at the card's record, in `sort` order, each shown by its file field `image`. The card's picture snaps photo by photo as it is swiped on a touch screen, and shows a left and a right arrow while the pointer is over it. The photos come with the list's records, in the same request through the list API's [`photos`](api.md#card-photos)
|
|
456
|
+
`photos: { resource, field, image, sort? }` names where a card's further photos come from: the records of `resource` whose relation `field` points at the card's record, in `sort` order, each shown by its file field `image`. The card's picture snaps photo by photo as it is swiped on a touch screen, and shows a left and a right arrow while the pointer is over it. The photos come with the list's records, in the same request through the list API's [`photos`](api.md#card-photos), so every card on the page has them from the start, and a map's card too. The card's own `image` comes first and is not shown twice when it is among the photos too, and a card steps through ten pictures at most, its own among them; the arrows wrap around at both ends, dots under the picture mark the photo shown, and a card with no further photos has no arrows. Swiping or pressing an arrow does not open the record; tapping the picture does. In a row that scrolls sideways, as an embedded list shows its cards on a phone, a swipe scrolls the row instead, and the arrows show at all times on a touch screen. A card drawn by a `card` component has no arrows.
|
|
457
457
|
|
|
458
458
|
```ts
|
|
459
459
|
d.cards({ image: r.photo, title: r.address }, { photos: { resource: 'listing_photos', field: 'listing_id', image: 'photo', sort: 'position' } })
|
|
460
460
|
```
|
|
461
461
|
|
|
462
|
-
The server checks `photos` when it starts: `field` is a filterable relation to the list's resource, `image` a file field and `sort` a valid order on `resource`, and every cards display of the list names the same `photos`, since its records load with one set. One query reads the photos of the whole page, the first of each record by an index on `field` and the sorted fields, such as `unique (listing_id, position)`; the [scan guard](api.md#safety)
|
|
462
|
+
The server checks `photos` when it starts: `field` is a filterable relation to the list's resource, `image` a file field and `sort` a valid order on `resource`, and every cards display of the list names the same `photos`, since its records load with one set. One query reads the photos of the whole page, the first of each record by an index on `field` and the sorted fields, such as `unique (listing_id, position)`; the [scan guard](api.md#safety) checks that one serves it, as it does a list's filter. In `/api/meta`, a user who cannot list those photos, or read `field`, `image` or the sorted fields, gets the cards without them, and the list API brings them only the photos they could list themselves.
|
|
463
463
|
|
|
464
464
|
### Favorites
|
|
465
465
|
|
|
@@ -477,13 +477,13 @@ d.cards({ image: r.photo, title: r.address }, { favorite: { resource: 'favorites
|
|
|
477
477
|
view<typeof favorites>('favorites').names({ singular: 'Favorite', plural: 'Favorites' }).listOf((r) => r.listing_id)
|
|
478
478
|
```
|
|
479
479
|
|
|
480
|
-
The server checks `favorite` when it starts: `resource` has an [owner](data-config.md#access)
|
|
480
|
+
The server checks `favorite` when it starts: `resource` has an [owner](data-config.md#access) (`.owner(...)`), so the API lists and creates each user's own, and `field` is a filterable, writable relation to the list's resource, which has a single-column key; `.listOf` needs a relation to a resource with a single-column key. In `/api/meta`, a signed-in user who cannot list, create and delete those records, or write `field`, gets the cards without the heart.
|
|
481
481
|
|
|
482
482
|
### Saved searches
|
|
483
483
|
|
|
484
484
|
`.saveSearch({ resource, label? })` on a view puts a **Save search** button beside the list's title while its filters or search narrow it. A press asks for a name, which may be left empty unless the `name` field of `.searchesOf` has no `.optional()`, showing the filter's chips, then saves the list's filter, as the address holds it, as a record of `resource`, the signed-in user's own, with the name as given or `null`; the button is a toggle named `label` ("Save search" by default) with `aria-pressed`, pressed while that filter is saved, and the next press takes the search off again. Without a `name` field it saves at once. A visitor gets the button too when the view of `resource` has a [sign-in prompt](#sign-in-prompts), which a press opens.
|
|
485
485
|
|
|
486
|
-
The view of `resource` says what a saved search is with `.searchesOf(...)`, and its list page then shows the user's searches instead of rows, in its list's order. Each has its name, which links to its record page, and the filter's chips, which are its title instead when it has no name; its `controls`, enum fields as a menu and booleans as a switch, each saved as soon as it changes, which a toast confirms, a rename button, which asks for the name as saving does, a delete button, and the records the search finds, as a [`RecordRow`](blocks.md#recordrow)
|
|
486
|
+
The view of `resource` says what a saved search is with `.searchesOf(...)`, and its list page then shows the user's searches instead of rows, in its list's order. Each has its name, which links to its record page, and the filter's chips, which are its title instead when it has no name; its `controls`, enum fields as a menu and booleans as a switch, each saved as soon as it changes, which a toast confirms, a rename button, which asks for the name as saving does, a delete button, and the records the search finds, as a [`RecordRow`](blocks.md#recordrow) shows them: how many, and the searched resource's cards in one row that scrolls sideways and loads more as it scrolls, up to `limit` when it is set. **View all results** opens the searched list with the search's filter, and names the search in the address, `?saved_search=<key>` (`addressWords.savedSearch`).
|
|
487
487
|
|
|
488
488
|
While the list's filter differs from the search it was opened from, and no other search has it, the button reads **Update** with the search's name, beside **Save as new search** (the noun from the names of the view of `resource`). **Update** asks first, in a dialog: each filter added, removed or changed, as the panel's chips name them, how many more or fewer records the search finds, and the records it would add and drop, the first 12 of each with their counts, drawn as its results are. Those come from the list API, with the filters `new AND NOT old` and `old AND NOT new`, where each condition of the negated filter also asks that its field has a value, so that a record the old filter cannot decide (a range on a rent it has none of) counts as not found by it, as the list shows. The dialog updates the search, saves the list's filter as a new one, asking for its name, or does nothing.
|
|
489
489
|
|
|
@@ -503,19 +503,19 @@ view<typeof savedSearches>('saved_searches').searchesOf((r) => ({
|
|
|
503
503
|
}))
|
|
504
504
|
```
|
|
505
505
|
|
|
506
|
-
The view checks its own fields when the config loads: `filter` and `name` are text fields, `seenAt` a timestamp and each control an enum or boolean. The server checks the rest when it starts: `resource` has an [owner](data-config.md#access)
|
|
506
|
+
The view checks its own fields when the config loads: `filter` and `name` are text fields, `seenAt` a timestamp and each control an enum or boolean. The server checks the rest when it starts: `resource` has an [owner](data-config.md#access), the fields a save or a control writes are writable, `unseen.field` is a filterable timestamp or date of the searched resource, and a view of the resource a list saves to has `searchesOf` for that list. In `/api/meta`, a user who cannot list the searched resource or read `filter` gets the view without `searchesOf`, and its controls and `unseen` narrow to what they can write. A search's filter is checked like any list's when its records load; checking it on a write, against the searched resource, is the data config's: a `.validate` rule with `parseFilter` and `checkFilter`.
|
|
507
507
|
|
|
508
|
-
To tell users of new records, a job matches each new record against the saved filters with `evaluateFilter`, given the searched resource as `search` so that a search text in the filter looks in its search fields too, and sends an [email](email.md)
|
|
508
|
+
To tell users of new records, a job matches each new record against the saved filters with `evaluateFilter`, given the searched resource as `search` so that a search text in the filter looks in its search fields too, and sends an [email](email.md). The [property portal example](https://github.com/PrototeamHQ/protobase/tree/main/examples/property-portal#alerts) mails at once or in a daily digest.
|
|
509
509
|
|
|
510
510
|
### Exports
|
|
511
511
|
|
|
512
512
|
Every list has an **Export** button beside its title, and **Export N** beside **Delete N** for the rows selected in its table. Both open one dialog that asks for the format, Excel (`.xlsx`) or CSV; the rows, those the list finds with its filters, search and sort, or the selected ones; the columns, the list's own in its order to start with, then any field the user may read, each moved up or down; and the values, **As shown**, as the list shows them (enum value labels, the names of related records, dates and numbers formatted with the view's prefix, suffix and decimals), or **Raw values**, as the API stores them (keys, codes, ISO dates). It says how many rows that is before it starts: counted exactly up to 10,000, the planner's estimate above.
|
|
513
513
|
|
|
514
|
-
The rows come through the list API as the user may read them, page by page with its page tokens (`POST /{resource}:search`, 500 a page), so the [scan guard](api.md#safety)
|
|
514
|
+
The rows come through the list API as the user may read them, page by page with its page tokens (`POST /{resource}:search`, 500 a page), so the [scan guard](api.md#safety), the role's row filter and its readable fields apply as on the list; a [sensitive field](data-config.md#sensitive-fields) is never offered. The selected rows are found again by their key, so a resource with a composite key offers only the list's rows. The browser builds the file in a Web Worker, the server only answering the pages it reads anyway, and writes it as it goes: to the file the user picks where the browser has the [File System Access API](https://developer.mozilla.org/docs/Web/API/File_System_API), as a download otherwise. A progress dialog counts the rows, and **Cancel** stops after the page being read and discards the file.
|
|
515
515
|
|
|
516
516
|
A workbook has one sheet named after the records, a bold header row of the columns' labels that stays in view, columns as wide as their header and the first page's values, and typed cells: numbers, dates and times with a number format (as shown, the list's format; raw, `yyyy-mm-dd`), booleans as TRUE and FALSE, and text. As shown, a time is on the viewer's clock, as the list shows it; raw, in UTC, as the API sends it; a 64-bit integer past 2^53 stays text so that no digit is lost, and a text is cut at Excel's 32,767 characters. A sheet holds at most 1,048,575 rows. A CSV file is UTF-8 with a byte order mark, so Excel reads it as such, quoted as RFC 4180 has it, with a text that starts with `=`, `+`, `-`, `@`, a tab or a carriage return written after an apostrophe, so that a spreadsheet does not run it as a formula. The file is named after the records and the day, as `Orders 2026-10-16.xlsx`.
|
|
517
517
|
|
|
518
|
-
`.export(false)` takes Export off a view's list, and `.export({ maxRows })` limits how many rows a file holds: the dialog says when the list finds more, and the toast that ends the export says the file holds only the first rows. Like the rest of a view, this only shapes the page: what a user may read is the [data config's access rules](data-config.md#access)
|
|
518
|
+
`.export(false)` takes Export off a view's list, and `.export({ maxRows })` limits how many rows a file holds: the dialog says when the list finds more, and the toast that ends the export says the file holds only the first rows. Like the rest of a view, this only shapes the page: what a user may read is the [data config's access rules](data-config.md#access), and the API serves it as it does to the list.
|
|
519
519
|
|
|
520
520
|
```ts
|
|
521
521
|
view<typeof orders>('orders').export({ maxRows: 50_000 })
|
|
@@ -524,7 +524,7 @@ view<typeof auditLog>('audit_log').export(false)
|
|
|
524
524
|
|
|
525
525
|
## Importing records
|
|
526
526
|
|
|
527
|
-
A list page offers **Import** beside **New** to a user who may create the resource's records; `.import(false)` on the view turns it off. It opens a dialog that creates or updates records from an Excel workbook (`.xlsx`) or a CSV file (UTF-8, its delimiter a comma, semicolon or tab, found from the first line). See [Importing records from a spreadsheet](../guides/import-records.md)
|
|
527
|
+
A list page offers **Import** beside **New** to a user who may create the resource's records; `.import(false)` on the view turns it off. It opens a dialog that creates or updates records from an Excel workbook (`.xlsx`) or a CSV file (UTF-8, its delimiter a comma, semicolon or tab, found from the first line). See [Importing records from a spreadsheet](../guides/import-records.md) for a walk through.
|
|
528
528
|
|
|
529
529
|
```ts
|
|
530
530
|
view<typeof invoices>('invoices').import(false)
|
|
@@ -534,27 +534,27 @@ view<typeof invoices>('invoices').import(false)
|
|
|
534
534
|
2. **Columns.** A column whose header is a field's label or name, ignoring case and spacing, fills that field; each mapping can be changed, or the column skipped. The fields are those the import can write: not read-only, not the tenant, not JSON or files, and relations to records with a key of one field. The fields a new record needs (not optional, without a default) that no column fills are listed, and a create waits for them. A relation's column holds the related record's key, or the value of a field the user picks under it, such as a customer's email. **Numbers** and **Dates** say how the file writes what text leaves open: `1,234.56` or `1.234,56`, the day or the month first; they start from the browser's language. Dates written as `2026-12-31` read the same either way, and a time without a zone is the browser's.
|
|
535
535
|
3. **Rows.** **Create** makes a record of each row. A user who may also update records can choose **Update**, which finds each row's record by a column the user picks, holding its key or a field no two records share (filterable, not sensitive), and skips a row that finds none, or **Create or update**, which creates that record instead.
|
|
536
536
|
4. **Check.** The whole file is read and every row converted before anything is written: the first rows as they will be saved, and each row's problems, also as a file to download. Nothing is guessed: an empty cell is `null`, never the field's default; numbers and dates in the chosen formats, true or false (`true`, `false`, `yes`, `no`, `1`, `0`), enum values by their [value labels](#names-and-columns) or values, and related records found by exactly one match convert, and anything else is a problem on its row. The import skips those rows.
|
|
537
|
-
5. **Import.** The rows are written in batches of 100 with [`POST /api/v1:batchWrite`](api.md#batch-writes)
|
|
537
|
+
5. **Import.** The rows are written in batches of 100 with [`POST /api/v1:batchWrite`](api.md#batch-writes), so the server validates each and checks the user's access as it does a single write; an update is sent with the ETag `*`. Each batch is a transaction of its own, so an import is not all or nothing: a row the server refuses is set aside with the server's reason, and the rest of its batch is sent again. **Cancel import** stops between two batches, keeping what was written, and so does an error such as an expired session. The summary counts the rows created, updated, skipped (with problems in the file) and failed (refused by the server), and downloads the rows not imported as a CSV, the file's own columns followed by each row's line in the file and its problems, to fix and import again.
|
|
538
538
|
|
|
539
539
|
## Create pages
|
|
540
540
|
|
|
541
|
-
When a resource's records are made by a process rather than a form, such as an app a server sets up or an order from a cart, its view names a [composed page](layouts.md)
|
|
541
|
+
When a resource's records are made by a process rather than a form, such as an app a server sets up or an order from a cart, its view names a [composed page](layouts.md) of the app's own that creates them, with `.create({ page })`:
|
|
542
542
|
|
|
543
543
|
```ts
|
|
544
544
|
view<typeof repairs>('repairs').create({ page: 'book-repair' })
|
|
545
545
|
```
|
|
546
546
|
|
|
547
|
-
- `/<resource>/new` shows that page instead of the create form, so the list's **New** button and every [create address](layouts.md#addresses)
|
|
548
|
-
- **New** shows to whoever `/api/meta` gives the page, as its `roles` say, whatever the resource's `create` access. The resource's API can then refuse creates (`create: () => false`) while the page creates through an [API function](../guides/api-functions.md)
|
|
549
|
-
- The address's `values` stay in it. A component on the page reads them with `useAppAddress()` and can keep its answers there as they are given, so a reload, a link, or a round trip through another site keeps them. See [Create pages](custom-components.md#create-pages)
|
|
547
|
+
- `/<resource>/new` shows that page instead of the create form, so the list's **New** button and every [create address](layouts.md#addresses) open it. The breadcrumb reads the resource and **New**, as for the form.
|
|
548
|
+
- **New** shows to whoever `/api/meta` gives the page, as its `roles` say, whatever the resource's `create` access. The resource's API can then refuse creates (`create: () => false`) while the page creates through an [API function](../guides/api-functions.md) that writes with `db`. Someone without the page gets no **New**, and `/<resource>/new` tells them they cannot create there: the create form never shows. **Import** still follows the resource's `create` access.
|
|
549
|
+
- The address's `values` stay in it. A component on the page reads them with `useAppAddress()` and can keep its answers there as they are given, so a reload, a link, or a round trip through another site keeps them. See [Create pages](custom-components.md#create-pages).
|
|
550
550
|
- A create address's `values` may name what is not a field of the resource, such as `{ kind: 'create', resource: 'tasks', values: { objective_id: '{id}' } }` for a task's objectives kept in a join resource, since the page reads them. Its `{field}` placeholders are still checked against the record the link sits on. A resource without a create page still refuses such values, as its create form would drop them.
|
|
551
551
|
- The server refuses a page that does not exist when it starts.
|
|
552
552
|
|
|
553
|
-
[A create page of your own](../guides/create-page.md)
|
|
553
|
+
[A create page of your own](../guides/create-page.md) builds one step by step.
|
|
554
554
|
|
|
555
555
|
## Sign-in prompts
|
|
556
556
|
|
|
557
|
-
`.signIn({ title, description, benefits?, icon?, signUp? })` on a view tells a visitor who is not signed in what they could do with the resource once signed in. Where a signed-in user sees the list, the visitor sees the prompt: an icon (`icon`, as for field hints, a sign-in icon by default), `title`, `description` and a line per `benefits`, with **Sign in**, which opens the sign-in page and comes back to the same address. A card's [favorite button](#favorites) that saves to the resource, and a list's [Save search](#saved-searches) button that saves to it, open the same prompt as a dialog, with **Not now** to close it. With [open sign-up](auth.md#open-sign-up)
|
|
557
|
+
`.signIn({ title, description, benefits?, icon?, signUp? })` on a view tells a visitor who is not signed in what they could do with the resource once signed in. Where a signed-in user sees the list, the visitor sees the prompt: an icon (`icon`, as for field hints, a sign-in icon by default), `title`, `description` and a line per `benefits`, with **Sign in**, which opens the sign-in page and comes back to the same address. A card's [favorite button](#favorites) that saves to the resource, and a list's [Save search](#saved-searches) button that saves to it, open the same prompt as a dialog, with **Not now** to close it. With [open sign-up](auth.md#open-sign-up) on the server, the prompt also offers **Create an account**, which opens the app's own sign-up page. `signUp: { label, href }` names a page elsewhere instead, `https://`, `http://` or `mailto:`, opened in a new tab.
|
|
558
558
|
|
|
559
559
|
```ts
|
|
560
560
|
view<typeof favorites>('favorites').signIn({
|
|
@@ -565,7 +565,7 @@ view<typeof favorites>('favorites').signIn({
|
|
|
565
565
|
})
|
|
566
566
|
```
|
|
567
567
|
|
|
568
|
-
Only a caller without a token gets the prompts, in `/api/meta` as `signIn`, for the resources they cannot see whose view for the `anonymous` role has one: its names, its sidebar place and the prompt. Those resources keep their place in the sidebar, the [bottom bar](bottom-bar.md)
|
|
568
|
+
Only a caller without a token gets the prompts, in `/api/meta` as `signIn`, for the resources they cannot see whose view for the `anonymous` role has one: its names, its sidebar place and the prompt. Those resources keep their place in the sidebar, the [bottom bar](bottom-bar.md) and the [user menu](user-menu.md). Pages of the project can show a prompt too: `SignInPrompt` from `@protobase/ui` takes it `as="page"` or `as="dialog"`, and `ResponsiveDialog` is the modal that becomes a sheet on a phone.
|
|
569
569
|
|
|
570
570
|
## The record page
|
|
571
571
|
|
|
@@ -592,7 +592,7 @@ export const repairsView = filtered
|
|
|
592
592
|
.saveFeedback('button')
|
|
593
593
|
```
|
|
594
594
|
|
|
595
|
-
`.layout((r) => [...])` with [`l`](https://docs.protobase.net/api/schema/variables/l/)
|
|
595
|
+
`.layout((r) => [...])` with [`l`](https://docs.protobase.net/api/schema/variables/l/) from `@protobase/schema`:
|
|
596
596
|
|
|
597
597
|
| Item | |
|
|
598
598
|
| --- | --- |
|
|
@@ -601,16 +601,16 @@ export const repairsView = filtered
|
|
|
601
601
|
| `l.tab(title, items)` | A tab holding main-column items; a view's tabs show as one strip on the read view and the form. See [Tabs](#tabs). |
|
|
602
602
|
| `l.sidebar(fields, { when? })` | A summary card beside it, read-only. `when` also takes a [condition](#form-and-read-view). |
|
|
603
603
|
| `l.related(title, { ... })` | A table or cards of the records of another resource that point at this one, in the main column. See [Related records](#related-records). |
|
|
604
|
-
| `l.custom(Component, { title?, props?, sidebar?, when? })` | A [custom component](custom-components.md#record-sections)
|
|
604
|
+
| `l.custom(Component, { title?, props?, sidebar?, when? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. |
|
|
605
605
|
| `l.map(title, { latitude, longitude, zoom?, sidebar?, when? })` | A map with a pin at the record's position, in the main column or with `sidebar: true` as a sidebar card. See [Maps](#maps). |
|
|
606
606
|
| `l.chart(title, { resource, field, at, series, range?, help?, when? })` | Line graphs of numbers of the records that point at this one, such as a machine's samples, over the last hour, day or week. See [Charts of related records](#charts-of-related-records). |
|
|
607
607
|
| `l.gallery(title, { image?, photos?, when? })` | The record's photos as tiles, opening a lightbox. See [Galleries](#galleries). |
|
|
608
|
-
| `l.history(title?, { limit?, when? })` | The record's changes, newest first, with who made each and the fields before and after; needs `.history()` on the resource, and a view without a layout shows it last by itself. See [Record history](history.md#on-the-record-page)
|
|
609
|
-
| `l.comments(title?, { when? })` | The record's comments, oldest first, with a box to write one that @mentions people; needs `.comments()` on the resource, and a view without a layout shows it last by itself. See [Record comments](comments.md#on-the-record-page)
|
|
608
|
+
| `l.history(title?, { limit?, when? })` | The record's changes, newest first, with who made each and the fields before and after; needs `.history()` on the resource, and a view without a layout shows it last by itself. See [Record history](history.md#on-the-record-page). |
|
|
609
|
+
| `l.comments(title?, { when? })` | The record's comments, oldest first, with a box to write one that @mentions people; needs `.comments()` on the resource, and a view without a layout shows it last by itself. See [Record comments](comments.md#on-the-record-page). |
|
|
610
610
|
|
|
611
611
|
A custom component draws only its part: the page around it stays the record page, at `/<resource>/<key>`, with its breadcrumbs, Save, the action rail with Edit and Delete, and the related records, and a layout may hold only custom components. The repairs above list the customer's earlier repairs under the bike:
|
|
612
612
|
|
|
613
|
-
Without a layout the record page shows one section with every field the user may change; its [read view](#read-view-and-edit), which is what a user who may change none gets, shows every field. A section or sidebar card with no field the user may see is left out. The record's title is the page's heading, above the sections, with an enum `status` as a badge beside it unless the sidebar shows it already. `.saveFeedback('button')` shows saving on the Save button instead of a toast (`'toast'`, the default). A [sensitive field](data-config.md#sensitive-fields)
|
|
613
|
+
Without a layout the record page shows one section with every field the user may change; its [read view](#read-view-and-edit), which is what a user who may change none gets, shows every field. A section or sidebar card with no field the user may see is left out. The record's title is the page's heading, above the sections, with an enum `status` as a badge beside it unless the sidebar shows it already. `.saveFeedback('button')` shows saving on the Save button instead of a toast (`'toast'`, the default). A [sensitive field](data-config.md#sensitive-fields) in a section is masked, with an eye button that reveals it. A [write-only field](access.md#write-only-fields) is on the form only where a section names it, never in the section without a layout, and shows as an empty input to set a new value in.
|
|
614
614
|
|
|
615
615
|
A record opened from a list, by its row or its card, shows the fields the list loaded at once, with placeholders for the others, and takes input once the whole record has loaded; actions, custom components, maps and galleries wait for it. What the page shows is read again whenever the browser tab or window regains focus, as are the lists, unless the record has unsaved changes, which keep the version they were made to.
|
|
616
616
|
|
|
@@ -691,7 +691,7 @@ The read view and the form share the layout, so every item and field shows on bo
|
|
|
691
691
|
| `'always'` | On both, as without the setting. The default. |
|
|
692
692
|
| `'editing'` | Only while the record is edited: on its form and the create form, not on the read view or a locked form. |
|
|
693
693
|
| `'reading'` | Only while it is not: on the read view and the locked form, and in a gallery's photo details. |
|
|
694
|
-
| a condition, such as `'status = "done"'` | Only `l.section`, `l.related` and `l.sidebar` take it: they show while the condition holds for the saved record, as [`<Show when>`](layouts.md#conditions)
|
|
694
|
+
| a condition, such as `'status = "done"'` | Only `l.section`, `l.related` and `l.sidebar` take it: they show while the condition holds for the saved record, as [`<Show when>`](layouts.md#conditions) reads it, and change once the record is saved, not while the user types. They stay off the create form, which has no saved record, so a conditional section's fields go under "Other fields" there. A condition that does not parse, or names a field the record does not have, stops startup. |
|
|
695
695
|
|
|
696
696
|
```ts
|
|
697
697
|
view<typeof listings>('listings')
|
|
@@ -719,7 +719,7 @@ On a phone, an integer field brings up a number keyboard and a decimal field a d
|
|
|
719
719
|
])
|
|
720
720
|
```
|
|
721
721
|
|
|
722
|
-
The photos are read with the list API under the user's own access, up to 500, so an index on `field` and the sorted fields serves them, which [`protobase doctor`](cli.md#doctor)
|
|
722
|
+
The photos are read with the list API under the user's own access, up to 500, so an index on `field` and the sorted fields serves them, which [`protobase doctor`](cli.md#doctor) checks. In the lightbox, a photo held by a record of a resource the user may read has an info button, which shows that record's details, as does the `i` key: in a sidebar beside the photo, or on a mobile screen in a sheet over the lower part of the screen, which Escape, its close button or a swipe down on its header closes. The details start closed, and the browser remembers whether they were left open for the next photo and gallery. They are the fields its record page's sections show, less its file and the field pointing at the record, as a table of labels and values, as the record API answers the user, so the server decides what they see, and a link to its record page. A user who may not read that resource sees the photo alone, without the info button, as everyone does when it has no other field to show. In `/api/meta`, a user who cannot read `image` gets the gallery without it, and one who cannot list the photos without them; a gallery left with neither is left out. The server checks when it starts that `image` is a file field and that `photos` fits the resources.
|
|
723
723
|
|
|
724
724
|
### Maps
|
|
725
725
|
|
|
@@ -792,7 +792,7 @@ The browser fetches the tiles, so their host must answer the app's origins with
|
|
|
792
792
|
|
|
793
793
|
Without any configuration, the record page's rail has a **Related records** card that counts the records pointing at this one: per resource, and per relation when one resource has two, such as Orders (Customer) and Orders (Supplier), how many there are, linking to its list filtered on this record (`/orders?filter=customer_id = "7"`). It counts each filterable relation to a resource with a one-field key, so an index serves the count, and leaves out a resource's tenant, a resource the user cannot list or whose relation they cannot read, the lines drawn on the page, and a relation an `l.related` section of the page already lists.
|
|
794
794
|
|
|
795
|
-
`l.related(title, options)` lists the first records of `resource` that point at the record on the page, in the table or display the resource's list page uses (with its switch, and on a phone its cards in one sideways row, as a [`Table` block](blocks.md#table)
|
|
795
|
+
`l.related(title, options)` lists the first records of `resource` that point at the record on the page, in the table or display the resource's list page uses (with its switch, and on a phone its cards in one sideways row, as a [`Table` block](blocks.md#table) shows them), and links to all of them in that list. They point at it directly, through a relation field, or through a join resource (`through`), such as the leases a tenant signed through `lease_tenants`:
|
|
796
796
|
|
|
797
797
|
| Option | |
|
|
798
798
|
| --- | --- |
|
|
@@ -899,7 +899,7 @@ view<typeof hosts>('hosts').layout((r) => [
|
|
|
899
899
|
])
|
|
900
900
|
```
|
|
901
901
|
|
|
902
|
-
Each series is read through [`:aggregate`](api.md)
|
|
902
|
+
Each series is read through [`:aggregate`](api.md), grouped by `at` with `field = <this record's key>` as its filter, so the user's access applies as on the list, and a user who cannot read `field`, `at` or any series gets no chart (one who cannot read some series gets the others). That filter and grouping need an index on `(field, at)`, such as `create index on host_samples (host_id, sampled_at)`, which [`protobase doctor`](cli.md#doctor) checks. A `field` that is no relation to this resource, an `at` that is no timestamp or not filterable, or a series that is no number or is sensitive stops the server at startup. Keeping the samples, and removing old ones, is the app's own work.
|
|
903
903
|
|
|
904
904
|
## Actions and views per role
|
|
905
905
|
|
|
@@ -926,7 +926,7 @@ export const workshopRepairsView = laidOut
|
|
|
926
926
|
.actions((a) => [a.update('ready', { label: 'Ready for pickup', icon: 'send', set: { status: 'ready' } })])
|
|
927
927
|
```
|
|
928
928
|
|
|
929
|
-
`.actions((a) => [...])` names the moves a record page offers in its action rail, between **Edit**, when the record opens as a read view or locked, and **Delete**, for a user who may delete it, unless an `a.remove` deletes already; composed pages can put the same actions on buttons. On the form, **Save** leads the sidebar, above the rail, with **Cancel** under it when Edit opened the form; on a mobile screen they sit in a bar under the form instead. On a mobile screen, below `md` (768px), the rail's actions, Edit and Delete among them, sit in the top bar's **Record actions** menu (the ⋮ button), at hand however long the record is. `a.update`, `a.remove`, `a.link` and [`a.ai`](ai.md#ai-actions)
|
|
929
|
+
`.actions((a) => [...])` names the moves a record page offers in its action rail, between **Edit**, when the record opens as a read view or locked, and **Delete**, for a user who may delete it, unless an `a.remove` deletes already; composed pages can put the same actions on buttons. On the form, **Save** leads the sidebar, above the rail, with **Cancel** under it when Edit opened the form; on a mobile screen they sit in a bar under the form instead. On a mobile screen, below `md` (768px), the rail's actions, Edit and Delete among them, sit in the top bar's **Record actions** menu (the ⋮ button), at hand however long the record is. `a.update`, `a.remove`, `a.link` and [`a.ai`](ai.md#ai-actions), which has the model write a field, work without code; `a.action` runs a handler the app registers; it and `a.update` ask for their [inputs](#actions-that-ask-for-input) first when they have some. They are described with [named actions](layouts.md#named-actions).
|
|
930
930
|
|
|
931
931
|
`.forRoles([...])` makes a view for users with one of those roles: each user gets the first such view that matches their roles, and the view without roles otherwise. A per-role view is a whole view, so build it from another (`laidOut.forRoles(...)` above) and change what differs.
|
|
932
932
|
|
|
@@ -1008,13 +1008,13 @@ a.update('answer', { label: 'Answer', inputs: (i) => [i.text('answer', { label:
|
|
|
1008
1008
|
| `i.date(name, o)` | A date, `YYYY-MM-DD`. |
|
|
1009
1009
|
| `i.choice(name, { options })` | One of `options`, each a `value` with the `label` it reads as. |
|
|
1010
1010
|
| `i.choice(name, { resource })` | A record of `resource`, picked as the create form picks a relation; the handler gets its key. |
|
|
1011
|
-
| `i.custom(name, { component, props? })` | What a [component](custom-components.md)
|
|
1011
|
+
| `i.custom(name, { component, props? })` | What a [component](custom-components.md) of the app's `protobase.ui.tsx`, by the name it is registered under, edits. |
|
|
1012
1012
|
|
|
1013
|
-
Each takes `label`, and optionally `help`, a `default`, `optional: true` to allow an empty answer (every other input is required) and `when`, an AIP-160 condition over the inputs before it, as [`<Show when>`](layouts.md#conditions)
|
|
1013
|
+
Each takes `label`, and optionally `help`, a `default`, `optional: true` to allow an empty answer (every other input is required) and `when`, an AIP-160 condition over the inputs before it, as [`<Show when>`](layouts.md#conditions) is over a record: `"start = 'github' OR code = 'github'"`. An input whose condition does not hold is hidden, not required and left out of `values`, and the inputs after it read it as empty. A `when` that names no input before it, a `default` that is not one of the options and a name given twice stop the config from loading; so does a choice of a resource the app does not have, when the server starts.
|
|
1014
1014
|
|
|
1015
|
-
An empty answer is `null`. Before the handler runs, the dialog refuses a required answer left empty, a number that is none, a date that is not `YYYY-MM-DD` and a text longer than `max`, each under its input. When the handler throws an `ActionInputError` from `@protobase/ui`, such as `new ActionInputError({ email: 'No user has this address' })`, or an API error, such as a [function's](../guides/api-functions.md)
|
|
1015
|
+
An empty answer is `null`. Before the handler runs, the dialog refuses a required answer left empty, a number that is none, a date that is not `YYYY-MM-DD` and a text longer than `max`, each under its input. When the handler throws an `ActionInputError` from `@protobase/ui`, such as `new ActionInputError({ email: 'No user has this address' })`, or an API error, such as a [function's](../guides/api-functions.md) answer, whose errors name an input as their `field`, each message shows under its input and the dialog stays open; another error shows above the inputs. When it resolves, the dialog closes and the action ends as any other: everything shown of the resource reloads and a toast says it is done.
|
|
1016
1016
|
|
|
1017
|
-
A custom input's component gets the answer as `value` (`null` when empty), `onChange`, `invalid` while its answer is refused, the input's `props` and the `input` itself (`ActionInputProps`), as a [field type's](custom-components.md#field-types)
|
|
1017
|
+
A custom input's component gets the answer as `value` (`null` when empty), `onChange`, `invalid` while its answer is refused, the input's `props` and the `input` itself (`ActionInputProps`), as a [field type's](custom-components.md#field-types) editor does. Without that component the button is disabled, with the reason as its tooltip. In `/api/meta`, a user who cannot read the resource of a choice does not get the action.
|
|
1018
1018
|
|
|
1019
1019
|
### Where an action applies
|
|
1020
1020
|
|
|
@@ -1038,4 +1038,4 @@ A custom input's component gets the answer as `value` (`null` when empty), `onCh
|
|
|
1038
1038
|
|
|
1039
1039
|
Besides the record page, the list's row menu offers each named action without `inputs` on the rows it applies to, disabled where it is disabled on the record page, and in red when it is a delete or a danger action; a link is a link there, and is left out where `when` does not hold. An `a.update` or `a.action` with `bulk` and no `inputs` is also offered for the selected rows, as **Start (2)**, while one of them applies: it asks its `confirm` once, runs on each row it applies to, one after another, and its toast says how many it ran on, skipped and failed on. An `a.action`'s handler is called once per row.
|
|
1040
1040
|
|
|
1041
|
-
A condition reads only the record's own fields, so the list decides it for each row from the row itself: `protobase build` refuses one that names a relation's field (`host_id.name`), counts records (`hosts.count`) or names a field the resource does not have, a disabled button without a `reason`, and a `reason` or `otherwise` without `when`. In `/api/meta`, a user who cannot read a field the condition reads does not get the action. The condition only decides what the buttons show: the resource's [access rules](access.md)
|
|
1041
|
+
A condition reads only the record's own fields, so the list decides it for each row from the row itself: `protobase build` refuses one that names a relation's field (`host_id.name`), counts records (`hosts.count`) or names a field the resource does not have, a disabled button without a `reason`, and a `reason` or `otherwise` without `when`. In `/api/meta`, a user who cannot read a field the condition reads does not get the action. The condition only decides what the buttons show: the resource's [access rules](access.md) decide what the API lets the user do.
|
|
@@ -6,7 +6,7 @@ The user menu at the bottom of the sidebar, with the app's own account pages and
|
|
|
6
6
|
|
|
7
7
|
The signed-in user sits at the bottom of the sidebar. Clicking them opens a menu with their name and email, the app's own pages, the theme switch, and "Sign out". Account pages (organization, billing, users) and help links belong here rather than among the working resources.
|
|
8
8
|
|
|
9
|
-
Export one [`userMenu(...)`](https://docs.protobase.net/api/schema/functions/usermenu/)
|
|
9
|
+
Export one [`userMenu(...)`](https://docs.protobase.net/api/schema/functions/usermenu/) from the config module:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
// examples/erp/config/user-menu.ts, re-exported from config/index.ts
|
|
@@ -23,10 +23,10 @@ export const accountMenu = userMenu((m) => [
|
|
|
23
23
|
| Item | Does |
|
|
24
24
|
| --- | --- |
|
|
25
25
|
| `m.resource(name, { label?, icon? })` | Opens the resource's list. The resource leaves the sidebar. The label defaults to the view's plural name. |
|
|
26
|
-
| `m.page(name, { label?, icon? })` | Opens a [composed page](layouts.md)
|
|
26
|
+
| `m.page(name, { label?, icon? })` | Opens a [composed page](layouts.md). The page leaves the sidebar. The label defaults to its title. |
|
|
27
27
|
| `m.link(label, href, { icon? })` | Opens `href` in a new tab. Only `https://`, `http://` and `mailto:` are accepted. |
|
|
28
28
|
|
|
29
|
-
`accounts` is the built-in [Users page](auth.md#users-page)
|
|
29
|
+
`accounts` is the built-in [Users page](auth.md#users-page), which the config exports as `usersPage` from `@protobase/layout`; without the export, `createAdmin` refuses the item. Items keep their order. After them come the app's own account pages: "Sign-in & security" for everyone (their [passkeys](auth.md#passkeys) and [two-factor authentication](auth.md#two-factor-authentication)) and "Sign-in policy" for admins (the [sign-in policy](auth.md#sign-in-policy), and the log of [staff sign-ins](auth.md#staff-sign-in)); then the [theme switch](theme.md#light-dark-or-the-system), and "Sign out" always comes last. `icon` is one of `bell`, `book-open`, `bookmark`, `building`, `credit-card`, `external-link`, `file-text`, `heart`, `key`, `layout-dashboard`, `life-buoy`, `mail`, `receipt`, `settings`, `shield`, `users`. A resource item without one uses the resource's sidebar icon, and a link item uses `external-link`.
|
|
30
30
|
|
|
31
31
|
Every caller gets the menu through `/meta`, without the resources and pages they cannot see, so a user who cannot read `organizations` has no "Organization" item. Links are shown to everyone. `createAdmin` refuses to start when an item names a resource or page that does not exist, and `configExports` refuses a config module that exports two menus.
|
|
32
32
|
|