From 223d198c95b64d3d803be5d914c5b899dd30c8eb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 13 Jul 2026 19:59:34 -0400 Subject: refactor(admin): simplify css and js of card collapsing and side bar directories --- internal/admin/static/moduleeditor.js | 60 ++++++++++++++++------------------- 1 file changed, 28 insertions(+), 32 deletions(-) (limited to 'internal/admin/static/moduleeditor.js') diff --git a/internal/admin/static/moduleeditor.js b/internal/admin/static/moduleeditor.js index b2eb79f..ff9d8a4 100644 --- a/internal/admin/static/moduleeditor.js +++ b/internal/admin/static/moduleeditor.js @@ -106,6 +106,9 @@ function renderModuleEditor(id, data) { html += ''; $('#editorMain').innerHTML = html; + document.querySelectorAll('details.obj-card').forEach(function(d) { + d.addEventListener('toggle', function() { expandedCards[d.getAttribute('data-card')] = d.open; }); + }); setupSearchFields(); } @@ -116,43 +119,41 @@ function renderCurrent() { } function renderCard(sec, data) { - var collapsed = expandedCards[sec.id] === false; + var openAttr = expandedCards[sec.id] === false ? '' : ' open'; var isFull = cardWidths[sec.id] !== undefined ? cardWidths[sec.id] : (sec.fullWidth || false); var fullClass = isFull ? ' obj-card-full' : ''; - var h = '
'; - h += '
'; - h += '' + (collapsed ? '▶' : '▼') + ''; + var h = '
'; + h += ''; + h += ''; h += '' + sec.label + ''; - h += ''; + h += ''; if (!sec.always) { - h += ''; + h += ''; } - h += '
'; - if (!collapsed) { - h += '
'; + h += ''; + h += '
'; - if (sec.isArray) { - h += renderArraySection(sec, data); - } else { - h += '
'; - sec.fields.forEach(function(f) { - h += renderField(sec, f, data, -1); + if (sec.isArray) { + h += renderArraySection(sec, data); + } else { + h += '
'; + sec.fields.forEach(function(f) { + h += renderField(sec, f, data, -1); + }); + h += '
'; + + if (sec.inline) { + sec.inline.forEach(function(il) { + if (il.type === 'kv') { + h += ced_renderKV(sec, il, data); + } else if (il.type === 'kv_search') { + h += ced_renderKVSearch(sec, il, data); + } }); - h += '
'; - - if (sec.inline) { - sec.inline.forEach(function(il) { - if (il.type === 'kv') { - h += ced_renderKV(sec, il, data); - } else if (il.type === 'kv_search') { - h += ced_renderKVSearch(sec, il, data); - } - }); - } } - h += '
'; } h += '
'; + h += ''; return h; } @@ -177,11 +178,6 @@ function renderField(sec, f, data, idx) { return ced_renderField(sec, f, data, idx, null, null, cardPath, fieldID, getVal); } -function toggleCard(id) { - expandedCards[id] = expandedCards[id] === false ? true : false; - renderCurrent(); -} - function toggleCardWidth(id) { cardWidths[id] = !cardWidths[id]; renderCurrent(); -- cgit v1.2.3