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:
2026-11-13 13:37:55 +01:00
parent aba512800e
commit d13340672f
9 changed files with 155 additions and 25 deletions

View File

@@ -1,14 +1,18 @@
<script setup lang="ts">
import { inject, ref } from 'vue'
import { t } from '../../../app/i18n'
import PartialHost from '../../partial/PartialHost.vue'
import ExtensionFailure from '../../ui/ExtensionFailure.vue'
import type { FieldControlProps } from '../control'
import { FORM_PARTIAL_RELOAD } from '../formContext'
// A `type: partial` form row (D-09; UI-SPEC S2): the controller partial
// named by `path`, rendered on create (no record) and update (?id=). It holds
// no value. The row's visible label, when declared, names the group. A form
// without a controller (a settings page) has no partial route to call.
// Phase 35: reloads when FormView bumps FORM_PARTIAL_RELOAD after save/action.
const props = defineProps<FieldControlProps>()
const reloadKey = inject(FORM_PARTIAL_RELOAD, ref(0))
</script>
<template>
@@ -25,6 +29,7 @@ const props = defineProps<FieldControlProps>()
:source="source"
:name="props.field.path || props.field.name"
:record-id="recordId ?? null"
:reload-key="reloadKey"
/>
<ExtensionFailure v-else data-partial-failed :text="t('backend::lang.extension.partial_failed')" />
</div>

View File

@@ -16,6 +16,12 @@ export const FORM_PATCH: InjectionKey<(name: string, value: unknown) => void> =
/** The form schema's locale (meta.locale). */
export const FORM_LOCALE: InjectionKey<Readonly<Ref<string>>> = Symbol('summer.form.locale')
/**
* Bumped after every successful save and record action so `type: partial`
* fields re-fetch (Phase 35, UI-SPEC C8).
*/
export const FORM_PARTIAL_RELOAD: InjectionKey<Readonly<Ref<number>>> = Symbol('summer.form.partialReload')
/** Enabled content locales for ML controls (schema meta.enabledLocales). */
export const FORM_ENABLED_LOCALES: InjectionKey<Readonly<Ref<readonly string[]>>> = Symbol('summer.form.enabledLocales')

View File

