Skip to content

Commit 66d211d

Browse files
committed
Add Collapse all button to close all inline details without clearing inputs
- Add collapseAll() JS function that closes all <details> elements - Add "▲ Collapse all" button in controls bar next to Clear all - Does not touch checkboxes, text inputs, or column widths https://claude.ai/code/session_01Sh7FCwgc4muABUcE6XXmWK
1 parent a51d665 commit 66d211d

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

Services/HtmlReport/HtmlReportGenerateService.Js.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ private static void AppendJs(StringBuilder sb, string storageKey, string reportD
112112
sb.AppendLine(" setTimeout(function(){ URL.revokeObjectURL(a.href); }, 1000);");
113113
sb.AppendLine(" }");
114114
sb.AppendLine();
115+
sb.AppendLine(" function collapseAll() {");
116+
sb.AppendLine(" document.querySelectorAll('details[open]').forEach(function(d){ d.removeAttribute('open'); });");
117+
sb.AppendLine(" scheduleSave();");
118+
sb.AppendLine(" }");
119+
sb.AppendLine();
115120
sb.AppendLine(" function clearAll() {");
116121
sb.AppendLine(" if (!confirm('Clear all checkboxes and text inputs?')) return;");
117122
sb.AppendLine(" document.querySelectorAll('input[type=\"checkbox\"]').forEach(function(cb){ cb.checked=false; });");

Services/HtmlReportGenerateService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private string BuildHtml(
107107
sb.AppendLine("<!--CTRL-->");
108108
sb.AppendLine("<div class=\"controls\">");
109109
sb.AppendLine(" <button class=\"btn\" onclick=\"downloadReviewed()\">&#x2913; " + HtmlEncode("Download as reviewed") + "</button>");
110+
sb.AppendLine(" <button class=\"btn btn-clear\" onclick=\"collapseAll()\">&#x25B2; " + HtmlEncode("Collapse all") + "</button>");
110111
sb.AppendLine(" <button class=\"btn btn-clear\" onclick=\"clearAll()\">&#x2715; " + HtmlEncode("Clear all") + "</button>");
111112
sb.AppendLine(" <span id=\"save-status\" class=\"save-status\"></span>");
112113
sb.AppendLine("</div>");

doc/samples/diff_report.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
<!--CTRL-->
198198
<div class="controls">
199199
<button class="btn" onclick="downloadReviewed()">&#x2913; Download as reviewed</button>
200+
<button class="btn btn-clear" onclick="collapseAll()">&#x25B2; Collapse all</button>
200201
<button class="btn btn-clear" onclick="clearAll()">&#x2715; Clear all</button>
201202
<span id="save-status" class="save-status"></span>
202203
</div>
@@ -924,6 +925,11 @@ <h2 style="color:#0051c3">[ ! ] Modified Files &#x2014; Timestamps Regressed (5)
924925
setTimeout(function(){ URL.revokeObjectURL(a.href); }, 1000);
925926
}
926927

928+
function collapseAll() {
929+
document.querySelectorAll('details[open]').forEach(function(d){ d.removeAttribute('open'); });
930+
scheduleSave();
931+
}
932+
927933
function clearAll() {
928934
if (!confirm('Clear all checkboxes and text inputs?')) return;
929935
document.querySelectorAll('input[type="checkbox"]').forEach(function(cb){ cb.checked=false; });

0 commit comments

Comments
 (0)