fix: main-html-script syntax (tree toggle)

This commit is contained in:
2026-03-01 20:40:16 +10:00
parent c3976108a9
commit 0a96b4581c
+6 -3
View File
@@ -2970,7 +2970,7 @@ function toggleAddAgentChannel(ch){
if(gT) gT.style.display = (ch==='telegram')?'block':'none'; if(gT) gT.style.display = (ch==='telegram')?'block':'none';
if(gD) gD.style.display = (ch==='discord')?'block':'none'; if(gD) gD.style.display = (ch==='discord')?'block':'none';
} }
function buildAddSubForm(function buildAddSubForm() { function buildAddSubForm() {
const cfg = S.agents || []; const cfg = S.agents || [];
// Parent agent dropdown (all agents as potential parent for grouping) // Parent agent dropdown (all agents as potential parent for grouping)
let parentOpts = ''; let parentOpts = '';
@@ -3219,7 +3219,7 @@ function renderAgents() {
if (children.length) { if (children.length) {
const treeId = 'tree-' + root.id; const treeId = 'tree-' + root.id;
html += '<div class="tree-children-wrap">'; html += '<div class="tree-children-wrap">';
html += '<button class="tree-toggle" onclick="toggleTree('' + treeId + '',this)" title="Expand / Collapse"></button>'; html += '<button class="tree-toggle" data-tree="' + treeId + '" title="Expand / Collapse"></button>';
html += '<div class="tree-children" id="' + treeId + '">'; html += '<div class="tree-children" id="' + treeId + '">';
children.forEach(c => { html += agentCard(c, false); }); children.forEach(c => { html += agentCard(c, false); });
html += '</div></div>'; html += '</div></div>';
@@ -3230,6 +3230,9 @@ function renderAgents() {
el.innerHTML = html; el.innerHTML = html;
el.onclick = function(ev) { el.onclick = function(ev) {
const tbtn = ev.target.closest('.tree-toggle');
if (tbtn && tbtn.dataset.tree) { toggleTree(tbtn.dataset.tree, tbtn); return; }
const btn = ev.target.closest('[data-action]'); const btn = ev.target.closest('[data-action]');
if (!btn) return; if (!btn) return;
const action = btn.dataset.action; const action = btn.dataset.action;
@@ -3240,7 +3243,7 @@ function renderAgents() {
}; };
} }
function toggleTreeunction toggleTree(treeId, btn) { function toggleTree(treeId, btn) {
const el = document.getElementById(treeId); const el = document.getElementById(treeId);
if (!el) return; if (!el) return;
el.classList.toggle('collapsed'); el.classList.toggle('collapsed');