Skip to content

ViewBuilder

Defined in: packages/schema/src/view.ts:73

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.

R extends object

actions(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:275

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.

(a) => ActionModel[]

ViewBuilder<R>


chart(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:224

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.

(r) => ChartInput

ViewBuilder<R>


create(options): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:331

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.

CreateModel

ViewBuilder<R>


export(options): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:317

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.

false | ExportModel

ViewBuilder<R>


fields(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:124

Hints per field, such as { total: r.total.prefix('€').decimals(2) }; calls add up.

(r) => Record<string, FieldView>

ViewBuilder<R>


filters(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:178

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=.

(r, w) => FilterWidgetModel[]

ViewBuilder<R>


form(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:235

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.

(r) => FormInput

ViewBuilder<R>


forRoles(roles): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:94

Shows this view only to users with one of these roles; a view without roles is the default.

string[]

ViewBuilder<R>


help(help): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:119

A line under the list’s title.

string

ViewBuilder<R>


helpWhen(helpWhen): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:253

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.

HelpWhen

ViewBuilder<R>


icon(icon): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:89

An icon name carried in /meta, for apps that draw their own shell; the admin picks sidebar icons by resource name.

string

ViewBuilder<R>


import(enabled): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:267

Whether the list page offers Import, which creates or updates records from an .xlsx or CSV file the user picks (true, the default, to users who may create records); .import(false) turns it off. See Importing records.

boolean

ViewBuilder<R>


layout(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:215

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.

(r) => LayoutItemModel[]

ViewBuilder<R>


list(build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:137

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.custom), one of which may be the default the list opens in. Throws when display or column names collide, default names none or an editable field is not among the columns. See Editing in the list.

(r, d, c) => object

ViewBuilder<R>


listOf(pick): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:284

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.

(r) => Ref

ViewBuilder<R>


namedList(name, build): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:189

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.

string

(v) => ViewBuilder<R>

ViewBuilder<R>


names(names): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:84

What a record and the records are called, such as “New repair” and “Repairs”; the resource name in words by default.

string

string

ViewBuilder<R>


nav(nav): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:114

Where the resource sits in the sidebar; recent lists a few of its records under the entry (see Sidebar).

Omit<NavModel, "recent"> & object

ViewBuilder<R>


recordMode(recordMode): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:245

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.

RecordMode

ViewBuilder<R>


saveFeedback(saveFeedback): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:258

Where the record page shows that it saved: a toast (the default) or the Save button.

SaveFeedback

ViewBuilder<R>


saveSearch(search): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:307

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.

SaveSearchModel

ViewBuilder<R>


searchesOf(pick): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:343

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.

(r) => object

ViewBuilder<R>


searchResult(pick): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:107

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.

(r) => object

ViewBuilder<R>


signIn(prompt): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:296

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.

SignInPromptModel

ViewBuilder<R>


title(pick): ViewBuilder<R>

Defined in: packages/schema/src/view.ts:99

The field shown as this record’s title. Throws when the field does not exist.

(r) => Ref

ViewBuilder<R>


toModel(resource?): ViewModel

Defined in: packages/schema/src/view.ts:366

With the resource’s model, also verifies the title, search result and list display fields, related column names, a gallery’s image, listOf, searchesOf, the sidebar’s recent group and the forms’ fields.

ResourceModel

ViewModel