1import {Controller} from '@hotwired/stimulus' 2 3export default class extends Controller { 4 refresh() { 5 const filters = this.buildFilters() 6 this.showAllRows() 7 this.hideRows(filters) 8 } 9 10 showAllRows() { 11 for (const jobRow of this.element.querySelectorAll('.job')) { 12 jobRow.style.display = null 13 } 14 } 15 16 hideRows(filters) { 17 for (const jobRow of this.element.querySelectorAll('.job')) { 18 for (const dataAttribute of Object.keys(filters)) { 19 const dataAttributesArray = JSON.parse(jobRow.attributes[`data-${dataAttribute}`].value) 20 if (dataAttributesArray.indexOf(filters[dataAttribute]) === -1) { 21 jobRow.style.display = 'none' 22 } 23 } 24 } 25 } 26 27 buildFilters() { 28 const filters = {} 29 for (const filter of this.element.querySelectorAll('.job-select-filter')) { 30 const key = filter.dataset.filter 31 const selectedItem = Array.from(filter.options).find((option) => option.selected) 32 if (selectedItem) { 33 const value = selectedItem.value 34 if (value !== '') { 35 filters[key] = value 36 } 37 } 38 } 39 return filters 40 } 41}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.