feat(admin): footer record actions, deletable flag, mail row states and diff styles
- FormView footer RecordActions when there is no preview; meta.deletable hides Delete - Partial fields reload after save and record actions; customized/outdated badges - .summer-diff kit and docs for codeeditor, mailpreview and footer actions Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -66,6 +66,10 @@ As in WinterCMS, a shortcut presses a button on the screen. Ctrl and Cmd are bot
|
||||
|
||||
A shortcut does what its button does, and nothing while the button is disabled (while saving, while loading, with an upload in progress). The save keys also work while typing in a field, a code field or the rich editor. There, on a record form, Ctrl+Enter saves and closes instead of inserting a line break (Shift+Enter still does), and on a create form Ctrl+Shift+S creates and starts a new record instead of toggling strikethrough; this is a known trade-off. Ctrl+S never opens the browser's Save page dialog.
|
||||
|
||||
The `codeeditor` field (CodeMirror 6) keeps the same model: Tab is not bound to indent, so focus leaves the editor; Mod+S and Mod+Enter still save the form; Esc does not cancel while the caret is in the editor. A load failure falls back to a monospace textarea that still saves.
|
||||
|
||||
The `mailpreview` field posts the unsaved draft to `POST /mail/preview` and shows the server HTML in a sandboxed iframe (`sandbox=""` with `srcdoc` only). **Send test to me** posts the same draft to `POST /mail/test-send` with no recipient; a 429 disables the button for `Retry-After` seconds.
|
||||
|
||||
Esc, / and ? do nothing while typing in a field, or while a dialog, popover or menu is open; those close on Esc themselves. When a dialog with a form is open (a related record, a pivot, the record picker, file details, a new API token), Ctrl+S and Ctrl+Enter submit that dialog and never the form underneath. Settings forms and My account have no unsaved-changes question, so Esc does not leave them. Save buttons show their shortcut in their tooltip.
|
||||
|
||||
## Types from OpenAPI
|
||||
|
||||
@@ -29,7 +29,9 @@ update:
|
||||
|
||||
On a create form Save follows `redirect` and Save and close follows `redirectClose`; on an update form Save stays on the record. The create form also has Create and new, which saves the record and opens an empty create form of the same controller, ignoring both redirects. The buttons answer Ctrl+S (Cmd+S on macOS), Ctrl+Enter and, on the create form, Ctrl+Shift+S.
|
||||
|
||||
An optional `recordActions` key lists the record actions the form offers, by the names the controller registers through `pact.HasAdminRecordActions`. It needs a `preview` block, because record actions are offered on the [preview screen](#preview-screen). The show response of a record then carries `meta.actions`: the declared actions the administrator may run and that apply to the record in its current state. See [Record actions](admin-controllers.md#record-actions).
|
||||
An optional `recordActions` key lists the record actions the form offers, by the names the controller registers through `pact.HasAdminRecordActions`. When the form has a `preview` block, those actions appear on the [preview screen](#preview-screen). When it has no preview, the update form footer shows them after Delete (outline buttons; a `danger` action uses the danger confirm). The show response of a record carries `meta.actions`: the declared actions the administrator may run and that apply to the record in its current state. See [Record actions](admin-controllers.md#record-actions).
|
||||
|
||||
`meta.deletable` on the show response hides Delete when it is `false`. When the key is absent, Delete behaves as before (`true`), so existing controllers are unchanged. After every successful save and record action, `type: partial` fields reload so status hints and diffs stay current.
|
||||
|
||||
## fields.yaml
|
||||
|
||||
@@ -107,12 +109,12 @@ for _, f := range form.Fields {
|
||||
| `repeater` | A list of rows, each with its own small form, stored as JSON in one column; see [Repeater](#repeater). |
|
||||
| `money` | An exact decimal amount with a currency suffix, never a float and never rounded; see [Money](#money). |
|
||||
| `taglist` | A list of tags edited as chips, stored as a JSON array or as one separator-joined string; see [Taglist](#taglist). |
|
||||
| `codeeditor` | A source editor for HTML, CSS or plain text (`language` required: `html`, `css` or `text`); optional `size` and `mailImages: true` for the mail image insert control. |
|
||||
| `colorpicker` | A `#rrggbb` colour (or empty); Winter's `availableColors` is not supported. Invalid colours are a 422 with `backend::lang.colorpicker.invalid`. |
|
||||
| `mailimage` | A single image chosen from the mail image library (stores a file id). Missing library images are a 422 with `backend::lang.mailimage.missing`. |
|
||||
| `mailpreview` | A valueless live preview control (`mode` required: `template`, `layout`, `partial` or `branding`); never bound or accepted in a save body. |
|
||||
| `codeeditor` | A CodeMirror 6 source editor for HTML, CSS or plain text (`language` required: `html`, `css` or `text`); optional `size` and `mailImages: true` for the mail image insert control. Tab leaves the editor; Mod+S / Mod+Enter still save. A load failure falls back to a monospace textarea. |
|
||||
| `colorpicker` | A `#rrggbb` colour (or empty) with a native swatch and hex text; Winter's `availableColors` is not supported. Invalid colours are a 422 with `backend::lang.colorpicker.invalid`. |
|
||||
| `mailimage` | A single image chosen from the mail image library (stores a file id or null). Missing library images show `backend::lang.mailimage.missing` in the admin and are a 422 on save. |
|
||||
| `mailpreview` | A valueless live preview control (`mode` required: `template`, `layout`, `partial` or `branding`); never bound or accepted in a save body. Renders the server HTML in a sandboxed iframe and can send a test to the signed-in administrator. |
|
||||
|
||||
The WinterCMS widgets that are not in this list (the code editor, the color picker, the media finder and the others) are not provided. A field with one of those types stops the start-up, unless a plugin registers that alias as its own field type: plugins add field types with a custom element and Go code that decides what is stored; see [Plugin field types](field-types.md).
|
||||
The WinterCMS widgets that are not in this list (the media finder and the others) are not provided. A field with one of those types stops the start-up, unless a plugin registers that alias as its own field type: plugins add field types with a custom element and Go code that decides what is stored; see [Plugin field types](field-types.md).
|
||||
|
||||
### Field options
|
||||
|
||||
|
||||
Reference in New Issue
Block a user