Enhance bulk selection functionality in exam index template with visual cues and row click toggling

This commit is contained in:
Ross
2025-11-06 22:03:48 +00:00
parent ebad9c6bd9
commit 8f2ca66bbb
+22 -1
View File
@@ -53,9 +53,14 @@
#exam-list-wrapper input.exam-select-checkbox { display: none; }
#exam-list-wrapper.bulk-mode input.exam-select-checkbox { display: inline-block; }
/* Show bulk controls area only when not d-none (toggled by JS) */
/* Show bulk controls area only when not d-none (toggled by JS) */
/* Visual affordances when bulk-mode is active */
#exam-list-wrapper.bulk-mode .mb-2 { cursor: pointer; }
#exam-list-wrapper .mb-2.selected { background-color: rgba(0,123,255,0.06); }
/* Defensive: hide bulk-controls unless bulk-mode is enabled */
#exam-list-wrapper:not(.bulk-mode) #bulk-controls { display: none !important; }
</style>
{% endblock css %}
@@ -91,6 +96,22 @@
}
});
}
// Make clicking an exam row toggle its checkbox when bulk-mode is enabled.
document.addEventListener('click', function(e){
if(!examListWrapper.classList.contains('bulk-mode')) return;
// find the closest exam container (id like exam-<pk>)
const examItem = e.target.closest('[id^="exam-"]');
if(!examItem || !examListWrapper.contains(examItem)) return;
// don't toggle when clicking interactive controls
if(e.target.closest('a, button, input, label, form')) return;
const cb = examItem.querySelector('input.exam-select-checkbox');
if(cb){
cb.checked = !cb.checked;
examItem.classList.toggle('selected', cb.checked);
}
});
});
</script>
{% endblock %}