This commit is contained in:
2026-01-20 21:26:15 +01:00
parent 03452ce973
commit 004af588e4
2 changed files with 12 additions and 14 deletions

View File

@@ -107,7 +107,7 @@ export function initEditor() {
} }
async function loadVersionsForCurrent() { async function loadVersionsForCurrent() {
if (!current?.id || !current?.section?.is_template) { if (!current?.id) {
renderVersionOptions([]); renderVersionOptions([]);
return; return;
} }
@@ -353,7 +353,7 @@ export function initEditor() {
window.__currentEditorCtx = { id: current.id, mode: current.section.slug, section: current.section }; window.__currentEditorCtx = { id: current.id, mode: current.section.slug, section: current.section };
setSendContext(current.section?.is_template ? current.id : 0, current.name); setSendContext(current.section?.is_template ? current.id : 0, current.name);
if (btnTest) btnTest.classList.toggle('hidden', !current.section?.is_template); if (btnTest) btnTest.classList.toggle('hidden', !current.section?.is_template);
setVersionUiVisible(!!current.section?.is_template); setVersionUiVisible(!!current.section);
    // Neuen Token erzeugen & alten Listener entfernen     // Neuen Token erzeugen & alten Listener entfernen
    reqToken++;     reqToken++;
@@ -657,7 +657,7 @@ export function initEditor() {
sendForm && (sendForm.onsubmit = doSend); sendForm && (sendForm.onsubmit = doSend);
editorSelect && (editorSelect.onchange = () => switchEditor(editorSelect.value)); editorSelect && (editorSelect.onchange = () => switchEditor(editorSelect.value));
btnRestoreVersion && (btnRestoreVersion.onclick = async () => { btnRestoreVersion && (btnRestoreVersion.onclick = async () => {
if (!current?.id || !current?.section?.is_template) return; if (!current?.id) return;
const versionId = Number(versionSelect?.value || 0); const versionId = Number(versionSelect?.value || 0);
if (!versionId) { if (!versionId) {
err('Bitte eine Version auswählen'); err('Bitte eine Version auswählen');

View File

@@ -954,19 +954,17 @@ class ApiKernel
return; return;
} }
if (!empty($section['is_template'])) { $versionCols = array_filter([$jsonCol, $htmlCol, $craftCol, $settingsCol, $editorCol]);
$versionCols = array_filter([$jsonCol, $htmlCol, $craftCol, $settingsCol, $editorCol]); $shouldSnapshot = false;
$shouldSnapshot = false; foreach ($versionCols as $col) {
foreach ($versionCols as $col) { if (array_key_exists($col, $data)) {
if (array_key_exists($col, $data)) { $shouldSnapshot = true;
$shouldSnapshot = true; break;
break;
}
}
if ($shouldSnapshot) {
$this->createContentVersion($current, $itemCols, $customerId, (int)($section['id'] ?? 0));
} }
} }
if ($shouldSnapshot) {
$this->createContentVersion($current, $itemCols, $customerId, (int)($section['id'] ?? 0));
}
$set = implode(',', array_map(static fn($c) => "`$c` = :$c", array_keys($data))); $set = implode(',', array_map(static fn($c) => "`$c` = :$c", array_keys($data)));
$data['id'] = $id; $data['id'] = $id;