mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
20 lines
407 B
JavaScript
20 lines
407 B
JavaScript
import { Controller } from "stimulus";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["all", "checkbox"];
|
|
|
|
connect() {
|
|
this.toggleCheckbox()
|
|
}
|
|
|
|
toggleAll() {
|
|
this.checkboxTargets.forEach(checkbox => {
|
|
checkbox.checked = this.allTarget.checked;
|
|
});
|
|
}
|
|
|
|
toggleCheckbox() {
|
|
this.allTarget.checked = this.checkboxTargets.every(checkbox => checkbox.checked);
|
|
}
|
|
}
|