asdasd
This commit is contained in:
@@ -68,7 +68,6 @@ async function openTemplateManager(item, section) {
|
||||
const badge = document.getElementById('manage_tpl_badge');
|
||||
const versionsWrap = document.getElementById('manage_tpl_versions');
|
||||
const btnClose = document.getElementById('manageTemplateClose');
|
||||
const btnSave = document.getElementById('manageTemplateSave');
|
||||
const btnDelete = document.getElementById('manageTemplateDelete');
|
||||
const deleteHint = document.getElementById('manage_tpl_delete_hint');
|
||||
const delDlg = document.getElementById('deleteDialog');
|
||||
@@ -140,15 +139,8 @@ async function openTemplateManager(item, section) {
|
||||
}
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
inpApiName && inpApiName.removeEventListener('input', onApiInput);
|
||||
versionsWrap && versionsWrap.removeEventListener('click', onVersionsClick);
|
||||
if (btnClose) btnClose.onclick = null;
|
||||
if (btnSave) btnSave.onclick = null;
|
||||
if (btnDelete) btnDelete.onclick = null;
|
||||
};
|
||||
|
||||
const onSave = async () => {
|
||||
let autoSaveTimer = null;
|
||||
const autoSave = async () => {
|
||||
try {
|
||||
const payload = {
|
||||
name: inpName ? inpName.value : '',
|
||||
@@ -158,12 +150,29 @@ async function openTemplateManager(item, section) {
|
||||
payload.api_name = inpApiName ? inpApiName.value : '';
|
||||
}
|
||||
const res = await apiUpdate('content', item.id, payload);
|
||||
toast(res && res.ok ? 'Gespeichert' : 'Speichern fehlgeschlagen', !!(res && res.ok));
|
||||
if (res?.ok && typeof window.loadList === 'function') window.loadList(section);
|
||||
if (!res?.ok) toast(res?.error || 'Speichern fehlgeschlagen', false);
|
||||
} catch {
|
||||
toast('Speichern fehlgeschlagen', false);
|
||||
}
|
||||
};
|
||||
const scheduleAutoSave = () => {
|
||||
if (autoSaveTimer) clearTimeout(autoSaveTimer);
|
||||
autoSaveTimer = setTimeout(autoSave, 450);
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
inpApiName && inpApiName.removeEventListener('input', onApiInput);
|
||||
inpName && inpName.removeEventListener('input', scheduleAutoSave);
|
||||
inpApiName && inpApiName.removeEventListener('input', scheduleAutoSave);
|
||||
versionsWrap && versionsWrap.removeEventListener('click', onVersionsClick);
|
||||
if (btnClose) btnClose.onclick = null;
|
||||
if (btnDelete) btnDelete.onclick = null;
|
||||
if (autoSaveTimer) {
|
||||
clearTimeout(autoSaveTimer);
|
||||
autoSaveTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const onDeleteItem = async () => {
|
||||
if (activeId) return;
|
||||
@@ -230,8 +239,9 @@ async function openTemplateManager(item, section) {
|
||||
};
|
||||
|
||||
inpApiName && inpApiName.addEventListener('input', onApiInput);
|
||||
inpName && inpName.addEventListener('input', scheduleAutoSave);
|
||||
inpApiName && inpApiName.addEventListener('input', scheduleAutoSave);
|
||||
btnClose && (btnClose.onclick = () => { dlg && dlg.close(); cleanup(); });
|
||||
btnSave && (btnSave.onclick = onSave);
|
||||
btnDelete && (btnDelete.onclick = onDeleteItem);
|
||||
versionsWrap && versionsWrap.addEventListener('click', onVersionsClick);
|
||||
|
||||
|
||||
@@ -169,7 +169,6 @@ require __DIR__ . '/../partials/structure/layout_start.php';
|
||||
<span id="manage_tpl_badge" class="text-xs px-2 py-1 rounded-full bg-slate-100 text-slate-600">ID –</span>
|
||||
<div class="ms-auto flex gap-2">
|
||||
<button type="button" id="manageTemplateClose" class="btn">Schließen</button>
|
||||
<button type="button" id="manageTemplateSave" class="btn">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
|
||||
Reference in New Issue
Block a user