Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/35902-skills-related-lists-tabs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/skills': patch
---

Clause-②: no
Metadata-protocol: none

The record-page skills teach the parent-declared record page:

- `objectstack-ui` record-page rule: the parent's `relatedLists` is the tab list. Without it nothing changes; declared, only the named lists show, in order, with the attachments, approvals and activity tabs named by object (`sys_attachment`, `sys_approval_request`, `sys_activity`), and an entry `{ list, label, columns }` titles one list. "Put the tasks tab first" lists every tab to keep, tasks first, because a list naming only the task hides the rest. A child list another package adds is hidden by a `relatedLists` that does not name it.
- The same rule's step 1 no longer teaches a stage bar or a key-field strip: the stage is the status tag beside the title, whose menu moves it, and `highlightFields` feed hover cards, pickers and related-list columns. A field group lists its own members in `fields`. The wide full page pins the details left beside the tabs, unless the details hold a child table or there is no other tab; the right summary rail and its switch are gone from the text, and the details column's dragged width joins the reader's own choices.
- A `master_detail` child is a tab by default (`objectstack-data` relationships rule, the record-page rule and an eval); a parent field group naming the child list places its table among the fields, written only when asked, and the list keeps its tab too unless a declared `relatedLists` leaves it out.
- `objectstack-data` field-groups example lists each group's members in `fields`; `objectstack-ui` navigation names `fieldGroups` alone.
- Evals: the tasks-first case now writes the full tab list; new cases remove the attachments tab, place a Tax ID field after Industry in its group's list, and put a quote's line items above its amount section.
76 changes: 70 additions & 6 deletions content/docs/ui/pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,13 @@ replacement.
A record page needs no authoring. With no page assigned, the Console synthesizes one from
the object: a header, the record's **details** (the **Details** tab), and one tab per related
list, then **Attachments** for an object with `enable: { files: true }`, **Approvals** when the
record has approval requests, and **动态** (Activity) last, each with its count. A relationship
whose child field declares `relatedList: 'primary'` is part of the record's body: its list is a
full-width table in the details, after the first field section, with no tab of its own. **动态**
record has approval requests, and **动态** (Activity) last, each with its count. Every related
list is a tab by default, a `master_detail` child's too. The header carries the title
(`nameField`) and, for an object with a `stageField`, a status tag whose menu moves the stage;
the page draws no stage bar and no key-field strip (`highlightFields` feed hover cards, pickers
and related-list columns). A relationship whose child field declares `relatedList: 'primary'`
is part of the record's body: its list is a full-width table in the details, after the field
sections drawn open, with no tab of its own. **动态**
(`?related=timeline`) holds the record's system entries: its activity and, with
`enable: { trackHistory: true }`, its field changes; there is no separate History tab. On the
desktop the record's comments are not in it but in the comment panel, opened from the
Expand All @@ -194,9 +198,69 @@ whole table (`?related=<object>.<field>`). The tab row shows as many tabs as its
rest into a **+N** menu; the open tab is always on the row. The related tabs are the reader's
to arrange: move one before or after its neighbour, hide one, and bring hidden ones back. The
arrangement is kept per user and object, never in the object's declaration.
Moving a child table into the record's body is therefore a one-word change on the
relationship field, not a page-authoring task, and `relatedList: false` leaves a child off the
page.
Moving a child table into the record's body is therefore a declaration on the parent (a field
group naming the list, below), not a page-authoring task, and `relatedList: false` leaves a
child off the page.

### Declaring the tabs and the field groups

The parent object declares its record page's tabs and sections in one place. Without these
keys nothing changes.

- **`relatedLists` is the tab list.** Declared, only the related lists it names show, in its
order; leaving one out hides its tab. The three built-in tabs are named by object:
`sys_attachment` (attachments: shown only when listed, and only with files enabled),
`sys_approval_request` (approvals: when unlisted, after the listed tabs) and `sys_activity`
(the activity stream: when unlisted, last). An entry `{ list, label, columns }` gives one list
its own title and child-field columns, winning over the child field's `relatedListTitle` /
`relatedListColumns`; a built-in is written only as its bare name. To put one tab first, list
every tab the page keeps with that one first. A child list another package adds is hidden by a
`relatedLists` that does not name it (letting a package place its own list is a later change),
and `relatedList: false` on the child's reference field still hides a list.
- **A field group lists its fields.** `fieldGroups` are the Details sections, in array order.
A group lists its members, in order, in `fields`; without `fields`, its members are the fields
whose `group` names it, the older spelling, still read.
- **A group can place a child table among the fields.** A group that names a child list
(`relatedList: 'quote_line'`, with no `fields`) draws that list's table at its position in the
details, and the record's create and edit forms enter the child rows with the record. The
list keeps its tab as well unless a declared `relatedLists` leaves it out. Write such a group
only where the table belongs among the fields; without one the list is only a tab.

