From 06dddedef6068b2fd1e43b1b461d167f3dd30139 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Tue, 20 Jan 2026 02:02:20 +0100 Subject: [PATCH] asdasd --- public/assets/js/bridge/library-api.js | 9 ++++++- public/assets/js/ui-tabs.js | 33 ++++++++++++++++---------- public/editor/bridge-core.js | 9 +++++-- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/public/assets/js/bridge/library-api.js b/public/assets/js/bridge/library-api.js index 60076b1..4353fca 100644 --- a/public/assets/js/bridge/library-api.js +++ b/public/assets/js/bridge/library-api.js @@ -156,6 +156,9 @@ // NEU: Generische Fetch-Funktion für jeden Ressourcentyp ('kind')     B.fetchResource = (kind) => { +        if (B.USE_DYNAMIC_SECTIONS && ['templates','sections','blocks','snippets'].includes(String(kind || '').toLowerCase())) { +            return Promise.resolve([]); +        }         if (!shouldLoad(kind)) {             log('BLOCKED', `Blockiert: ${kind} (Modus: ${B.EDITOR_MODE})`, '#708090', 'info');             return Promise.resolve([]); @@ -183,7 +186,10 @@ const loadDynamic = async () => { const sections = await resolveAllowedSections(); B.ALLOWED_SECTION_SLUGS = sections.map(s => String(s.slug || '').toLowerCase()); - if (!sections.length) return []; + if (!sections.length) { + bm.remove(PLACEHOLDER_ID); + return []; + } const promises = sections.map(section => fetchData('content', 'list', { section_id: section.id }) .then(items => (Array.isArray(items) ? items : []).map(i => ({ @@ -209,6 +215,7 @@   if (filtered.length === 0) { log('NO DATA', 'Keine API-Daten gefunden.', 'orange', 'warn', true); + bm.remove(PLACEHOLDER_ID); } else { filtered.forEach(item => { const blockId = `lib-${item.kind}-${item.id}`; diff --git a/public/assets/js/ui-tabs.js b/public/assets/js/ui-tabs.js index 839a85f..904c332 100644 --- a/public/assets/js/ui-tabs.js +++ b/public/assets/js/ui-tabs.js @@ -24,6 +24,27 @@ function pickDefaultSection(sections) { export async function initTabs() { const nav = document.getElementById('sectionTabs'); if (!nav) return; + + const setActive = (sections, id) => { + const next = sections.find(s => Number(s.id) === Number(id)); + if (!next) return; + window.__activeSection = next; + renderTabs(nav, sections, next.id); + if (typeof window.loadList === 'function') { + window.loadList(next); + } + }; + + nav.addEventListener('click', (ev) => { + const btn = ev.target?.closest?.('button[data-section-id]'); + if (!btn) return; + const sections = window.__sectionsConfig || []; + if (!sections.length) return; + const id = Number(btn.dataset.sectionId || 0); + if (!id) return; + setActive(sections, id); + }); + const readyPromise = (async () => { try { const res = await apiAction('sections_config.list', { method: 'GET' }); @@ -36,18 +57,6 @@ export async function initTabs() { const active = pickDefaultSection(sections); window.__activeSection = active; renderTabs(nav, sections, active?.id); - nav.querySelectorAll('button[data-section-id]').forEach(btn => { - btn.addEventListener('click', () => { - const id = Number(btn.dataset.sectionId || 0); - const next = sections.find(s => Number(s.id) === id); - if (!next) return; - window.__activeSection = next; - renderTabs(nav, sections, next.id); - if (typeof window.loadList === 'function') { - window.loadList(next); - } - }); - }); if (typeof window.loadList === 'function' && active) { window.loadList(active); } diff --git a/public/editor/bridge-core.js b/public/editor/bridge-core.js index daaf4d6..94e3820 100644 --- a/public/editor/bridge-core.js +++ b/public/editor/bridge-core.js @@ -913,8 +913,13 @@                 }; -                if (Array.isArray(data.snippets) && data.snippets.length) applySnips(data.snippets); -                else (B.fetchSnippets ? B.fetchSnippets() : Promise.resolve([])).then(applySnips); +                if (Array.isArray(data.snippets) && data.snippets.length) { +                    applySnips(data.snippets); +                } else if (B.USE_DYNAMIC_SECTIONS) { +                    applySnips([]); +                } else { +                    (B.fetchSnippets ? B.fetchSnippets() : Promise.resolve([])).then(applySnips); +                }                 if (data.ref && (Array.isArray(data.ref.sections) || Array.isArray(data.ref.blocks))) {                     replaceReferenceLibrary(ed, {