Skip to content

Commit 014c5a3

Browse files
committed
docs(skills): line items in the parent's form are a parent field group naming the child
The data and ui skills taught that `inlineEdit: true` on the child's master_detail field puts the child grid in the parent's form. A parent field group naming the child (`fieldGroups[].relatedList`) does that; `inlineEdit` only picks how the rows are edited. Three texts, two eval cases corrected, one eval case added, changeset. Claude-Session: https://claude.ai/code/session_01FEkQ5kDGa1ViantgrfH797 Co-authored-by: Claude <noreply@anthropic.com>
1 parent a5a5312 commit 014c5a3

6 files changed

Lines changed: 68 additions & 49 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): entering line items in the parent's form is taught as a parent field group naming the child, not `inlineEdit` alone
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
objectstack-data's `rules/relationships.md` (Inline Editing), objectstack-ui's `rules/list-views.md` (Master-Detail Forms) and the objectstack-ui `SKILL.md` trap list taught that `inlineEdit: true` on the child's `master_detail` field puts the child grid into the parent's form. They now teach the rule the platform applies: the parent's form enters a child's rows where a field group of the parent names that child (`fieldGroups: [{ key: 'lines', label: 'Lines', relatedList: 'invoice_line' }]`), `inlineEdit` only picks how those rows are edited, and without the group the child is a tab and the form has no lines. Text only; each file's old wording is cut to pay for the new. Two eval cases that expected the old answer are corrected and objectstack-data gains one case for form entry of quote lines.

‎skills/objectstack-data/evals/objects-fields-relationships.json‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
{
2525
"id": 2,
2626
"prompt": "Model invoices with line items, and let invoices be tagged with many tags where each tagging records who added it and when. A rep who owns a line item but can only read the invoice may still correct that line.",
27-
"expected_output": "Line items: `invoice_line` with a `master_detail` field to `invoice`, `required: true`, `deleteBehavior: 'cascade'` (or `'restrict'` — `set_null` is refused on master_detail), `inlineEdit` on that relationship, and a `summary` roll-up field on the parent. Tagging carries attributes, so it is a junction object (`invoice_tag`) with two `lookup` fields plus `added_by` / `added_at` — not a `multiple: true` lookup (an array of ids) and not a `many_to_many` type, which does not exist. The line object is `sharingModel: 'controlled_by_parent'` with `sharing: { controlledByParent: { ownerMayEdit: true } }` (by-id update only; every other write still needs master edit). `added_by` is `type: 'user'` — never a `lookup` to a `user` object, which does not exist.",
27+
"expected_output": "Line items: `invoice_line` with a `master_detail` field to `invoice`, `required: true`, `deleteBehavior: 'cascade'` (or `'restrict'` — `set_null` is refused on master_detail), and a `summary` roll-up field on the parent. Tagging carries attributes, so it is a junction object (`invoice_tag`) with two `lookup` fields plus `added_by` / `added_at` — not a `multiple: true` lookup (an array of ids) and not a `many_to_many` type, which does not exist. The line object is `sharingModel: 'controlled_by_parent'` with `sharing: { controlledByParent: { ownerMayEdit: true } }` (by-id update only; every other write still needs master edit). `added_by` is `type: 'user'` — never a `lookup` to a `user` object, which does not exist.",
2828
"files": [],
2929
"assertions": {
3030
"must_contain": [
3131
"master_detail",
3232
"deleteBehavior",
33-
"inlineEdit",
3433
"summary",
3534
"lookup",
3635
"ownerMayEdit",
@@ -432,6 +431,21 @@
432431
"event: 'afterInsert'"
433432
]
434433
}
434+
},
435+
{
436+
"id": 25,
437+
"prompt": "`quote_line` 通过 `master_detail` 字段 `quote` 归属 `quote`。新建报价单时要在表单里直接录明细,和报价单一起保存。该怎么声明?",
438+
"expected_output": "On the PARENT `quote` object, a field group that names the child: `fieldGroups: [..., { key: 'lines', label: '明细', relatedList: 'quote_line' }]` (such a group holds no fields). The standard create/edit form of `quote` then enters the lines at that group and saves quote + lines in one atomic transaction, and the record page draws the same table there. Without the group nothing changes: `quote_line` is a tab and the form has no lines, whatever `inlineEdit` on `quote_line.quote` says; `inlineEdit` only picks how the rows are edited (`'grid'` / `'form'`, `true` or absent picks by the child's shape). No custom page and no form view is needed. If either object declares `enable.apiMethods`, it must list `'bulk'`.",
439+
"files": [],
440+
"assertions": {
441+
"must_contain": [
442+
"fieldGroups",
443+
"relatedList: 'quote_line'"
444+
],
445+
"must_not_contain": [
446+
"definePage"
447+
]
448+
}
435449
}
436450
]
437451
}

‎skills/objectstack-data/rules/relationships.md‎

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -247,44 +247,38 @@ which clients are meant to see, acknowledged — a note:
247247

248248
## Inline Editing (Master-Detail Entry)
249249

250-
Declare inline editing **on the relationship**, in the data model — not in a form
251-
view. Set `inlineEdit: true` on the child's `master_detail` (or `lookup`) field
252-
that points back to the parent. The parent's **standard** create/edit form then
253-
renders an editable grid for these children and saves parent + children in **one
254-
atomic transaction**. A parent or child declaring `enable.apiMethods` must list
250+
The parent's **standard** create/edit form enters a child's rows where **a
251+
field group of the parent names that child** (`relatedList`): the group draws
252+
the child's table at its place in the record's details and in the parent's
253+
entry form (below the form's fields when its sections name no field group),
254+
and parent + children save in **one atomic transaction**. Without the group
255+
nothing changes: the child is a tab and the form has no lines, whatever
256+
`inlineEdit` says. A parent or child declaring `enable.apiMethods` must list
255257
`'bulk'`, or that save is refused `405 OBJECT_API_METHOD_NOT_ALLOWED`.
256258

257259
```typescript
258-
// On the CHILD object's FK field:
259-
export default ObjectSchema.create({
260-
name: 'invoice_line',
261-
sharingModel: 'controlled_by_parent',
262-
fields: {
263-
invoice: {
264-
type: 'master_detail',
265-
reference: 'invoice',
266-
inlineEdit: true, // ← edited inline within the Invoice form
267-
inlineTitle: 'Line Items', // optional grid title
268-
// inlineColumns / inlineAmountField — optional overrides; columns are
269-
// otherwise derived from this object's fields.
270-
},
271-
quantity: { type: 'number' },
272-
amount: { type: 'currency' },
273-
},
274-
});
260+
// PARENT `invoice`: the group places the lines and holds no fields
261+
fieldGroups: [{ key: 'lines', label: 'Line Items', relatedList: 'invoice_line' }],
262+
263+
// CHILD `invoice_line`: its master_detail FK, declaring no `relatedList`
264+
invoice: {
265+
type: 'master_detail',
266+
reference: 'invoice',
267+
inlineTitle: 'Line Items', // optional grid title
268+
// inlineColumns / inlineAmountField — optional overrides; columns are
269+
// otherwise derived from this object's fields.
270+
},
275271
```
276272

277-
**Set `inlineEdit` only for true line-item / composition children** (invoice
278-
lines, order items, expense lines) — the things a user enters *together with*
279-
the parent. **Leave it off for associations** (comments, attachments, activity,
280-
audit): those are also `master_detail` (cascade delete) but should NOT clutter
281-
the parent's entry form — surface them as related lists on the detail page.
273+
Name only true line-item / composition children (invoice lines, order items,
274+
expense lines); leave associations (comments, attachments, activity, audit) as
275+
tabs.
282276

283277
The rendering side, `subforms` overrides included: objectstack-ui → Master-Detail Forms.
284278

285279
#### Inline-edit form factor (`grid` vs `form`)
286280

287-
`inlineEdit` also picks how the children are entered:
281+
`inlineEdit` only picks how a placed child's rows are entered:
288282

289283
```typescript
290284
inlineEdit: true // auto — pick grid/form from the child's shape (default)
@@ -300,7 +294,7 @@ editable fields, else `grid`. Set the string to override.
300294
behaviors purely from how you model the child + parent:
301295

302296
```typescript
303-
// Parent
297+
// Parent (a field group names invoice_line, as above)
304298
Invoice = {
305299
fields: {
306300
tax_rate: Field.number({ label: 'Tax Rate (%)' }), // → live Subtotal/Tax/Total stack

‎skills/objectstack-ui/SKILL.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ Two more: [List Views](#list-views), [Actions](#actions).
4545
with `columns` and `modalSize`. `tabbed` flags a required field only on its
4646
own tab and overflows on a phone
4747
([Form Views](./rules/list-views.md#form-views)).
48-
2. **A record entered with its line items is `inlineEdit` on the child's
49-
`master_detail` field**, before any custom page, and its grid needs no "Add
50-
line" button. A parent or child declaring `enable.apiMethods` must list
51-
`'bulk'`, or the save is refused `405`
48+
2. **A record entered with its line items is a parent field group naming the
49+
child** (`fieldGroups: [{ key: 'lines', label: 'Lines', relatedList:
50+
'invoice_line' }]`), before any custom page; without it nothing changes:
51+
the child is a tab and the form has no lines, whatever `inlineEdit` says.
52+
Its grid needs no "Add line" button. A parent or child declaring
53+
`enable.apiMethods` must list `'bulk'`, or the save is refused `405`
5254
([Master-Detail Forms](./rules/list-views.md#master-detail-forms-parent--child-line-items)).
5355
3. **A persisted chart binds a declared dataset.** A widget or report names a
5456
`defineDataset` and selects its `dimensions` / `values` by name; an object

‎skills/objectstack-ui/evals/views-apps-actions-pages.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
{
5555
"id": 6,
5656
"prompt": "Invoice entry as a stepped form — header, then line items, then review — saving the invoice and its lines together.",
57-
"expected_output": "A stepped form over ONE object is `formViews` with `type: 'wizard'` and `sections`, not a screen flow (nothing branches). Line items come from the DATA MODEL: `inlineEdit` on the child's `master_detail` field, which renders the editable grid and saves parent + children in one atomic `/api/v1/batch`; `subforms` only to override derived columns. No custom page, and no 'Add line' button (the ghost row exists).",
57+
"expected_output": "A stepped form over ONE object is `formViews` with `type: 'wizard'` and `sections`, not a screen flow (nothing branches). Line items come from the DATA MODEL: a field group of `invoice` naming the `master_detail` child (`fieldGroups: [{ key: 'lines', label: 'Lines', relatedList: 'invoice_line' }]`), which draws the editable grid in the form and saves parent + children in one atomic `/api/v1/batch`; without the group the form has no lines, whatever `inlineEdit` says. `subforms` only to override derived columns. No custom page, and no 'Add line' button (the ghost row exists).",
5858
"files": [],
5959
"assertions": {
60-
"must_contain": ["type: 'wizard'", "inlineEdit", "formViews", "master_detail"],
60+
"must_contain": ["type: 'wizard'", "relatedList", "formViews", "master_detail"],
6161
"must_not_contain": ["type: 'screen'"]
6262
}
6363
},

‎skills/objectstack-ui/rules/list-views.md‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,19 +367,19 @@ To let users enter a record **together with its child line items** (invoice +
367367
lines, project + tasks) and save them **atomically**, you almost never need a
368368
custom page or form config. Prefer, in order:
369369

370-
1. **Relationship `inlineEdit` (default, zero UI config).** Declare it in the
371-
DATA MODEL — set `inlineEdit` on the child's `master_detail` field that
372-
references the parent. Every standard New/Edit form for the parent (modal,
373-
drawer, full-page) then auto-renders the children and saves parent + children
374-
in one atomic `/api/v1/batch`. **No view metadata needed.** A parent or child
370+
1. **A parent field group naming the child (zero view config).** In the DATA
371+
MODEL, the parent declares `fieldGroups: [{ key: 'lines', label: 'Lines',
372+
relatedList: 'invoice_line' }]`. Its standard New/Edit forms (modal,
373+
drawer, full-page) then draw the children there and save parent + children
374+
in one atomic `/api/v1/batch`. Without the group nothing changes: the child
375+
is a tab and the form has no lines. A parent or child
375376
declaring `enable.apiMethods` must list `'bulk'`, or that save is refused
376-
`405 OBJECT_API_METHOD_NOT_ALLOWED`. The
377-
`true` / `'grid'` / `'form'` ladder and what each value picks:
377+
`405 OBJECT_API_METHOD_NOT_ALLOWED`. `inlineEdit` only picks how rows are
378+
edited, the `true` / `'grid'` / `'form'` ladder:
378379
**objectstack-data → Relationships → Inline Editing**.
379380

380381
2. **Form view `subforms` (override / tuning).** Add to a form view only when you
381-
need to override the derived columns/order, or expose a child the
382-
relationship didn't mark inline:
382+
need to override the derived columns/order, or inline a child no group names:
383383

384384
```typescript
385385
form: {
@@ -395,9 +395,8 @@ custom page or form config. Prefer, in order:
395395
3. **`object-master-detail-form` page block (bespoke layout).** Use a page only
396396
for free-form layouts. Same `details: [{ childObject }]` shorthand.
397397

398-
**Line-item grid behaviors (`grid` mode).** The editable grid is a real
399-
spreadsheet-style line editor, and
400-
every behaviour is derived from the DATA MODEL — computed columns, catalog
398+
**Line-item grid behaviors (`grid` mode).** Every behaviour of the editable
399+
grid is derived from the DATA MODEL — computed columns, catalog
401400
typeahead auto-fill, persisted drag-reorder, and the live Subtotal → Tax → Total
402401
stack: **objectstack-data → Relationships → Inline Editing**. Three things are
403402
authored on this side: a trailing **ghost** row always exists, so never add an

0 commit comments

Comments
 (0)