{/* os:check */}
```typescript
import { ObjectSchema, Field } from '@objectstack/spec/data';

export const Quote = ObjectSchema.create({
name: 'quote',
label: 'Quote',
sharingModel: 'private',
fields: {
name: Field.text({ label: 'Quote Name', required: true }),
account: Field.lookup('account', { label: 'Account' }),
valid_until: Field.date({ label: 'Valid Until' }),
discount: Field.percent({ label: 'Discount' }),
total: Field.currency({ label: 'Total' }),
terms: Field.textarea({ label: 'Terms' }),
},
fieldGroups: [
{ key: 'basic', label: 'Basic Information', fields: ['name', 'account', 'valid_until'] },
// Only where the line items belong among the fields; without it they are a tab.
{ key: 'lines', label: 'Line Items', relatedList: 'quote_line' },
{ key: 'amount', label: 'Amount', fields: ['discount', 'total'] },
{ key: 'terms', label: 'Terms', fields: ['terms'] },
],
relatedLists: [
// Named here as well, so the line items also keep a tab, with these columns.
{ list: 'quote_line', label: 'Line Items', columns: ['product', 'quantity', 'unit_price', 'amount'] },
'task',
'sys_attachment',
'sys_approval_request',
'sys_activity',
],
});
```

### How the page is laid out

The Console lays the page out by the width of the surface it occupies, never by the viewport.
On a full page wide enough for a 320 px details column beside 400 px of tabs, the details are
Expand Down
26 changes: 13 additions & 13 deletions skills/objectstack-data/references/examples-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
## Field Groups (MVP)

