Appearance
Views
A view is a way to draw a saved view's objects in Objects, beside Sorus's own Table and Gallery. Basics brings a Board for projects.
json
"views": [
{
"id": "board",
"title": "Board",
"entry": "board.html",
"module": "board-view.js",
"types": ["project"]
}
]| Key | |
|---|---|
id | The view's key. |
title | Its name under Show as, up to 40 characters. |
entry | Its HTML page. |
types | Your type keys it can show. Leave it empty to offer it for any type. |
module | Optional. Run natively when signed by Sorus. |
A saved view of one of those types offers the view under Show as. The saved view keeps it by ID, <extension id>/<view id>; if the extension is removed, the view falls back to a table.
Drawing it
The view gets the saved view in pages.view: its name and query (type, filters, sort). Run the query, and draw again when it changes:
js
const pages = await connect()
async function draw(view) {
const { rows } = await pages.client.objects.query({ query: view.query })
// …
}
await draw(pages.view)
pages.onView(draw)onView fires when the person filters or sorts. To redraw after edits, also listen to pages.client.changes().
A view can only query objects of its own types, unless its manifest uses objects.read. See Permissions.