From 591ebf1276baf22324cc96bf646d1b8a82e87238 Mon Sep 17 00:00:00 2001 From: colorlink Date: Fri, 16 Oct 2026 04:01:02 +0000 Subject: [PATCH] Admin UI: collapse PER GROUP (category) with arrow, groups minimized by default; drop per-tool minimize Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg --- assets/js/admin.js | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/assets/js/admin.js b/assets/js/admin.js index c1a5d83..ff78c69 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -26,7 +26,7 @@ function updateCards(form){ }); } -/* ---- Categories (collapsible) + per-tool expand arrow (cards minimized by default) ---- */ +/* ---- Collapse PER GROUP (category). Each group has an arrow; groups minimized by default. ---- */ var LSKEY='asktamMcpCatCollapsed'; function loadState(){try{return JSON.parse(localStorage.getItem(LSKEY)||'{}')||{};}catch(e){return {};}} function saveState(m){try{localStorage.setItem(LSKEY,JSON.stringify(m));}catch(e){}} @@ -44,15 +44,8 @@ function initCollapsibleTools(){ }); saveState(state); } - function setAllCards(min){ - form.querySelectorAll('.asktam-mcp-tool-card').forEach(function(card){ - card.classList.toggle('is-min',min); - var b=card.querySelector('.asktam-mcp-card-min'); - if(b){b.textContent=min?'▸':'▾';b.setAttribute('aria-label',min?'Expand tool':'Minimize tool');} - }); - } - // Global controls: category expand/collapse + expand/minimize every tool card + // Global controls: expand / collapse every group at once var bulk=form.querySelector('.asktam-mcp-bulk-actions'); if(bulk && !bulk.querySelector('.asktam-mcp-collapse-tools')){ var wrap=document.createElement('span'); @@ -62,9 +55,8 @@ function initCollapsibleTools(){ wrap.appendChild(exp);wrap.appendChild(col); var save=bulk.querySelector('.asktam-mcp-bulk-save'); if(save)bulk.insertBefore(wrap,save);else bulk.appendChild(wrap); - // Expand all = open every category AND open every tool card; Collapse all = reverse - exp.addEventListener('click',function(){setAll(false);setAllCards(false);}); - col.addEventListener('click',function(){setAll(false);setAllCards(true);}); + exp.addEventListener('click',function(){setAll(false);}); + col.addEventListener('click',function(){setAll(true);}); } cats.forEach(function(cat){ @@ -74,14 +66,15 @@ function initCollapsibleTools(){ var caret=document.createElement('span'); caret.className='asktam-mcp-cat-caret'; caret.setAttribute('aria-hidden','true'); - caret.textContent='▾'; + caret.textContent='▾'; // ▾ ; rotates to ▸ when the group is collapsed (CSS) header.insertBefore(caret,header.firstChild); } - // Categories default EXPANDED so the full tool list is visible. - var collapsed=(id in state)?!!state[id]:false; + // Each GROUP minimized (collapsed) by default; click the header to expand it. + var collapsed=(id in state)?!!state[id]:true; cat.classList.toggle('is-collapsed',collapsed); if(header && !header.dataset.collBound){ header.dataset.collBound='1'; + header.style.cursor='pointer'; header.addEventListener('click',function(e){ if(e.target.closest('.asktam-mcp-category-actions'))return; // let All/None work var now=!cat.classList.contains('is-collapsed'); @@ -90,24 +83,6 @@ function initCollapsibleTools(){ }); } }); - - // Per-tool arrow — each tool MINIMIZED by default (shows just the name). Arrow expands it. - form.querySelectorAll('.asktam-mcp-tool-card').forEach(function(card){ - if(card.querySelector('.asktam-mcp-card-min'))return; - card.classList.add('is-min'); - var b=document.createElement('button'); - b.type='button'; - b.className='asktam-mcp-card-min'; - b.setAttribute('aria-label','Expand tool'); - b.textContent='▸'; // right-pointing arrow = minimized - b.addEventListener('click',function(e){ - e.preventDefault();e.stopPropagation(); // don't toggle the tool's checkbox - var min=card.classList.toggle('is-min'); - b.textContent=min?'▸':'▾'; // ▸ minimized / ▾ expanded - b.setAttribute('aria-label',min?'Expand tool':'Minimize tool'); - }); - card.appendChild(b); - }); } function initFooter(){