Add buttons for toggle on and off

This commit is contained in:
Jorge Manrubia
2025-09-17 18:08:26 +02:00
parent e34eee8237
commit 515fb72d54
3 changed files with 19 additions and 1 deletions
@@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static classes = [ "toggle" ]
static targets = [ "checkbox" ]
toggle() {
this.element.classList.toggle(this.toggleClass)
@@ -14,4 +15,16 @@ export default class extends Controller {
remove() {
this.element.classList.remove(this.toggleClass)
}
checkAll() {
this.checkboxTargets.forEach(checkbox => {
checkbox.checked = true
})
}
checkNone() {
this.checkboxTargets.forEach(checkbox => {
checkbox.checked = false
})
}
}