// The problems in the corner (D11, §6.6 of DESIGN_M1.md): every diagnostic the // state payload carries, each with whatever says where it is (M1-UI-012, // M1-UI-013). // // Like legend.js, it builds elements and leaves placing them to app.js. // Where a diagnostic is, from whichever of its locations it has. Zero is a // row, transaction or posting like any other, so absence is only ever null. export function where(d) { const parts = []; if (d.file) parts.push(d.row === null ? d.file : `${d.file}:${d.row}`); if (d.journal) parts.push(`↔ ${d.journal}`); if (d.key) parts.push(`[${d.key}]`); if (d.transaction !== null) { parts.push(d.posting === null ? `transaction ${d.transaction}` : `transaction ${d.transaction} posting ${d.posting}`); } return parts.join(" "); } // What the corner and the panel's header say. export const countText = (count) => `${count} problem${count === 1 ? "" : "s"}`; // What the corner holds, which app.css reserves room below the page for. export function cornerState(count, open) { if (count === 0) return "none"; return open ? "open" : "minimized"; } // One entry of the panel's list. export function problemEntry(d) { const li = document.createElement("li"); const location = where(d); if (location) { const span = document.createElement("span"); span.className = "where"; span.textContent = location + ": "; li.append(span); } li.append(document.createTextNode(d.message)); return li; }