diff --git a/docs/specifications/collection-views.md b/docs/specifications/collection-views.md index f05e6ac..035c858 100644 --- a/docs/specifications/collection-views.md +++ b/docs/specifications/collection-views.md @@ -85,7 +85,7 @@ Board and Calendar cards used to title themselves off "the first `text`-type fie - **Storage.** `Collection.primaryFieldKey?: string` (`data-model.md` §1) — a schema key, stored the same whole-value way as `schema` itself (`readCollectionMeta`/`ymeta.set('primaryFieldKey', ...)` in `src/lib/data/records.ts`). Absent on every Collection created before this feature, and on any Collection where no field has been explicitly chosen since — no migration script runs; resolution (next bullet) is what makes an unset Collection keep behaving exactly as it did before. - **Resolution: `resolvePrimaryField(schema, primaryFieldKey)`.** Returns the schema field named by `primaryFieldKey` when it exists and is an eligible type; otherwise falls back to the first `text` field in schema order — the exact pre-#96 implicit rule — so a Collection created before this feature, or one whose chosen primary field was since deleted or retyped away, keeps showing the same title without a migration step. The fallback only ever considers `text` fields, not every eligible type, so this returns `undefined` both when the schema has no eligible field at all and when it has eligible fields (e.g. a lone `number` or `select` field) but none of type `text` (Board/Calendar's card/entry title then reads "Untitled", same as before). Board and Calendar both call this in place of their old `schema.find(p => p.type === 'text')` line; `FieldMenu`'s primary-field indicator (next bullet) calls it too, so the star always matches what's actually titling a card. - **Eligible types: everything except `relation`.** A `relation` value is a list of record IDs with no display string of its own (data-model.md's `PropertyValue`) — every other type (`text`, `number`, `date`, `select`, `checkbox`) already renders as one displayable value via `PropertyValueCell`, so `setPrimaryField` rejects choosing a `relation` field (`ValidationError`), and a retype that turns the current primary field _into_ `relation` clears `primaryFieldKey` in the same transaction rather than leaving it pointing at a now-invalid field. Deleting the current primary field clears it the same way. Both repairs mirror the existing `deleteCollectionProperty`/`updateCollectionProperty` pattern of fixing up stale schema references in one transaction rather than leaving a dangling key for a reader to notice later. -- **Display value: `primaryFieldDisplayValue(value, property)`** (`src/lib/data/views.ts`) — a plain-text rendering of any eligible type's value (a `select` value resolves through `property.options` to its label; `checkbox` renders "Checked"/empty), used for Board/Calendar's card-title `aria-label`s and Calendar's static entry-title text. Board's own card _editor_ still renders the primary field as a full `PropertyValueCell` (so whichever type is chosen — not just `text` — stays directly editable inline); this function is only for the places a plain string is needed instead of an editable cell. +- **Display value: `primaryFieldDisplayValue(value, property)`** (`src/lib/data/views.ts`) — a plain-text rendering of any eligible type's value (a `select` value resolves through `property.options` to its label; `checkbox` renders "Checked"/"Unchecked"), used for Board's card-title `aria-label`s and other plain-text title fallbacks. Board's card and Calendar's entry normally render their primary field as a full `PropertyValueCell` (so whichever type is chosen — not just `text` — stays directly editable inline); this function is only for places a plain string is needed instead of an editable cell. - **Colliding with `groupBy` or `swimlaneBy` (issue #104, #105).** `primaryFieldKey` and Board/Calendar's `groupBy` (§3), or Board's `swimlaneBy`, are independent choices — nothing stops a user from pointing any of them at the same `select`/`date` field. Both Board's card title and Calendar's entry title normally render the primary field as a directly-editable `PropertyValueCell` (§4), which — when `titleProperty.key` matches `groupProperty.key` (Board or Calendar) or Board's `swimlaneProperty.key` — would otherwise sit right next to another editable control for the identical value: Board's matching "Move to column"/"Move to swimlane" `