This commit is contained in:
2026-01-21 01:00:50 +01:00
parent 1992502cd3
commit 107de0b7db
2 changed files with 16 additions and 7 deletions

View File

@@ -266,7 +266,7 @@ export function initEditor() {
versionItems = items || [];
if (!versionSelect) return;
const rows = Array.isArray(versionItems) ? versionItems : [];
versionSelect.innerHTML = '<option value="">Version wählen</option>';
versionSelect.innerHTML = '';
if (!rows.length) {
const opt = document.createElement('option');
opt.value = '';
@@ -277,18 +277,17 @@ export function initEditor() {
return;
}
versionSelect.disabled = false;
rows.forEach((item) => {
rows.forEach((item, idx) => {
const opt = document.createElement('option');
const label = `#${item.version_no} ${formatVersionDate(item.created_at)}`;
opt.value = String(item.id);
opt.textContent = label;
versionSelect.appendChild(opt);
});
if (lastVersionSelection) {
versionSelect.value = lastVersionSelection;
} else {
versionSelect.value = '';
if (!lastVersionSelection && idx === 0) {
lastVersionSelection = String(item.id);
}
});
if (lastVersionSelection) versionSelect.value = lastVersionSelection;
}
async function loadVersionsForCurrent() {

View File

@@ -857,6 +857,16 @@ class ApiKernel
foreach ($data as $k => $v) $stmt->bindValue(":$k", $v);
$stmt->execute();
$newId = (int)$this->pdo->lastInsertId();
try {
$stmt = $this->pdo->prepare("SELECT * FROM `$itemsTable` WHERE `id` = :id AND `customer_id` = :cid LIMIT 1");
$stmt->execute([':id' => $newId, ':cid' => $customerId]);
$row = $stmt->fetch();
if ($row) {
$this->createContentVersion($row, $itemCols, $customerId, (int)$section['id']);
}
} catch (Throwable $e) {
// ignore versioning failures on create
}
$this->respond(['ok' => true, 'kind' => 'content', 'id' => $newId, 'item' => ['id' => $newId, 'name' => $name]]);
}