asdasd
This commit is contained in:
@@ -71,6 +71,10 @@ async function openTemplateManager(item, section) {
|
||||
const btnSave = document.getElementById('manageTemplateSave');
|
||||
const btnDelete = document.getElementById('manageTemplateDelete');
|
||||
const deleteHint = document.getElementById('manage_tpl_delete_hint');
|
||||
const delDlg = document.getElementById('deleteDialog');
|
||||
const delText = document.getElementById('deleteText');
|
||||
const delForm = document.getElementById('deleteForm');
|
||||
const delCancel = document.getElementById('deleteCancel');
|
||||
|
||||
const detail = await fetchContentItem(item.id, section.id).catch(() => ({}));
|
||||
const row = detail?.item || detail?.data || detail || {};
|
||||
@@ -163,11 +167,31 @@ async function openTemplateManager(item, section) {
|
||||
|
||||
const onDeleteItem = async () => {
|
||||
if (activeId) return;
|
||||
if (!confirm('Template wirklich löschen?')) return;
|
||||
const res = await apiAction('content.delete', { method: 'POST', data: { id: item.id, section_id: section.id } });
|
||||
toast(res && res.ok ? 'Gelöscht' : 'Löschen fehlgeschlagen', !!(res && res.ok), { duration: 3000 });
|
||||
dlg && dlg.close();
|
||||
if (typeof window.loadList === 'function') window.loadList(section);
|
||||
if (!delDlg || !delForm) {
|
||||
const res = await apiAction('content.delete', { method: 'POST', data: { id: item.id, section_id: section.id } });
|
||||
toast(res && res.ok ? 'Gelöscht' : 'Löschen fehlgeschlagen', !!(res && res.ok), { duration: 3000 });
|
||||
dlg && dlg.close();
|
||||
if (typeof window.loadList === 'function') window.loadList(section);
|
||||
return;
|
||||
}
|
||||
if (delText) {
|
||||
delText.innerHTML = `Soll <strong>${item.name || '(ohne Name)'} #${item.id}</strong> wirklich gelöscht werden?`;
|
||||
}
|
||||
const cleanupDelete = () => {
|
||||
delForm.onsubmit = null;
|
||||
if (delCancel) delCancel.onclick = null;
|
||||
};
|
||||
if (delCancel) delCancel.onclick = () => { delDlg.close(); cleanupDelete(); };
|
||||
delForm.onsubmit = async (ev) => {
|
||||
ev.preventDefault();
|
||||
const res = await apiAction('content.delete', { method: 'POST', data: { id: item.id, section_id: section.id } });
|
||||
delDlg.close();
|
||||
cleanupDelete();
|
||||
toast(res && res.ok ? 'Gelöscht' : 'Löschen fehlgeschlagen', !!(res && res.ok), { duration: 3000 });
|
||||
dlg && dlg.close();
|
||||
if (typeof window.loadList === 'function') window.loadList(section);
|
||||
};
|
||||
delDlg.showModal();
|
||||
};
|
||||
|
||||
const onVersionsClick = async (ev) => {
|
||||
|
||||
Reference in New Issue
Block a user