Löschen/Deaktivierung

This commit is contained in:
2026-02-01 01:34:05 +01:00
parent 1709ae6551
commit 57dc40fd46
4 changed files with 145 additions and 30 deletions

View File

@@ -89,14 +89,18 @@ async function openTemplateManager(item, section) {
let activeId = 0;
const fetchTemplateReferences = async () => {
if (!section?.is_template) return [];
const res = await apiAction('templates.references', { method: 'GET', data: { template_id: item.id } }).catch(() => ({}));
if (!section?.is_template) return null;
const res = await apiAction('templates.references', { method: 'GET', data: { template_id: item.id } }).catch(() => null);
if (!res || res.ok === false) return null;
return Array.isArray(res?.references) ? res.references : [];
};
const confirmTemplateReferences = async (actionLabel) => {
if (!section?.is_template) return true;
const refs = await fetchTemplateReferences();
if (refs === null) {
return confirm(`Referenzen konnten nicht geprüft werden. ${actionLabel} trotzdem?`);
}
if (!refs.length) return true;
const preview = refs.slice(0, 6).map(r => `${r.name || 'Template'} #${r.id}`).join(', ');
const more = refs.length > 6 ? ` und ${refs.length - 6} weitere` : '';