Skip to content
Closed
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
16 changes: 16 additions & 0 deletions .changeset/35692-skills-master-detail-body-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@objectstack/skills': patch
---

docs(skills): the data and ui skills teach that a `master_detail` child is a record-page body table by default

Clause-②: no
Metadata-protocol: none

The record page draws a `master_detail` child as a full-width body table whenever its FK declares no `relatedList`. The skills still tied that to `inlineEdit`. They now teach the rule the runtime applies.

- objectstack-data's `rules/relationships.md`, "Detail-page related lists": a `master_detail` child is a body table by default and a `lookup` child is a panel. `inlineEdit` governs entry in the parent's form only. The `relatedList` list reads `'primary'` (the `master_detail` default), `true` (the `lookup` default) and `false`. The example no longer writes `inlineEdit` and `relatedList: 'primary'` on a `master_detail` field to get the table.
- objectstack-ui's `rules/record-page.md`, step 2: the same defaults, the body table is drawn above the field sections (it used to say after the first one), and "put the tasks first" is the parent's `relatedLists`. The example field drops its `relatedList: 'primary'`.
- objectstack-ui's `evals/record-page.json`, case 1: the expected answer adds no placement flag to a `master_detail` field, and an answer that authors `inlineEdit` fails the case. `evals/README.md` follows.

Both rules files are shorter than before. No ceiling moves.
15 changes: 6 additions & 9 deletions skills/objectstack-data/rules/relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,14 @@ 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
(`master_detail` and `lookup`) is shown **by default** — owned (`master_detail`)
children first. The relationship
flags exist to *refine* that:
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:

```typescript
project: {
type: 'master_detail',
reference: 'project',
inlineEdit: true,
relatedList: 'primary', // read side: a body table
reference: 'project', // no relatedList: a body table
relatedListTitle: 'Tasks',
relatedListColumns: ['title', 'status', 'priority', 'due_date'],
},
Expand All @@ -365,10 +363,9 @@ 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 with `inlineEdit`.
- `'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`, or omitted (except inline-edited `master_detail`) — an auxiliary
panel on the 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` /
Expand Down
2 changes: 1 addition & 1 deletion skills/objectstack-ui/evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ view / page / dashboard / report metadata.
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
table placed first by `relatedList: 'primary'` (no page file),
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.
Expand Down
5 changes: 3 additions & 2 deletions skills/objectstack-ui/evals/record-page.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
{
"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. One flag on the child's reference field — `relatedList: 'primary'` on `task.lead` — makes the tasks a full-width body table in the lead's details, after the first field section; `relatedListFilter: { status: { $ne: 'done' } }` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other lists. Not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.",
"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 above the lead's field sections. `relatedListFilter: { status: { $ne: 'done' } }` on `task.lead` keeps it to open tasks, and the lead's `relatedLists: ['task', ...]` puts it before the other tables. Not `inlineEdit` (form entry, not the page), not a `definePage` with `kind: 'full'`, and never a `slots.tabs`.",
"files": [],
"assertions": {
"must_contain": [
"relatedList: 'primary'",
"relatedListFilter",
"relatedLists"
],
"must_not_contain": [
"inlineEdit:",
"definePage(",
"slots: { tabs",
"kind: 'full',"
Expand Down
8 changes: 4 additions & 4 deletions skills/objectstack-ui/rules/record-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ one tab per panel with its count) enlarges a panel at `?related=object.field`.

**2 · Relationship flags shape the related column.** On the CHILD object's
reference field: `relatedList: 'primary'` draws the child as a full-width body
table in the details after the first field section (the default for a
`master_detail` with `inlineEdit`); `true` / absent is a panel in the right
table in the details above the field sections (the default for a
`master_detail`); `true` (a `lookup`'s default) is a panel in the right
column; `false` leaves the child off the page. `relatedListTitle` /
`relatedListColumns` (child field names) replace the derived title / columns;
`relatedListFilter` (Query-DSL, `{ status: { $ne: 'done' } }`) is AND-composed
with the parent condition, and the panel's count honours it. Rows follow the
child's default list view `sort` (`isDefault`, else the first declared); the
parent's `relatedLists` orders tables and panels alike. "Put the tasks first on
the lead page" is `relatedList: 'primary'` on `task.lead` — no page file.
the lead page" is `relatedLists: ['task']` on `lead` — no page file.

**3 · A slotted page overrides one slot.** `kind: 'slotted'` replaces only the
slots it names — `header`, `actions`, `alerts`, `highlights`, `details`,
Expand Down Expand Up @@ -59,7 +59,7 @@ import { Field, ObjectSchema } from '@objectstack/spec/data';
export const Task = ObjectSchema.create({
name: 'task', sharingModel: 'controlled_by_parent',
fields: {
lead: Field.masterDetail('lead', { relatedList: 'primary', relatedListFilter: { status: { $ne: 'done' } } }),
lead: Field.masterDetail('lead', { relatedListFilter: { status: { $ne: 'done' } } }), // a body table
},
});
```
Loading