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
10 changes: 10 additions & 0 deletions .changeset/36281-embedded-sub-fields-hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/lint': patch
---

fix(lint): the `field/embedded-sub-fields` fix names the field group that inlines the child

Clause-②: no
Metadata-protocol: none

The rule's fix line told the author to make the typed list a child object and that `inlineEdit: 'grid'` edits it inline. A child is inlined in its parent's form only when a field group of the parent names it in `relatedList`; the FK's `inlineEdit` picks grid or form, nothing more. An author who followed the old line got a child shown as a tab, with no lines on the parent's form. The fix now reads: make the typed list a child object whose `master_detail` field points back here, name it in a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key. When the rule fires, its id, severity and path are unchanged.
14 changes: 14 additions & 0 deletions packages/lint/src/data-model-rules.embedded-sub-fields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,17 @@ describe('field/embedded-sub-fields — one-line verdict, `os explain` carries t
}
});
});

describe('field/embedded-sub-fields — the fix names the field group that inlines the child', () => {
// A parent field group whose `relatedList` names the child places it on the
// parent's form; the FK's `inlineEdit` only picks grid or form (spec
// `EMBEDDED_JSON_TYPED_LIST`). A hint teaching `inlineEdit` as the switch
// leaves the author a child that is only a tab.
it('routes to `fieldGroups[].relatedList` and gives `inlineEdit` only the form factor', () => {
const [issue] = findings(audit({ type: 'repeater', fields: SUB_ROWS }));
expect(issue!.fix).toContain('`master_detail`');
expect(issue!.fix).toContain('`fieldGroups[].relatedList`');
expect(issue!.fix).toContain('`inlineEdit` only picks how rows are edited');
expect(issue!.fix).not.toContain("inlineEdit: 'grid'");
});
});
4 changes: 2 additions & 2 deletions packages/lint/src/data-model-rules.fix-lines.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ describe('[#22161] data-model-rules.ts — one remedy line per fix', () => {

it('field/embedded-sub-fields: one line, whatever the type, the keys or the names', () => {
const fix =
'Make the typed list a child object whose `master_detail` field points back here ' +
"(`inlineEdit: 'grid'` edits it inline), and remove the key.";
'Make the typed list a child object whose `master_detail` field points back here, name it in ' +
'a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key.';
for (const type of ['repeater', 'composite']) {
const objects = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/lint/src/data-model-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,8 @@ export function lintDataModel(objects: any[]): LintIssue[] {
`object-level ${type} is untyped JSON with no sub-fields`,
path: `${fieldPath}.${declared[0]}`,
fix:
'Make the typed list a child object whose `master_detail` field points back here ' +
"(`inlineEdit: 'grid'` edits it inline), and remove the key.",
'Make the typed list a child object whose `master_detail` field points back here, name it in ' +
'a `fieldGroups[].relatedList` here (`inlineEdit` only picks how rows are edited), and remove the key.',
});
}
}
Expand Down
Loading