mirror of
https://github.com/LinkStackOrg/LinkStack.git
synced 2025-02-15 11:31:00 +01:00
Implement shift-click selection for checkboxes in user panel
This commit is contained in:
parent
d95e0e6033
commit
9b0f884393
@ -208,5 +208,35 @@
|
||||
Livewire.dispatch('refresh');
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('table-loaded', () => {
|
||||
setTimeout(() => {
|
||||
const checkboxes = document.querySelectorAll('.form-check-input');
|
||||
let lastChecked;
|
||||
|
||||
function handleShiftSelect(e) {
|
||||
let inBetween = false;
|
||||
|
||||
if (e.shiftKey && this.checked) {
|
||||
checkboxes.forEach(checkbox => {
|
||||
if (checkbox === this || checkbox === lastChecked) {
|
||||
inBetween = !inBetween;
|
||||
}
|
||||
if (inBetween || checkbox === this || checkbox === lastChecked) {
|
||||
checkbox.checked = true;
|
||||
checkbox.dispatchEvent(new Event('change'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
lastChecked = this;
|
||||
}
|
||||
|
||||
checkboxes.forEach(checkbox =>
|
||||
checkbox.addEventListener('click', handleShiftSelect)
|
||||
);
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user