verison
This commit is contained in:
@@ -266,7 +266,7 @@ export function initEditor() {
|
|||||||
versionItems = items || [];
|
versionItems = items || [];
|
||||||
if (!versionSelect) return;
|
if (!versionSelect) return;
|
||||||
const rows = Array.isArray(versionItems) ? versionItems : [];
|
const rows = Array.isArray(versionItems) ? versionItems : [];
|
||||||
versionSelect.innerHTML = '<option value="">Version wählen</option>';
|
versionSelect.innerHTML = '';
|
||||||
if (!rows.length) {
|
if (!rows.length) {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = '';
|
opt.value = '';
|
||||||
@@ -277,18 +277,17 @@ export function initEditor() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
versionSelect.disabled = false;
|
versionSelect.disabled = false;
|
||||||
rows.forEach((item) => {
|
rows.forEach((item, idx) => {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
const label = `#${item.version_no} – ${formatVersionDate(item.created_at)}`;
|
const label = `#${item.version_no} – ${formatVersionDate(item.created_at)}`;
|
||||||
opt.value = String(item.id);
|
opt.value = String(item.id);
|
||||||
opt.textContent = label;
|
opt.textContent = label;
|
||||||
versionSelect.appendChild(opt);
|
versionSelect.appendChild(opt);
|
||||||
});
|
if (!lastVersionSelection && idx === 0) {
|
||||||
if (lastVersionSelection) {
|
lastVersionSelection = String(item.id);
|
||||||
versionSelect.value = lastVersionSelection;
|
|
||||||
} else {
|
|
||||||
versionSelect.value = '';
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
if (lastVersionSelection) versionSelect.value = lastVersionSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadVersionsForCurrent() {
|
async function loadVersionsForCurrent() {
|
||||||
|
|||||||
@@ -857,6 +857,16 @@ class ApiKernel
|
|||||||
foreach ($data as $k => $v) $stmt->bindValue(":$k", $v);
|
foreach ($data as $k => $v) $stmt->bindValue(":$k", $v);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$newId = (int)$this->pdo->lastInsertId();
|
$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]]);
|
$this->respond(['ok' => true, 'kind' => 'content', 'id' => $newId, 'item' => ['id' => $newId, 'name' => $name]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user