Sha256: 286627c3ddc32ab0d61214e0d2a29cfef388e99db4fce0e7eb1458ba2ad47d16
Contents?: true
Size: 668 Bytes
Versions: 52
Compression:
Stored size: 668 Bytes
Contents
import { Controller } from 'stimulus' export default class extends Controller { static targets = [ "itemCheckbox", "checkbox" ] connect() { this.resourceName = this.element.dataset.resourceName } toggle(event) { var value = !!event.target.checked document.querySelectorAll(`[data-controller="item-selector"][data-resource-name="${this.resourceName}"] input[type=checkbox]`) .forEach((checkbox) => checkbox.checked != value && checkbox.click()) } update() { var allSelected = true this.itemCheckboxTargets.forEach((checkbox) => allSelected = allSelected && checkbox.checked) this.checkboxTarget.checked = allSelected } }
Version data entries
52 entries across 52 versions & 1 rubygems