Skip to content

Commit b87d198

Browse files
committed
DAST admin: tick every rule in a class at once
Adds a select all checkbox to the header of each class on the premium curated rules page, so an administrator can tick a whole class in one click and then enable or disable the ticked rules. The per rule ticks and the enable all and disable all buttons work as before.
1 parent 0f6e2b8 commit b87d198

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎app/web/templates/dast_admin.html‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
6868
<input type="hidden" name="rule_class" value="{{ cls }}">
6969
<div class="table-scroll"><table>
70-
<thead><tr><th></th><th>Rule</th><th>Safety</th><th>Floor</th><th>State</th><th></th></tr></thead>
70+
<thead><tr><th><input type="checkbox" data-check-all aria-label="Select every rule in this class"></th><th>Rule</th><th>Safety</th><th>Floor</th><th>State</th><th></th></tr></thead>
7171
<tbody>
7272
{% for r in group.rules %}
7373
<tr>
@@ -243,6 +243,17 @@
243243

244244
<script>
245245
(function () {
246+
// A header checkbox ticks or clears every rule in its class.
247+
document.addEventListener("change", function (e) {
248+
var head = e.target;
249+
if (!head.matches || !head.matches("[data-check-all]")) { return; }
250+
var form = head.closest("form");
251+
if (!form) { return; }
252+
Array.prototype.forEach.call(
253+
form.querySelectorAll('input[name="rule_id"]'),
254+
function (cb) { cb.checked = head.checked; });
255+
});
256+
246257
// Tabs: show one pane at a time, remember it in the address.
247258
var tabs = Array.prototype.slice.call(document.querySelectorAll(".section-nav [data-tab]"));
248259
var panes = Array.prototype.slice.call(document.querySelectorAll("[data-pane]"));

0 commit comments

Comments
 (0)