@@ -157,7 +157,7 @@ function initials(value: unknown): string {
.join('')
}
const ROW_STATES = ['deleted', 'negative', 'disabled']
const ROW_STATES = ['deleted', 'negative', 'disabled', 'customized', 'outdated']
/** The row's known states in the fixed order; anything else is dropped. */
function statesOf(row: AdminRecord): string[] {

View File

@@ -15,8 +15,10 @@ const STYLES: Record<string, string> = {
deleted: 'border border-border-strong text-muted',
negative: 'bg-danger-soft text-danger',
disabled: 'bg-subtle text-muted',
customized: 'border border-border-strong text-text',
outdated: 'bg-sel text-text',
}
const ORDER = ['deleted', 'negative', 'disabled']
const ORDER = ['deleted', 'negative', 'disabled', 'customized', 'outdated']
const badges = computed(() => ORDER.filter((state) => props.states.includes(state)))
</script>

View File

@@ -492,6 +492,42 @@
margin: 0;
font-weight: 400;
}
/* Unified diff kit for mail file-version partials (Phase 35, UI-SPEC C7). */
.summer-diff {
margin: 0;
max-height: 480px;
overflow: auto;
padding: 12px 16px;
border: 1px solid var(--c-border);
border-radius: 12px;
background: var(--c-subtle);
font-family: var(--font-mono);
font-size: 13px;
line-height: 1.5;
white-space: pre;
color: var(--c-text);
}
.summer-diff__add,
.summer-diff__del,
.summer-diff__ctx {
display: block;
}
.summer-diff__add {
background: var(--c-ok-bg);
color: var(--c-ok-text);
}
.summer-diff__del {
background: var(--c-danger-soft);
color: var(--c-danger);
}
.summer-diff__ctx {
color: var(--c-text);
}
}
@media (prefers-reduced-motion: reduce) {

View File

@@ -4,7 +4,15 @@ import { onBeforeRouteLeave, onBeforeRouteUpdate, useRoute, useRouter } from 'vu
import { ArrowLeft, Trash2 } from '@lucide/vue'
import { api } from '../api/client'
import { parentFileRoutes } from '../api/files'
import type { AdminRecord, ErrorEnvelope, FormView, RecordEnvelope, RecordMeta, RelationOption } from '../api/types'
import type {
AdminRecord,
ErrorEnvelope,
FormView,
RecordAction,
RecordEnvelope,
RecordMeta,
RelationOption,
} from '../api/types'
import { controllerIdFromParams, controllerPath } from '../app/controllerRoutes'
import { shortcutHint } from '../app/hotkeys'
import { currentLocale, message, t } from '../app/i18n'
@@ -20,6 +28,7 @@ import {
FORM_ENABLED_LOCALES,
FORM_FEEDBACK,
FORM_LOCALE,
FORM_PARTIAL_RELOAD,
FORM_PATCH,
FORM_PERMISSION_LOCKS,
FORM_REMEMBER_LABEL,
@@ -28,6 +37,7 @@ import {
FORM_VALUES,
createUploadGate,
} from '../components/form/formContext'
import RecordActions from '../components/form/RecordActions.vue'
import type { AdminDependentOptionsResult } from '../api/types'
import { RELATION_MANAGER, needsRecord } from '../components/form/registry'
import { applyTriggers } from '../components/form/trigger'
@@ -91,6 +101,12 @@ const labels = ref<RecordMeta['labels']>({})
const permissionLocks = ref<NonNullable<RecordMeta['permissionLocks']>>({})
/** The controller's record title (meta.title, pact.FormRecordTitle); '' when it names none. */
const recordTitle = ref('')
/** Record actions from the show response (footer when there is no preview). */
const actions = ref<RecordAction[]>([])
/** When false, Delete is hidden; absent means true (existing controllers). */
const deletable = ref(true)
const acting = ref(false)
const partialReload = ref(0)
const errors = ref<Record<string, string[]>>({})
// The text of a save the server refused with 403 (UI-SPEC S6). It is a
// banner, not a toast: it stays readable until the next save attempt.
@@ -248,6 +264,8 @@ function adopt(record: RecordEnvelope | undefined): void {
labels.value = record.meta.labels ?? {}
permissionLocks.value = record.meta.permissionLocks ?? {}
recordTitle.value = record.meta.title ?? ''
actions.value = record.meta.actions ?? []
deletable.value = record.meta.deletable !== false
}
saved.value = snapshot(editablePayload(fields.value, values.value, mode, permissionLocks.value))
}
@@ -359,6 +377,7 @@ provide(FORM_ENABLED_LOCALES, computed(() => schemaEnabledLocales(schema.value?.
provide(FORM_ASSETS, () => assetsReady)
provide(FORM_PERMISSION_LOCKS, computed(() => permissionLocks.value))
provide(FORM_TRIGGER_NOTES, computed(() => triggered.value.notes))
provide(FORM_PARTIAL_RELOAD, partialReload)
// The form's single polite live region (dependent dropdown clears, repeater
// moves) and the feedback nested controls read: errors and notices by row
// path, the confirm dialog (Phase 17, D-07, D-08).
@@ -480,6 +499,7 @@ async function save(): Promise<RecordEnvelope | null> {
// The save committed everything held against the session.
pendingChanges.value = 0
revision.value++
partialReload.value++
const savedText = message(schema.value.messages.saved, undefined, { name: recordName.value })
// The toast repeats the notices, so a save that navigates away (save
// and close) still tells the administrator what changed.
@@ -543,6 +563,46 @@ async function onSaveAndNew(): Promise<void> {
}
}
const footerActions = computed(
() => mode === 'update' && !singleton.value && !backToPreview.value && actions.value.length > 0,
)
const showDelete = computed(() => mode === 'update' && !singleton.value && deletable.value)
const footerBusy = computed(() => busy.value || acting.value)
async function onActionDone(text: string): Promise<void> {
showToast(text)
if (recordId === null) {
return
}
const result = await api.GET('/{vendor}/{plugin}/{controller}/{id}', {
params: { path: { ...path, id: recordId } },
})
if (result.data) {
adopt(result.data)
partialReload.value++
} else if (result.response.status === 404) {
failed.value = true
}
}
async function onActionStale(): Promise<void> {
// RecordActions already toasted action_stale; reload the record in place.
if (recordId === null) {
return
}
const result = await api.GET('/{vendor}/{plugin}/{controller}/{id}', {
params: { path: { ...path, id: recordId } },
})
if (result.data) {
adopt(result.data)
partialReload.value++
}
}
function onActionGone(): void {
failed.value = true
}
async function onDelete(): Promise<void> {
if (recordId === null || busy.value || !schema.value) {
return
@@ -678,27 +738,40 @@ void load()
</template>
<footer
class="fixed right-0 bottom-0 left-[var(--shell-offset,0px)] z-30 flex items-center gap-2.5 border-t border-border bg-surface px-8 py-3.5"
class="fixed right-0 bottom-0 left-[var(--shell-offset,0px)] z-30 flex flex-wrap items-center gap-2.5 border-t border-border bg-surface px-8 py-3.5"
>
<Button
v-if="mode === 'update' && !singleton"
variant="danger"
data-action="delete"
:icon="Trash2"
:disabled="busy || loading || !schema"
@click="onDelete"
>
{{ t('backend::lang.form.delete') }}
</Button>
<div class="ml-auto flex items-center gap-2.5">
<Button variant="ghost" data-action="cancel" hotkey="escape" @click="onLeave">{{ t('backend::lang.form.cancel') }}</Button>
<div class="flex flex-wrap items-center gap-2.5">
<Button
v-if="showDelete"
variant="danger"
data-action="delete"
:icon="Trash2"
:disabled="footerBusy || loading || !schema"
@click="onDelete"
>
{{ t('backend::lang.form.delete') }}
</Button>
<RecordActions
v-if="footerActions && recordId !== null"
:source="path"
:record-id="recordId"
:actions="actions"
:disabled="footerBusy || loading || !schema"
@busy="(running: boolean) => (acting = running)"
@done="onActionDone"
@stale="onActionStale"
@gone="onActionGone"
/>
</div>
<div class="ml-auto flex flex-wrap items-center gap-2.5">
<Button variant="ghost" data-action="cancel" hotkey="escape" :disabled="footerBusy" @click="onLeave">{{ t('backend::lang.form.cancel') }}</Button>
<Button
v-if="mode === 'create'"
variant="outline"
data-action="save-new"
hotkey="mod+shift+s"
:title="shortcutHint(t('backend::lang.form.create_and_new'), 'mod+shift+s')"
:disabled="busy || loading || !schema || activeUploads > 0"
:disabled="footerBusy || loading || !schema || activeUploads > 0"
@click="onSaveAndNew"
>
{{ t('backend::lang.form.create_and_new') }}
@@ -708,7 +781,7 @@ void load()
data-action="save-close"
hotkey="mod+enter"
:title="shortcutHint(t('backend::lang.form.save_and_close'), 'mod+enter')"
:disabled="busy || loading || !schema || activeUploads > 0"
:disabled="footerBusy || loading || !schema || activeUploads > 0"
@click="onSaveAndClose"
>
{{ t('backend::lang.form.save_and_close') }}
@@ -718,7 +791,7 @@ void load()
data-action="save"
hotkey="mod+s"
:title="shortcutHint(t('backend::lang.form.save'), 'mod+s')"
:disabled="busy || loading || !schema || activeUploads > 0"
:disabled="footerBusy || loading || !schema || activeUploads > 0"
@click="onSave"
>
{{ busy ? t('backend::lang.form.saving') : t('backend::lang.form.save') }}

View File

@@ -106,6 +106,8 @@ const stateLabels = computed(() => ({
deleted: message(messages.value?.rowStateDeleted),
negative: message(messages.value?.rowStateNegative),
disabled: message(messages.value?.rowStateDisabled),
customized: message(messages.value?.rowStateCustomized),
outdated: message(messages.value?.rowStateOutdated),
}))
// Declared bulk actions the admin may run (D-09), in declared order. The
// built-in delete stays the toolbar button and is not part of the menu.