diff --git a/backend/workflows/static/workflows/js/requests_dashboard.js b/backend/workflows/static/workflows/js/requests_dashboard.js index 9d37646..80f489b 100644 --- a/backend/workflows/static/workflows/js/requests_dashboard.js +++ b/backend/workflows/static/workflows/js/requests_dashboard.js @@ -32,6 +32,7 @@ const selectAll = document.getElementById('select-all'); const rowChecks = Array.from(document.querySelectorAll('.row-select')); const selectedCount = document.getElementById('selected-count'); + const bulkForm = document.getElementById('bulk-delete-form'); if (!selectAll || !selectedCount || !rowChecks.length) return; function updateCount() { @@ -41,10 +42,31 @@ selectAll.indeterminate = checked > 0 && checked < rowChecks.length; } + function syncBulkSelection() { + if (!bulkForm) return; + bulkForm.querySelectorAll('input[type="hidden"][data-bulk-selected="1"]').forEach(function (node) { + node.remove(); + }); + rowChecks.forEach(function (checkbox) { + if (!checkbox.checked) return; + const hidden = document.createElement('input'); + hidden.type = 'hidden'; + hidden.name = 'selected_requests'; + hidden.value = checkbox.value; + hidden.setAttribute('data-bulk-selected', '1'); + bulkForm.appendChild(hidden); + }); + } + selectAll.addEventListener('change', function () { rowChecks.forEach((c) => { c.checked = selectAll.checked; }); updateCount(); }); rowChecks.forEach((c) => c.addEventListener('change', updateCount)); + if (bulkForm) { + bulkForm.addEventListener('submit', function () { + syncBulkSelection(); + }); + } updateCount(); })();