This commit is contained in:
2026-01-20 02:02:20 +01:00
parent 8e6248cea1
commit 06dddedef6
3 changed files with 36 additions and 15 deletions

View File

@@ -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}`;

View File

@@ -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);
}

View File

@@ -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, {