Löschen/Deaktivierung
This commit is contained in:
@@ -1062,7 +1062,10 @@ export function initEditor() {
|
||||
|
||||
async function confirmTemplateReferences(actionLabel) {
|
||||
if (!current?.section?.is_template || !current?.id) return true;
|
||||
const res = await apiAction('templates.references', { method: 'GET', data: { template_id: current.id } }).catch(() => ({}));
|
||||
const res = await apiAction('templates.references', { method: 'GET', data: { template_id: current.id } }).catch(() => null);
|
||||
if (!res || res.ok === false) {
|
||||
return confirm(`Referenzen konnten nicht geprüft werden. ${actionLabel} trotzdem?`);
|
||||
}
|
||||
const refs = Array.isArray(res?.references) ? res.references : [];
|
||||
if (!refs.length) return true;
|
||||
const preview = refs.slice(0, 6).map(r => `${r.name || 'Template'} #${r.id}`).join(', ');
|
||||
|
||||
@@ -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` : '';
|
||||
|
||||
Reference in New Issue
Block a user