mirror of https://github.com/itflow-org/itflow
Rename inconsistent multi Actions to Bulk Actions
This commit is contained in:
parent
f2719a612e
commit
ee3087725d
|
|
@ -0,0 +1,40 @@
|
|||
// Allow selecting and editing multiple records at once
|
||||
|
||||
var form = document.getElementById("bulkActions"); // Get the form element by its id
|
||||
var checkboxes = form.querySelectorAll('input[type="checkbox"].bulk-select'); // Select only checkboxes with class "bulk-select"
|
||||
var selectedCount = document.getElementById("selectedCount");
|
||||
var selectAllCheckbox = document.getElementById("selectAllCheckbox"); // The "select all" checkbox
|
||||
|
||||
// Event listener for each checkbox
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].addEventListener("click", updateSelectedCount);
|
||||
}
|
||||
|
||||
// Function to update the count of selected checkboxes
|
||||
function updateSelectedCount() {
|
||||
var count = 0;
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
if (checkboxes[i].checked) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
selectedCount.textContent = count; // Display the count
|
||||
|
||||
// Show or hide the multi-action button
|
||||
document.getElementById("bulkActionButton").hidden = count === 0;
|
||||
}
|
||||
|
||||
// Function to check/uncheck all checkboxes
|
||||
function checkAll(source) {
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = source.checked;
|
||||
}
|
||||
updateSelectedCount(); // Update the count after changing checkbox states
|
||||
}
|
||||
|
||||
// Event listener for the "select all" checkbox
|
||||
if (selectAllCheckbox) {
|
||||
selectAllCheckbox.addEventListener("click", function() {
|
||||
checkAll(this);
|
||||
});
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
// Allow selecting and editing multiple records at once
|
||||
|
||||
var form = document.getElementById("multi_actions"); // Get the form element by its id
|
||||
var checkboxes = form.querySelectorAll('input[type="checkbox"]');
|
||||
var selectedCount = document.getElementById("selectedCount");
|
||||
|
||||
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].addEventListener("click", updateSelectedCount);
|
||||
}
|
||||
|
||||
function updateSelectedCount() {
|
||||
var count = 0;
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
if (checkboxes[i].checked) {
|
||||
if (checkboxes[i] !== document.getElementById("selectAllCheckbox") && checkboxes[i].checked) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
selectedCount.textContent = count;
|
||||
if (count > 0) {
|
||||
document.getElementById("multiActionButton").hidden = false;
|
||||
}
|
||||
|
||||
if (count === 0) {
|
||||
document.getElementById("multiActionButton").hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function checkAll(source) {
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = source.checked;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue