mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Rename select-all-controller
This commit is contained in:
19
app/webpacker/controllers/checked_controller.js
Normal file
19
app/webpacker/controllers/checked_controller.js
Normal file
@@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user