Enhance row selection toggle functionality in SelectionTable to manage user selection state and improve user experience
This commit is contained in:
+29
-1
@@ -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);
|
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 (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; });
|
if (clearBtn) clearBtn.addEventListener('click', function(){ findRowCheckboxes().forEach(function(cb){ if (!cb.disabled) cb.checked = false; }); updateSelectedCount(); lastChecked = null; });
|
||||||
|
|||||||
Reference in New Issue
Block a user