(kind)
| 25 | |
| 26 | function setCombineUIRow(kind, visible) { |
| 27 | const row = document.getElementById(`${kind}-combine-row`); |
| 28 | if (row) row.hidden = !visible; |
| 29 | } |
| 30 | |
| 31 | function renderChips(kind) { |
| 32 | initState(); |
| 33 | const container = document.getElementById(`${kind}-filter-chips`); |
| 34 | if (!container) return; |
| 35 | const list = window.multiFilterChips[kind] || []; |
| 36 | container.innerHTML = ""; |
| 37 | if (list.length === 0) { |
| 38 | container.hidden = true; |
| 39 | setCombineUIRow(kind, false); |
| 40 | return; |
| 41 | } |
| 42 | container.hidden = false; |
| 43 | setCombineUIRow(kind, list.length > 1); |
| 44 | list.forEach((val) => { |
| 45 | const chip = document.createElement("span"); |
| 46 | chip.className = "filter-value-chip"; |
| 47 | chip.dataset.kind = kind; |
| 48 | chip.dataset.value = val; |
| 49 | let label = val === "__none__" ? "(empty)" : val; |
| 50 | if (kind === "filaments" && window.filamentLabelById && window.filamentLabelById[String(val)]) { |
| 51 | label = window.filamentLabelById[String(val)]; |
| 52 | } |
| 53 | chip.textContent = label; |
| 54 | const x = document.createElement("button"); |
| 55 | x.type = "button"; |
| 56 | x.className = "filter-chip-remove"; |
| 57 | x.setAttribute("aria-label", "Remove"); |
| 58 | x.textContent = "×"; |
| 59 | x.dataset.kind = kind; |
| 60 | x.dataset.value = val; |
no test coverage detected