- Declare groups on `ObjectSchema.fieldGroups` — **array order is the display order**.
- Assign each field to a group via `Field.group`, which references an
`ObjectFieldGroup.key`. In-group display order equals the traversal order
of `fields`.
- A group lists its members, in display order, in its own `fields`. Absent,
its members are the fields whose `group` names its `key` (older, still read).
A field listed by two groups, or listed while its `group` names another, is refused.
- Group keys must be `snake_case`.
- Optional per-group: `icon`, `description`, and `collapse`
(`'none'` always open · `'expanded'` collapsible, starts open ·
Expand All @@ -31,19 +31,19 @@ export default ObjectSchema.create({
sharingModel: 'private',

fieldGroups: [
{ key: 'contact_info', label: 'Contact Information', icon: 'user' },
{ key: 'billing', label: 'Billing', collapse: 'collapsed' },
{ key: 'system', label: 'System' },
{ key: 'contact_info', label: 'Contact Information', icon: 'user', fields: ['name', 'email', 'phone'] },
{ key: 'billing', label: 'Billing', collapse: 'collapsed', fields: ['vat_id', 'billing_address'] },
{ key: 'system', label: 'System', fields: ['created_at', 'created_by'] },
],

fields: {
name: { type: 'text', required: true, group: 'contact_info' },
email: { type: 'email', group: 'contact_info' },
phone: { type: 'phone', group: 'contact_info' },
vat_id: { type: 'text', group: 'billing' },
billing_address: { type: 'address', group: 'billing' },
created_at: { type: 'datetime', readonly: true, group: 'system' },
created_by: { type: 'user', readonly: true, group: 'system' },
name: { type: 'text', required: true },
email: { type: 'email' },
phone: { type: 'phone' },
vat_id: { type: 'text' },
billing_address: { type: 'address' },
created_at: { type: 'datetime', readonly: true },
created_by: { type: 'user', readonly: true },
},
});
```
Expand Down
39 changes: 18 additions & 21 deletions skills/objectstack-data/rules/relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,37 +345,34 @@ InvoiceLine = {
### Detail-page related lists (the read-side mirror)

You usually don't declare the **related list** on the parent's record detail page: every child relationship
is shown **by default** — a `master_detail` child as a body table, a `lookup`
child as a panel. `inlineEdit` plays no part: it governs entry in the parent's
form only. The relationship flags *refine* that:
is shown **by default** as a tab with its count, a `master_detail` child too. The
relationship flags *refine* that:

```typescript
project: {
type: 'master_detail',
reference: 'project', // no relatedList: a body table
reference: 'project',
relatedListTitle: 'Tasks',
relatedListColumns: ['title', 'status', 'priority', 'due_date'],
},

// Suppress a noisy association from the detail page entirely:
audit_ref: { type: 'master_detail', reference: 'invoice', relatedList: false },
```

`relatedList` is tri-state — placement:

- `'primary'` — a full-width table in the record's detail body. Default for a `master_detail` FK.
- `false` — the child object is not shown on the parent record page.
- `true` — an auxiliary panel on the record page. Default for a `lookup` FK.
- Order is the parent's: `relatedLists: ['task', 'event.related_to']` (child, or
`object.field`) lists those first. A child in the stack with no inbound FK is
refused everywhere; one that exists nowhere is refused by `os validate` /
`os build` (which leave a `sys_` / `cloud_` / `ai_` or sibling-artifact name
to the runtime) and by a metadata write naming no package — a write into a
package stores it, and the page places nothing.

`relatedListTitle` / `relatedListColumns` override the derived title / columns;
otherwise columns auto-derive from the child object's
`highlightFields`. Audit FKs
- `relatedList: false` — the child object is not shown on the parent record page.
- `'primary'` — a full-width table in the record's details, with no tab. A parent field
group naming a `master_detail` child (`relatedList: 'quote_line'`, written only when asked)
places its table there too; its tab stays unless a declared `relatedLists` omits it.
- The parent's `relatedLists` is the tab list (objectstack-ui Record Page): absent,
nothing changes; declared, only the named lists show, in order, built-ins by name
(`sys_attachment`, `sys_approval_request`, `sys_activity`). An entry is the child,
`object.field` or `{ list, label, columns }`. A child in the stack with no inbound FK
is refused everywhere; one that exists nowhere is refused by `os validate` /
`os build` (bar a platform or sibling-artifact name) and by a metadata
write naming no package (one into a package is stored, placing nothing).

`relatedListTitle` / `relatedListColumns` override the derived title / columns
(an entry's `label` / `columns` win); otherwise columns auto-derive from
the child object's `highlightFields`. Audit FKs
(`created_by`/`updated_by`/`owner_id`) never become related lists. A child that
references the parent through several FKs (e.g. `primary_account` +
`partner_account`) yields **one related list per FK**; a self-referential FK
Expand Down
13 changes: 8 additions & 5 deletions skills/objectstack-ui/evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ view / page / dashboard / report metadata.
in-page `<ObjectChart>` needs no dataset at all, and a dataset authored
for a Chinese brief, whose members carry Chinese `synonyms` and a
one-sentence `description`.
- `record-page.json` — the record page as the object declares it: a child
body table ordered first by `relatedLists` (no page file),
`navigation: { mode: 'page' }` on the list view with the reader's own
open choice left out of metadata, and `placedActions: true` on a full
page's `page:header` so packaged header actions draw without an id list.
- `record-page.json` — the record page as the object declares it: a tab
put first, and the attachments tab removed, by the parent's `relatedLists`
naming every tab it keeps (no page file); a field placed in its group's
own `fields`; a child table placed between field sections by a group's
`relatedList`; `navigation: { mode: 'page' }` on the list view with the
reader's own open choice left out of metadata; and `placedActions: true`
on a full page's `page:header` so packaged header actions draw without an
id list.
- `report-period-export.json` — a non-`joined` report's `dateRange` (one
`type: 'date'` dataset dimension) and `exportOptions` (csv / xlsx under the
base object's `allowExport` permission).
Expand Down
72 changes: 66 additions & 6 deletions skills/objectstack-ui/evals/record-page.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
"evals": [
{
"id": 1,
"prompt": "On the lead record page, put the tasks first: our reps want the open tasks table before anything else when they open a lead. The `task` object already has a `lead` master_detail field.",
"expected_output": "No page file and no placement flag: `task.lead` is a `master_detail` with no `relatedList`, so it is already a full-width body table, drawn after the lead's open field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it first among the tables, directly under those field sections. Not `inlineEdit` (form entry, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.",
"prompt": "On the lead record page, put the Tasks tab first: our reps want the open tasks before anything else when they open a lead. The `task` object already has a `lead` master_detail field, `event` has a `lead` lookup, and leads keep their attachments.",
"expected_output": "No page file. The lead's `relatedLists` is its record page's tab list, so it names every tab the page keeps, Tasks first: `relatedLists: ['task', 'event', 'sys_attachment', 'sys_approval_request', 'sys_activity']`. Once declared, only the named lists show: listing the task alone would take the Events and Attachments tabs away. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps the tab to open tasks. Not a field group naming the task list (that moves the table into the Details, which was not asked), not `inlineEdit`, not a `kind: 'full'` page, and no tabs slot.",
"files": [],
"assertions": {
"must_contain": [
"relatedListFilter",
"relatedLists"
"relatedLists",
"'sys_attachment'",
"relatedListFilter"
],
"must_not_contain": [
"relatedLists: ['task'],",
"relatedLists: ['task'] }",
"relatedList: 'task'",
"inlineEdit:",
"definePage(",
"slots: { tabs",
"kind: 'full',"
"slots: { tabs"
]
}
},
Expand Down Expand Up @@ -52,6 +55,63 @@
"actions: ['"
]
}
},
{
"id": 4,
"prompt": "Nobody attaches files to opportunities. Remove the Attachments tab from the opportunity record page, and keep every other tab as it is. Today the page shows Quotes (`quote.opportunity`), Contact roles (`opportunity_contact_role.opportunity`), Attachments, Approvals and Activity.",
"expected_output": "Declare the tab list on `opportunity` and leave the attachments built-in out: `relatedLists: ['quote', 'opportunity_contact_role', 'sys_approval_request', 'sys_activity']`. A declared list shows only the lists it names, and the attachments tab shows only when named, so it goes and the rest stay in their order. The files capability (`enable.files`) can stay. No page file, and not `relatedList: false` on a child's reference field (that hides a related list, not the attachments tab).",
"files": [],
"assertions": {
"must_contain": [
"relatedLists",
"'quote'",
"'sys_activity'"
],
"must_not_contain": [
"'sys_attachment',",
"'sys_attachment']",
"definePage(",
"kind: 'full'"
]
}
},
{
"id": 5,
"prompt": "Add a Tax ID field to the account, and show it right after Industry on the record page. The account declares `fieldGroups: [{ key: 'basic', label: 'Basic', fields: ['name', 'industry', 'website'] }]`.",
"expected_output": "A `tax_id` text field on `account`, and the `basic` group's own list names it after Industry: `fields: ['name', 'industry', 'tax_id', 'website']`. The group's `fields` decides the order inside the section, so the field's position among the object's `fields` does not matter, and the field carries no `group` key of its own (one naming another group than the list that names it is refused). No page file and no form sections.",
"files": [],
"assertions": {
"must_contain": [
"tax_id",
"'industry', 'tax_id'"
],
"must_not_contain": [
"group: 'basic',",
"group: 'basic' }",
"definePage(",
"sections:"
]
}
},
{
"id": 6,
"prompt": "On the quote record page, show the line items table above the Amount section instead of as a tab. The quote declares `fieldGroups: [{ key: 'basic', label: 'Basic', fields: ['name', 'account'] }, { key: 'amount', label: 'Amount', fields: ['subtotal', 'total'] }]` and no `relatedLists`; `quote_line` has a `quote` master_detail field, and the page's tabs today are Line items, Tasks (`task.quote`), Attachments, Approvals and Activity.",
"expected_output": "Two declarations on `quote`. A field group that names the child list, placed between the two sections: `fieldGroups: [{ key: 'basic', ... }, { key: 'lines', label: 'Line items', relatedList: 'quote_line' }, { key: 'amount', ... }]`; such a group carries no `fields`, and the line table is then drawn at that position in the Details, with the quote's create and edit forms inlining the lines. And a tab list that leaves the lines out, because a group-placed table keeps its tab while the parent declares no `relatedLists`: `relatedLists: ['task', 'sys_attachment', 'sys_approval_request', 'sys_activity']`. The master_detail field needs no `relatedList` value. No page file and no full page.",
"files": [],
"assertions": {
"must_contain": [
"relatedList: 'quote_line'",
"fieldGroups",
"relatedLists: ['task'"
],
"must_not_contain": [
"relatedList: 'primary',",
"relatedList: 'primary' }",
"definePage(",
"kind: 'full'",
"relatedLists: ['quote_line'"
]
}
}
]
}
Loading
Loading