diff --git a/admin/src/components/form/fields/PartialField.vue b/admin/src/components/form/fields/PartialField.vue index a64f0e0a..388ba9d2 100644 --- a/admin/src/components/form/fields/PartialField.vue +++ b/admin/src/components/form/fields/PartialField.vue @@ -1,14 +1,18 @@ @@ -25,6 +29,7 @@ const props = defineProps() :source="source" :name="props.field.path || props.field.name" :record-id="recordId ?? null" + :reload-key="reloadKey" /> diff --git a/admin/src/components/form/formContext.ts b/admin/src/components/form/formContext.ts index 2b9a6d62..c8286f3d 100644 --- a/admin/src/components/form/formContext.ts +++ b/admin/src/components/form/formContext.ts @@ -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>> = 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>> = Symbol('summer.form.partialReload') + /** Enabled content locales for ML controls (schema meta.enabledLocales). */ export const FORM_ENABLED_LOCALES: InjectionKey>> = Symbol('summer.form.enabledLocales') diff --git a/admin/src/components/list/DataTable.vue b/admin/src/components/list/DataTable.vue index 8870a144..d313a96e 100644 --- a/admin/src/components/list/DataTable.vue +++ b/admin/src/components/list/DataTable.vue @@ -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[] { diff --git a/admin/src/components/list/RowStateBadges.vue b/admin/src/components/list/RowStateBadges.vue index 37dd3828..f7991dee 100644 --- a/admin/src/components/list/RowStateBadges.vue +++ b/admin/src/components/list/RowStateBadges.vue @@ -15,8 +15,10 @@ const STYLES: Record = { 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))) diff --git a/admin/src/styles/main.css b/admin/src/styles/main.css index 6afcd2ca..f4f24c02 100644 --- a/admin/src/styles/main.css +++ b/admin/src/styles/main.css @@ -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) { diff --git a/admin/src/views/FormView.vue b/admin/src/views/FormView.vue index 7c6ae79b..4e8b0335 100644 --- a/admin/src/views/FormView.vue +++ b/admin/src/views/FormView.vue @@ -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({}) const permissionLocks = ref>({}) /** 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([]) +/** 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>({}) // 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 { // 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 { } } +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 { + 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 { + // 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 { if (recordId === null || busy.value || !schema.value) { return @@ -678,27 +738,40 @@ void load()