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

Version Path
avo-1.22.2 app/javascript/js/controllers/item_select_all_controller.js
avo-1.22.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.22.1.pre.2 app/javascript/js/controllers/item_select_all_controller.js
avo-1.22.1.pre.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.22.0 app/javascript/js/controllers/item_select_all_controller.js
avo-1.22.0.pre.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.21.1.pre.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.21.0 app/javascript/js/controllers/item_select_all_controller.js
avo-1.20.2.pre.2 app/javascript/js/controllers/item_select_all_controller.js
avo-1.20.2.pre.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.21.0.pre.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.20.1 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.11 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.10 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.9 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.8 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.7 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.6 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.5 app/javascript/js/controllers/item_select_all_controller.js
avo-1.19.1.pre.4 app/javascript/js/controllers/item_select_all_controller.js