fix: subcategories collapsed by default in contraband
This commit is contained in:
parent
3224bb46fa
commit
2b0f76aa1f
1 changed files with 9 additions and 4 deletions
|
|
@ -115,15 +115,15 @@
|
|||
if (sub.entries.length === 0 && sub.notes.length === 0) continue;
|
||||
|
||||
html += `<div class="crt-subcategory" data-sub-idx="${i}">`;
|
||||
html += `<div class="crt-sub-header" data-toggle="${i}">
|
||||
<span class="crt-sub-toggle">▾</span>
|
||||
html += `<div class="crt-sub-header collapsed" data-toggle="${i}">
|
||||
<span class="crt-sub-toggle">▸</span>
|
||||
<span class="crt-sub-name">${esc(sub.name)}</span>
|
||||
<span class="crt-sub-count">${sub.entries.length} items</span>
|
||||
</div>`;
|
||||
|
||||
// Notes
|
||||
if (sub.notes && sub.notes.length > 0) {
|
||||
html += `<div class="crt-sub-notes">`;
|
||||
html += `<div class="crt-sub-notes" style="display:none" id="crtNotes${i}">`;
|
||||
for (const note of sub.notes) {
|
||||
html += `⚠ ${esc(note)}<br>`;
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@
|
|||
}
|
||||
|
||||
// Entries
|
||||
html += `<div class="crt-entries" id="crtEntries${i}">`;
|
||||
html += `<div class="crt-entries" id="crtEntries${i}" style="display:none">`;
|
||||
for (const entry of sub.entries) {
|
||||
html += renderEntry(entry);
|
||||
}
|
||||
|
|
@ -257,12 +257,17 @@
|
|||
const entries = document.getElementById(`crtEntries${idx}`);
|
||||
if (!entries) return;
|
||||
const isCollapsed = header.classList.contains('collapsed');
|
||||
const notes = document.getElementById(`crtNotes${idx}`);
|
||||
if (isCollapsed) {
|
||||
header.classList.remove('collapsed');
|
||||
entries.style.display = '';
|
||||
if (notes) notes.style.display = '';
|
||||
header.querySelector('.crt-sub-toggle').textContent = '▾';
|
||||
} else {
|
||||
header.classList.add('collapsed');
|
||||
entries.style.display = 'none';
|
||||
if (notes) notes.style.display = 'none';
|
||||
header.querySelector('.crt-sub-toggle').textContent = '▸';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue