asdasd
This commit is contained in:
@@ -156,6 +156,9 @@
|
|||||||
|
|
||||||
// NEU: Generische Fetch-Funktion für jeden Ressourcentyp ('kind')
|
// NEU: Generische Fetch-Funktion für jeden Ressourcentyp ('kind')
|
||||||
B.fetchResource = (kind) => {
|
B.fetchResource = (kind) => {
|
||||||
|
if (B.USE_DYNAMIC_SECTIONS && ['templates','sections','blocks','snippets'].includes(String(kind || '').toLowerCase())) {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
if (!shouldLoad(kind)) {
|
if (!shouldLoad(kind)) {
|
||||||
log('BLOCKED', `Blockiert: ${kind} (Modus: ${B.EDITOR_MODE})`, '#708090', 'info');
|
log('BLOCKED', `Blockiert: ${kind} (Modus: ${B.EDITOR_MODE})`, '#708090', 'info');
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
@@ -183,7 +186,10 @@
|
|||||||
const loadDynamic = async () => {
|
const loadDynamic = async () => {
|
||||||
const sections = await resolveAllowedSections();
|
const sections = await resolveAllowedSections();
|
||||||
B.ALLOWED_SECTION_SLUGS = sections.map(s => String(s.slug || '').toLowerCase());
|
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 =>
|
const promises = sections.map(section =>
|
||||||
fetchData('content', 'list', { section_id: section.id })
|
fetchData('content', 'list', { section_id: section.id })
|
||||||
.then(items => (Array.isArray(items) ? items : []).map(i => ({
|
.then(items => (Array.isArray(items) ? items : []).map(i => ({
|
||||||
@@ -209,6 +215,7 @@
|
|||||||
|
|
||||||
if (filtered.length === 0) {
|
if (filtered.length === 0) {
|
||||||
log('NO DATA', 'Keine API-Daten gefunden.', 'orange', 'warn', true);
|
log('NO DATA', 'Keine API-Daten gefunden.', 'orange', 'warn', true);
|
||||||
|
bm.remove(PLACEHOLDER_ID);
|
||||||
} else {
|
} else {
|
||||||
filtered.forEach(item => {
|
filtered.forEach(item => {
|
||||||
const blockId = `lib-${item.kind}-${item.id}`;
|
const blockId = `lib-${item.kind}-${item.id}`;
|
||||||
|
|||||||
@@ -24,6 +24,27 @@ function pickDefaultSection(sections) {
|
|||||||
export async function initTabs() {
|
export async function initTabs() {
|
||||||
const nav = document.getElementById('sectionTabs');
|
const nav = document.getElementById('sectionTabs');
|
||||||
if (!nav) return;
|
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 () => {
|
const readyPromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const res = await apiAction('sections_config.list', { method: 'GET' });
|
const res = await apiAction('sections_config.list', { method: 'GET' });
|
||||||
@@ -36,18 +57,6 @@ export async function initTabs() {
|
|||||||
const active = pickDefaultSection(sections);
|
const active = pickDefaultSection(sections);
|
||||||
window.__activeSection = active;
|
window.__activeSection = active;
|
||||||
renderTabs(nav, sections, active?.id);
|
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) {
|
if (typeof window.loadList === 'function' && active) {
|
||||||
window.loadList(active);
|
window.loadList(active);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -913,8 +913,13 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Array.isArray(data.snippets) && data.snippets.length) applySnips(data.snippets);
|
if (Array.isArray(data.snippets) && data.snippets.length) {
|
||||||
else (B.fetchSnippets ? B.fetchSnippets() : Promise.resolve([])).then(applySnips);
|
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))) {
|
if (data.ref && (Array.isArray(data.ref.sections) || Array.isArray(data.ref.blocks))) {
|
||||||
replaceReferenceLibrary(ed, {
|
replaceReferenceLibrary(ed, {
|
||||||
|
|||||||
Reference in New Issue
Block a user