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/36455-ui-skill-create-surfaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/skills': patch
---

docs(skills): the UI skill teaches the New and Edit forms as built from the object's fields and field groups, and `showOnCreate`

Clause-②: no
Metadata-protocol: none

objectstack-ui no longer teaches an object's internal create and edit form views, which the Console's create and edit surfaces stopped loading. `SKILL.md` Traps 1 and `rules/list-views.md` "Form Views" now say that New and Edit are built from the object's fields, sectioned by its `fieldGroups` (`collapse: 'collapsed'` folds a rarely filled section) and following the fields' own rules; that `showOnCreate: false` leaves a field off every create surface and is refused beside `required: true`; and that a container's `form`, `formViews.default` and `formViews.create` still parse, steer nothing, and are reported by `os validate` as `form-view-internal-not-loaded`. The two form views that load are kept: a named `formViews` entry an action of type `form` opens (`/forms/:name`), and a public form (`sharing.enabled: true`), taught as before. "Master-Detail Forms" drops the form-view `subforms` override, which is no longer read; the parent field group naming the child and the page block remain. `evals/views-apps-actions-pages.json`, evals 1, 6, 13 and 19: each taught or assumed an internal form view and now expects the object's field groups and `showOnCreate`.
10 changes: 5 additions & 5 deletions skills/objectstack-ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ metadata:

