MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / renderChips

Function renderChips

query-builder.js:27–57  ·  view source on GitHub ↗
(kind)

Source from the content-addressed store, hash-verified

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;

Callers 6

addChipFunction · 0.85
removeChipFunction · 0.85
clearChipsKindFunction · 0.85
wireMultiFilterUIFunction · 0.85
clearSidebarFilterKindsFunction · 0.85
setTagMultiFilterFunction · 0.85

Calls 2

initStateFunction · 0.85
setCombineUIRowFunction · 0.85

Tested by

no test coverage detected