Enhance row selection toggle functionality in SelectionTable to manage user selection state and improve user experience

This commit is contained in:
Ross
2026-03-25 22:10:15 +00:00
parent d4f0c05341
commit 2d48a6bad6
+29 -1
View File
@@ -161,7 +161,35 @@ class SelectionTable(tables.Table):
table.addEventListener('change', function(e){ if (e.target && e.target.matches && e.target.matches('input[type="checkbox"]')) updateSelectedCount(); }, true);
toggleBtn.addEventListener('click', function(){ selectionEnabled = !selectionEnabled; if (selectionEnabled){ toggleBtn.textContent = 'Disable row selection'; if (controlsEl) controlsEl.style.display = ''; setCheckboxesDisabled(false); showSelectionColumn(); } else { toggleBtn.textContent = 'Enable row selection'; if (controlsEl) controlsEl.style.display = 'none'; setCheckboxesDisabled(true); hideSelectionColumn(); findRowCheckboxes().forEach(function(cb){ cb.checked = false; }); updateSelectedCount(); lastChecked = null; } });
toggleBtn.addEventListener('click', function(){
selectionEnabled = !selectionEnabled;
if (selectionEnabled){
toggleBtn.textContent = 'Disable row selection';
if (controlsEl) controlsEl.style.display = '';
setCheckboxesDisabled(false);
showSelectionColumn();
try {
table.style.userSelect = 'none';
table.style.webkitUserSelect = 'none';
table.style.MozUserSelect = 'none';
table.classList && table.classList.add('selection-mode');
} catch (e) {}
} else {
toggleBtn.textContent = 'Enable row selection';
if (controlsEl) controlsEl.style.display = 'none';
setCheckboxesDisabled(true);
hideSelectionColumn();
findRowCheckboxes().forEach(function(cb){ cb.checked = false; });
updateSelectedCount();
lastChecked = null;
try {
table.style.userSelect = '';
table.style.webkitUserSelect = '';
table.style.MozUserSelect = '';
table.classList && table.classList.remove('selection-mode');
} catch (e) {}
}
});
if (selectAllBtn) selectAllBtn.addEventListener('click', function(){ findRowCheckboxes().forEach(function(cb){ if (!cb.disabled) cb.checked = true; }); updateSelectedCount(); lastChecked = null; });
if (clearBtn) clearBtn.addEventListener('click', function(){ findRowCheckboxes().forEach(function(cb){ if (!cb.disabled) cb.checked = false; }); updateSelectedCount(); lastChecked = null; });