Two more: [List Views](#list-views), [Actions](#actions).

1. **A long form stays `simple`**: collapse what is rarely filled and size it
with `columns` and `modalSize`. `tabbed` flags a required field only on its
own tab and overflows on a phone
([Form Views](./rules/list-views.md#form-views)).
1. **New and Edit are the object's fields and `fieldGroups`, never a form
view**: they load no `form` or `formViews.create`, which parse.
`showOnCreate: false` keeps a field off every create surface (refused
beside `required: true`): [Form Views](./rules/list-views.md#form-views).
2. **A record entered with its line items is a parent field group naming the
child** (`fieldGroups: [{ key: 'lines', label: 'Lines', relatedList:
'invoice_line' }]`), before any custom page; without it nothing changes:
Expand Down Expand Up @@ -74,7 +74,7 @@ Two more: [List Views](#list-views), [Actions](#actions).
| Authoring | In | Open first |
|:--|:--|:--|
| A list, board, calendar, gallery or gantt: columns, `filter`, quick filters, toolbar search, sorting, grouping | `src/views/*.view.ts` | [List Views](./rules/list-views.md) |
| A form (`simple` / `tabbed` / `wizard`): width, columns and `sections`; master-detail (a parent with line items), a public form, field conditional rules | `src/views/*.view.ts` | [Form Views](./rules/list-views.md#form-views) |
| New / Edit form (field groups, `showOnCreate`, line items, field rules); a named or public form | the object; `src/views/*.view.ts` | [Form Views](./rules/list-views.md#form-views) |
| An app and its navigation; who sees or opens it; object nav, a `filters` slice or an interface page | `src/apps/*.app.ts` | [Navigation](./rules/navigation.md) |
| What a record page shows: related lists, a slotted or full page; how a record opens | the object | [Record Page](./rules/record-page.md) |
| A button or operation: `locations`, visibility, dialog and toast copy, params, new tab, the body's `ctx`, refusing by code (`refusals`) | `src/actions/*.action.ts`, `*.actions.ts` | [Actions](./rules/actions.md) |
Expand Down
7 changes: 4 additions & 3 deletions skills/objectstack-ui/evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ view / page / dashboard / report metadata.
base object's `allowExport` permission).
- `views-apps-actions-pages.json` — `defineView` containers, `App.create`
navigation, `defineAction` surfaces, record / interface pages, package
docs, wizard forms, a view added beside the list (and the empty board over
a field added with it), a write button whose body writes, the view kind
the request names.
docs, the New and Edit form built from the object (field groups,
`showOnCreate`, line items), a view added beside the list (and the empty
board over a field added with it), a write button whose body writes, the
view kind the request names.
- `triggers.json` — trigger cases: requests that should load this skill
(`should_trigger: true`) and near misses that should not (`false`), graded
on whether the skill was loaded, never on the answer.
Expand Down
20 changes: 10 additions & 10 deletions skills/objectstack-ui/evals/views-apps-actions-pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"evals": [
{
"id": 1,
"prompt": "Create `src/views/support-case.view.ts`: a default grid (subject linking to the record, status, priority, owner, due date), a 'My Open Cases' list, a kanban by status, and a simple edit form. None of the project's files are in this directory: write the file in your answer.",
"expected_output": "One `defineView({ list, form, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`), and `form` with `type: 'simple'` and `sections` referencing a declared field group.",
"prompt": "Create `src/views/support-case.view.ts`: a default grid (subject linking to the record, status, priority, owner, due date), a 'My Open Cases' list, a kanban by status, and a simple edit form with the case details in one section. None of the project's files are in this directory: write the file in your answer.",
"expected_output": "One `defineView({ list, listViews })` container — never a bare flat view object. `data: { provider: 'object', object: 'support_case' }`, `columns` with `link: true` on `subject`, the owner column is the injected `owner_id` (never an `assigned_to` field), a `listViews.my_open` entry with `filter` triples (`{ field: 'owner_id', operator: 'equals', value: '{current_user_id}' }`), a kanban entry with the required top-level `columns` plus `kanban: { groupByField: 'status' }` (no top-level `groupBy`). No `form` in the container: the edit form is built from the object, so the answer says its section is a `fieldGroups` entry of `support_case` (an internal `form` parses and is not loaded).",
"files": [],
"assertions": {
"must_contain": ["defineView", "provider: 'object'", "listViews", "groupByField", "link: true", "{current_user_id}", "owner_id"],
"must_not_contain": ["groupBy:", "conditionalRequired:", "'assigned_to'"]
"must_not_contain": ["groupBy:", "conditionalRequired:", "'assigned_to'", "form: {"]
}
},
{
Expand Down Expand Up @@ -54,10 +54,10 @@
{
"id": 6,
"prompt": "Invoice entry as a stepped form — header, then line items, then review — saving the invoice and its lines together.",
"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).",
"expected_output": "No form view and no screen flow (nothing branches): the invoice's New form is built from the object, so header, then lines, then the rest is the order of `invoice`'s `fieldGroups`. Line items come from the DATA MODEL: a field group naming the `master_detail` child (`fieldGroups: [{ key: 'header', ... }, { 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. The hand-over says the steps are sections of one form, not a wizard: a `formViews` wizard is not loaded by New or Edit, and a named form an action opens draws no line items. No custom page, and no 'Add line' button (the ghost row exists).",
"files": [],
"assertions": {
"must_contain": ["type: 'wizard'", "relatedList", "formViews", "master_detail"],
"must_contain": ["fieldGroups", "relatedList", "master_detail"],
"must_not_contain": ["type: 'screen'"]
}
},
Expand Down Expand Up @@ -123,7 +123,7 @@
},
{
"id": 13,
"prompt": "`task` already ships `defineView({ list, form })`. Reps want a board: add a `priority` select (A / B / C) to the object and a kanban grouped by it — the list must stay — and tell them what they will see when they first open the board.",
"prompt": "`task` already ships `defineView({ list })`. Reps want a board: add a `priority` select (A / B / C) to the object and a kanban grouped by it — the list must stay — and tell them what they will see when they first open the board.",
"expected_output": "A new `listViews.priority_kanban` entry (`type: 'kanban'`, the required top-level `columns`, `kanban: { groupByField: 'priority' }`) beside the untouched default `list`, never the list retyped into a board. The hand-over discloses the empty board: every existing task has no `priority` yet, so all of them sit in the trailing `Uncategorized` lane (scroll right on a narrow screen) under one empty lane per option; dragging a card onto a real lane writes the field, or they edit from the list; a runtime-token or CEL `defaultValue` on the new field fills no existing row, and a literal one does only on a SQL datasource, where it becomes the column DEFAULT.",
"files": [],
"assertions": {
Expand Down Expand Up @@ -183,12 +183,12 @@
},
{
"id": 19,
"prompt": "Author the default form view for `opportunity`: 42 fields in six sections (Basics, Amounts, Dates, Partner, Shipping, Internal Notes). Reps fill Basics and Amounts on every create and the other four rarely. The form opens in the New dialog, mostly on wide screens.",
"expected_output": "One form view with `type: 'simple'`: the six sections stacked on one scrolling page, each listing its own `fields`, with `collapsed: true` on the four rarely filled ones (or `collapse: 'collapsed'` on those `fieldGroups` entries of the object). `columns: 3` uses the wide dialog and `modalSize: 'xl'` sizes it. Not tabs: a required field on another tab is flagged only on its tab, and the tab strip overflows on a phone.",
"prompt": "Shape the New and Edit form of `opportunity`: 42 fields in six sections (Basics, Amounts, Dates, Partner, Shipping, Internal Notes). Reps fill Basics and Amounts on every create and the other four rarely, and `loss_reason` is never known at create. The form opens in the New dialog, mostly on wide screens.",
"expected_output": "No form view: New and Edit are built from the object. Six `fieldGroups` entries on `opportunity` in that order, with `collapse: 'collapsed'` on the four rarely filled ones, and `showOnCreate: false` on `loss_reason`, which edit, the record page and lists still show (it must not be `required: true`: the pair is refused). Not a `form`, `formViews.default` or `formViews.create` (each parses and is not loaded), and no `modalSize` or `columns`: the dialog's size and column count are derived.",
"files": [],
"assertions": {
"must_contain": ["type: 'simple'", "modalSize"],
"must_not_contain": ["type: 'tabbed'"]
"must_contain": ["fieldGroups", "collapse: 'collapsed'", "showOnCreate: false"],
"must_not_contain": ["type: 'tabbed'", "modalSize:"]
}
},
{
Expand Down
66 changes: 31 additions & 35 deletions skills/objectstack-ui/rules/list-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
### The `defineView` container (`*.view.ts` file shape)

Views ship **inside a `defineView` container** — one per object, aggregating
the default `list` and `form`, named `listViews`, and `formViews`. The loader
the default `list`, named `listViews` and named `formViews`. The loader
expands it into `<object>.<key>` view items that power the view switcher.

<!-- os:check -->
Expand All @@ -23,11 +23,13 @@ const data = { provider: 'object' as const, object: 'support_case' };

export const CaseViews = defineView({
list: { label: 'All Cases', type: 'grid', data, columns: ['subject', 'status'] },
form: { type: 'simple', data, sections: [{ group: 'case_detail' }] },
listViews: {
open: { label: 'Open', type: 'grid', data, columns: ['subject', 'status'],
filter: [{ field: 'status', operator: 'equals', value: 'open' }] },
},
formViews: { // named: a `form` action targets `support_case.triage`
triage: { type: 'simple', data, sections: [{ group: 'case_detail' }] },
},
});
```

Expand Down Expand Up @@ -341,21 +343,29 @@ group, **no resize handles**. Leaf tasks resize unless `locked: true`.

## Form Views

Field width, column count and the `sections` ladder:
[Record Presentation](./navigation.md#record-presentation--surface-width--columns-are-auto-derived).

| Type | When to Use |
|:-----|:------------|
| `simple` | Stacked sections on one scrolling page — the default, at any field count |
| `tabbed` | One tab per section — only for sections read apart; a required field on another tab is flagged only on its tab, and the tab strip overflows on a phone |
| `wizard` | Step-by-step flow — guided data entry (onboarding, applications) |

**A long form stays `simple`: collapse what is rarely filled** with
`collapse: 'collapsed'` on the object's `fieldGroups` entry, or `collapsed: true`
on a form section listing its own `fields`. `columns` (form or section) is a
per-row ceiling a narrow screen lowers; unset, a section draws two, so set `3`
for a wide data-entry form. `modalSize` (`sm` to `full`) sizes the New / Edit
dialog; unset, the field count picks `lg` or `xl`.
**An object's New and Edit forms are not form views.** The dialogs, the
full-page form (`editMode: 'page'`) and a create or edit an action opens are
built from the object: its fields, sectioned by `fieldGroups` in array order,
following each field's own rules. Authored there:

- `collapse: 'collapsed'` on a `fieldGroups` entry folds a rarely filled
section.
- `showOnCreate: false` on a field leaves it off every create surface; edit,
the record page and lists keep it. Beside `required: true` it is refused,
whatever its `defaultValue`: keep it on create, or make it `requiredWhen`.
- Dialog size and column count are derived, never authored:
[Record Presentation](./navigation.md#record-presentation--surface-width--columns-are-auto-derived).

A container's `form`, `formViews.default` and `formViews.create` still parse
and steer nothing (sections, tabs, steps, `subforms`, `defaults`, `modalSize`);
`os validate` warns `form-view-internal-not-loaded`. Two kinds of form view
load:

**A named form** is a `formViews` entry under any other key, registered as
`OBJECT.key`; an action of `type: 'form'` whose `target` is that name opens it
on its own page (`/forms/:name`). Its `type` is `simple` (stacked sections, the
default), `tabbed` (a tab per section) or `wizard` (a step per section, each
listing `fields`, never `{ group }`). It draws no child line items.

**A public form** is a form view with
`sharing: { enabled: true, allowAnonymous: true, publicLink: 'slug' }`:
Expand All @@ -365,7 +375,7 @@ Web-to-Lead at `GET/POST /api/v1/forms/:slug`.

To let users enter a record **together with its child line items** (invoice +
lines, project + tasks) and save them **atomically**, you almost never need a
custom page or form config. Prefer, in order:
custom page. Prefer, in order:

1. **A parent field group naming the child (zero view config).** In the DATA
MODEL, the parent declares `fieldGroups: [{ key: 'lines', label: 'Lines',
Expand All @@ -378,22 +388,8 @@ custom page or form config. Prefer, in order:
edited, the `true` / `'grid'` / `'form'` ladder:
**objectstack-data → Relationships → Inline Editing**.

2. **Form view `subforms` (override / tuning).** Add to a form view only when you
need to override the derived columns/order, or inline a child no group names:

```typescript
form: {
type: 'simple',
sections: [{ group: 'invoice_header' }], // a declared fieldGroup
subforms: [
{ childObject: 'invoice_line', // set `columns` only to override
title: 'Line Items', addLabel: 'Add line' },
],
},
```

3. **`object-master-detail-form` page block (bespoke layout).** Use a page only
for free-form layouts. Same `details: [{ childObject }]` shorthand.
2. **`object-master-detail-form` page block (bespoke layout).** Use a page only
for free-form layouts: `details: [{ childObject }]`.

**Line-item grid behaviors (`grid` mode).** Every behaviour of the editable
grid is derived from the DATA MODEL — computed columns, catalog
Expand All @@ -403,7 +399,7 @@ authored on this side: a trailing **ghost** row always exists, so never add an
"Add line" button to the grid (typing in the ghost materialises a row; an
untouched one is never persisted; a record-header action that inserts a priced
line is [Actions](./actions.md)); `autofill: false` opts one column out of the typeahead copy;
and the form's `taxRateField` overrides which parent field drives the totals.
and that page block's `taxRateField` overrides which parent field drives the totals.

## Field Conditional Rules in Forms

Expand Down
Loading