ViewBuilder
Defined in: packages/schema/src/view.ts:81
A view of a resource, as view(...) starts it: how the admin shows it. Each method returns a new view, so one view
can build on another. See UI config.
Type Parameters
Section titled “Type Parameters”R extends object
Methods
Section titled “Methods”actions()
Section titled “actions()”actions(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:322
The named actions of the record page’s action rail, which composed pages can put on buttons too: a.update,
a.remove and a.link need no code, a.action runs a handler the app registers.
Parameters
Section titled “Parameters”(a) => ActionModel[]
Returns
Section titled “Returns”ViewBuilder<R>
chart()
Section titled “chart()”chart(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:252
A chart above the list, following its filters: records per granularity over a date or timestamp field, or
records per value of groupBy, such as a status or a relation, as bars or a donut of the limit largest (default
10), counted or with sum or average that of a numeric field.
Parameters
Section titled “Parameters”(r) => ChartInput
Returns
Section titled “Returns”ViewBuilder<R>
create()
Section titled “create()”create(
options):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:378
Records are created on page, a composed page of the app’s own, in place of the create form: /<resource>/new
shows it with the address’s values, and the list’s New button opens it for whoever may open the page, whatever the
resource’s create access. So the resource’s API can refuse creates (create: never) while the page creates
through an API function. The server refuses a page that does not exist when it starts. See
Create pages.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”ViewBuilder<R>
createOpens()
Section titled “createOpens()”createOpens(
to):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:425
The resource’s create address opens to in place of the form, replacing the address in the history, {{field}}
filled from the address’s values, for a record that is made where it is used: a workflow’s test run opens in the
workflow’s page. An address that does not give every such field shows the form.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”ViewBuilder<R>
export()
Section titled “export()”export(
options):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:364
Whether the list page offers Export, which saves its rows as an Excel or CSV file built in the browser: false
takes it away, { maxRows } limits how many rows a file holds. A list offers it by default. It only shapes the
page: the rows and fields a file holds are those the list API gives the user. Throws when maxRows is not a
positive whole number. See Exports.
Parameters
Section titled “Parameters”options
Section titled “options”false | ExportModel
Returns
Section titled “Returns”ViewBuilder<R>
fields()
Section titled “fields()”fields(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:150
Hints per field, such as { total: r.total.prefix('€').decimals(2) }; calls add up.
Parameters
Section titled “Parameters”(r) => Record<string, FieldView>
Returns
Section titled “Returns”ViewBuilder<R>
filters()
Section titled “filters()”filters(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:206
The filter widgets above the list, in order, each on a .filterable() field: w.facets, w.dateRange, w.range,
w.toggle and w.flags. Together they write the list’s ?filter=.
Parameters
Section titled “Parameters”(r, w) => FilterWidgetModel[]
Returns
Section titled “Returns”ViewBuilder<R>
form()
Section titled “form()”form(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:263
A public form that creates a record of this resource for anyone, signed in or not, at /-/forms/<name>: the
fields a visitor fills in, the thanks shown once it is sent, a title (the view’s singular name by default) and
how many submissions one client may send perMinute (default 5). The anonymous role must grant create of those
fields; the form is the only way it creates. Each call adds a form. Throws on a name that does not fit an address, no
or repeated fields, or an empty thanks. See Public forms.
Parameters
Section titled “Parameters”(r) => FormInput
Returns
Section titled “Returns”ViewBuilder<R>
forRoles()
Section titled “forRoles()”forRoles(
roles):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:102
Shows this view only to users with one of these roles; a view without roles is the default.
Parameters
Section titled “Parameters”string[]
Returns
Section titled “Returns”ViewBuilder<R>
help()
Section titled “help()”help(
help):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:145
A line under the list’s title.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”ViewBuilder<R>
helpWhen()
Section titled “helpWhen()”helpWhen(
helpWhen):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:281
When the help lines of the view’s fields and sections show: always, the default, or only while the record is
editing, on its form; a field’s .help(text, { when }) or a section’s helpWhen says otherwise for its own.
Parameters
Section titled “Parameters”helpWhen
Section titled “helpWhen”Returns
Section titled “Returns”ViewBuilder<R>
icon()
Section titled “icon()”icon(
icon):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:97
The resource’s icon in the sidebar, bottom bar and user menu; a table without one. See Sidebar icons.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”ViewBuilder<R>
import()
Section titled “import()”import(
enabled):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:314
Whether the list page offers Import, which creates or updates records from an .xlsx, CSV or JSON file the user
picks (true, the default, to users who may create records); .import(false) turns it off. .import('table')
makes it a new table users add from the file instead, as the Tables list of user tables does. See
Importing records.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean | "table"
Returns
Section titled “Returns”ViewBuilder<R>
layout()
Section titled “layout()”layout(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:243
The record page, as items of l in order: sections, sidebar cards, related records, maps and custom components.
Without it the page shows one section with every field.
Parameters
Section titled “Parameters”(r) => LayoutItemModel[]
Returns
Section titled “Returns”ViewBuilder<R>
list()
Section titled “list()”list(
build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:163
The list: its table’s columns, fields or columns of related records (c.related), sort, search and a filter it opens with, the
columns that are editable in their cell, and other displays to switch to (d.cards, d.map, d.board, d.calendar, d.timeline, d.custom), one of which
may be the default the list opens in, and what drag lets a user change by dragging, nothing unless it says.
Throws when display or column names collide, default names none or an editable field is not among the columns. See
Editing in the list.
Parameters
Section titled “Parameters”(r, d, c) => object
Returns
Section titled “Returns”ViewBuilder<R>
listOf()
Section titled “listOf()”listOf(
pick):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:331
The list page shows the records this relation field points at instead of this resource’s rows, in their own view’s
list with its displays, filters and search: the listings among a member’s favorites, say. The record pages stay this
resource’s. Throws in toModel when the field is not a relation.
Parameters
Section titled “Parameters”(r) => Ref
Returns
Section titled “Returns”ViewBuilder<R>
namedList()
Section titled “namedList()”namedList(
name,build):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:217
Another list of this resource, with its own sidebar entry and address (/<resource>?list=<name>). build gets a
fresh view and sets its names (the sidebar entry, required), nav, help, list, filters and chart, none of
which come from the view’s own list. Its records open at the resource’s own address. Throws on a name that does not
fit an address or repeats, on anything else set, on nav.recent, and in toModel when the view has listOf or
searchesOf. See More than one list.
Parameters
Section titled “Parameters”string
(v) => ViewBuilder<R>
Returns
Section titled “Returns”ViewBuilder<R>
names()
Section titled “names()”names(
names):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:92
What a record and the records are called, such as “New repair” and “Repairs”; the resource name in words by default.
Parameters
Section titled “Parameters”plural
Section titled “plural”string
singular
Section titled “singular”string
Returns
Section titled “Returns”ViewBuilder<R>
nav(
nav):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:140
Where the resource sits in the sidebar; recent lists a few of its records under the entry (see
Sidebar), and tenant: 'current' opens it on the
caller’s own tenant (see The current organization),
create links to the create form under it (see Create link),
and start names the record the app opens at / (see Start record).
Parameters
Section titled “Parameters”Omit<NavModel, "recent"> & object
Returns
Section titled “Returns”ViewBuilder<R>
record()
Section titled “record()”record(
options):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:399
The record page at /<resource>/<key> is component, a component of the app’s own declared with component(...)
and exported from protobase.ui.tsx, filling the content area beside the sidebar and under the top bar, where the
page does not scroll. It reads the record with useLayoutRecord(). The standard record page stays at the record’s
address with standard: true, which the component links to; it shows instead while the component is missing or
when it throws. Throws when component is a built-in block. See
Full-area record pages.
focus: true draws it on a focus page, with the bar’s state, Save, the record’s actions and panels; the form
(r) => ({ surface: r.body }) needs no component: the surface is one field, drawn by its field type. See
Focus pages.
conversation makes the page the record’s conversation, filling the area with no component of the app’s own: a
header, the messages that point at the record and a box that sends one. A conversation with members titles its
record after them for each reader, as .titleFrom('members', ...) does, unless the view sets its own. See
Conversation pages.
Parameters
Section titled “Parameters”options
Section titled “options”{ component: ComponentRef<never>; focus?: boolean; } | { conversation: ConversationPageModel; } | ((r) => object)
Returns
Section titled “Returns”ViewBuilder<R>
recordMode()
Section titled “recordMode()”recordMode(
recordMode):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:273
How the record page opens to a user who may change the record: edit, the default, as its form; read as a read
view, its sections as tables of labels and values, with an Edit button to the form; locked as the form, locked
until Edit is pressed. A user who may not change it gets the read view in every mode. The form has its own address
(edit: true), so it opens in a new tab and Back leaves it. See The record page.
Parameters
Section titled “Parameters”recordMode
Section titled “recordMode”Returns
Section titled “Returns”ViewBuilder<R>
recordOpens()
Section titled “recordOpens()”recordOpens(
to):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:414
A record’s page opens to in its place, replacing the address in the history, {{field}} in its resource, key and
run replaced by the record’s values: a workflow run’s opens its workflow’s page with the run on the graph. A list
of addresses opens the first whose {{field}}s all have a value in the record, as a row button’s choices do: a
message opens in its channel, else in its direct message. Links that know the record’s fields, such as the top bar’s
search results, point at it too. A caller who cannot see where a choice leads skips it, and a record no choice fits
gets its own page. Throws on an empty list. See
Open elsewhere.
Parameters
Section titled “Parameters”AppAddress | readonly AppAddress[]
Returns
Section titled “Returns”ViewBuilder<R>
recordWidth()
Section titled “recordWidth()”recordWidth(
recordWidth):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:294
How wide the standard record page is: a centred column, the default, or the full width of the content pane, its
sidebar cards still beside the sections. See The record page.
Parameters
Section titled “Parameters”recordWidth
Section titled “recordWidth”Returns
Section titled “Returns”ViewBuilder<R>
saveFeedback()
Section titled “saveFeedback()”saveFeedback(
saveFeedback):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:286
Where the record page shows that it saved: a toast (the default) or the Save button.
Parameters
Section titled “Parameters”saveFeedback
Section titled “saveFeedback”Returns
Section titled “Returns”ViewBuilder<R>
saveSearch()
Section titled “saveSearch()”saveSearch(
search):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:354
A “Save search” button on the list page while its filter narrows it: it saves the filter as a record of resource,
the signed-in user’s own, whose view lists them with .searchesOf(...), and takes it off again while pressed. A
visitor is told what signing in gives, when that view has .signIn(...). See
Saved searches.
Parameters
Section titled “Parameters”search
Section titled “search”Returns
Section titled “Returns”ViewBuilder<R>
searchesOf()
Section titled “searchesOf()”searchesOf(
pick):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:437
This resource holds saved searches of resource, which a list page saves with .saveSearch(...): its list page
shows each of the user’s searches with its filters, its controls to change in place, the records it finds (with
unseen, newest first, those new since the user last opened its results marked) and a link to all of them. Throws in
toModel when filter or name is not a text field, unseen.seenAt not a timestamp or a control not an enum or
boolean field.
See Saved searches.
Parameters
Section titled “Parameters”(r) => object
Returns
Section titled “Returns”ViewBuilder<R>
searchResult()
Section titled “searchResult()”searchResult(
pick):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:127
How a record shows in the global search: a bold title of one or more fields joined by spaces (default: title)
and a subtitle field under it, replaced by the search field the text matched when that is neither.
Parameters
Section titled “Parameters”(r) => object
Returns
Section titled “Returns”ViewBuilder<R>
signIn()
Section titled “signIn()”signIn(
prompt):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:343
What a visitor who is not signed in is told about this resource, which they could use once signed in: on its list
page, in place of the list, and in the dialog of a card’s favorite button or a list’s “Save search” button that
saves here. The page offers “Sign in”, and a way to make an account: the page signUp names, or the app’s own sign-up
when the server has open sign-up. With it, the resource keeps its place in the bottom
bar and the sidebar of visitors. Throws when signUp.href is not https:, http: or mailto:. See
Sign-in prompts.
Parameters
Section titled “Parameters”prompt
Section titled “prompt”Returns
Section titled “Returns”ViewBuilder<R>
title()
Section titled “title()”title(
pick):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:107
The field shown as this record’s title. Throws when the field does not exist.
Parameters
Section titled “Parameters”(r) => Ref
Returns
Section titled “Returns”ViewBuilder<R>
titleBadge()
Section titled “titleBadge()”titleBadge(
pick):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:304
The field the record page shows as a badge beside its title, in the field’s valueColors and labels, such as a
verdict; without it an enum field named status shows there. Throws when the field does not exist, or is neither
an enum nor shown with .format('badge'). See
The record page.
Parameters
Section titled “Parameters”(r) => Ref
Returns
Section titled “Returns”ViewBuilder<R>
titleFrom()
Section titled “titleFrom()”titleFrom(
rule,pick):ViewBuilder<R>
Defined in: packages/schema/src/view.ts:116
A title derived per reader in the browser, in place of title: rule names a function of the project’s UI
titles, which gets the record with the fields picked and the signed-in reader, such as the names of the members
other than the reader. The record’s key shows while it returns nothing. Throws when a field does not exist.
Parameters
Section titled “Parameters”string
(r) => Ref[]
Returns
Section titled “Returns”ViewBuilder<R>
toModel()
Section titled “toModel()”toModel(
resource?):ViewModel
Defined in: packages/schema/src/view.ts:460
With the resource’s model, also verifies the title and titleFrom, search result and list display fields, related column names, a gallery’s image, listOf, searchesOf, the sidebar’s recent group and tenant, and the forms’ fields.