Sha256: dc413924a728bd6602ba83c6c54a4bd485b1c18f78d8b96866f05764e214be20

Contents?: true

Size: 1003 Bytes

Versions: 36

Compression:

Stored size: 1003 Bytes

Contents

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {

  static targets = ['condition', 'category']

  filterConditions(event) {
    const query = event.currentTarget.value.toLowerCase()
    const visibleCategories = new Set()

    // hide / show condition links that match the query and note which
    // categories should be visible
    this.conditionTargets.forEach(conditionNode => {
      const conditionName = conditionNode.innerHTML.toLowerCase()
      if (conditionName.includes(query)) {
        conditionNode.hidden = false
        visibleCategories.add(conditionNode.dataset.category)
      } else {
        conditionNode.hidden = true
      }
    })

    // hide / show category headers that have
    this.categoryTargets.forEach(categoryNode => {
      const categoryName = categoryNode.innerHTML
      if (visibleCategories.has(categoryName)) {
        categoryNode.hidden = false
      } else {
        categoryNode.hidden = true
      }
    })
  }
}

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
refine-rails-2.13.3 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.13.2 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.13.1 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.13.0 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.12.2 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.12.1 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.12.0 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.12 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.11 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.10 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.9 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.8 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.6 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.5 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.4 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.3 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.2 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.1 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.11.0 app/javascript/controllers/refine/inline-conditions-controller.js
refine-rails-2.10.1 app/javascript/controllers/refine/inline-conditions-controller.js