// ---------- Launch calendar ---------- // RNDSystems launches every 2nd & 4th Tuesday · BT launches every 3rd Tuesday. // Code freeze: Friday at 10:00 AM, the week of the launch (Friday before launch day). const UAT_NOW = new Date(); UAT_NOW.setHours(0, 0, 0, 0); function nthTuesday(y, m, n) { const d = new Date(y, m, 1); const first = ((2 - d.getDay()) + 7) % 7; // offset to first Tuesday return new Date(y, m, 1 + first + (n - 1) * 7); } function upcomingLaunches(ordinals, count) { const out = []; for (let i = 0; i < 18 && out.length < count; i++) { const m = UAT_NOW.getMonth() + i; const y = UAT_NOW.getFullYear() + Math.floor(m / 12); const mm = m % 12; for (const n of ordinals) { const launch = nthTuesday(y, mm, n); if (launch >= UAT_NOW) out.push({ launch, freeze: new Date(launch.getTime() - 4 * 86400000) }); } } return out.sort((a, b) => a.launch - b.launch).slice(0, count); } const fmtD = d => d.toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" }); const fmtDy = d => d.toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" }); const daysUntil = d => Math.round((d - UAT_NOW) / 86400000); // ---------- Editable launch dates ---------- // Click any launch date to type a new one. Overrides are saved in this // browser; the freeze date, countdowns and section order all recalculate. const LO_KEY = "sm-launch-overrides-v1"; let launchOverrides = {}; try { launchOverrides = JSON.parse(localStorage.getItem(LO_KEY) || "{}"); } catch { launchOverrides = {}; } const lkey = d => d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0"); function applyLaunchOverrides(list) { for (const l of list) { l.orig = lkey(l.launch); // scheduled date, before any override const ov = launchOverrides[l.orig]; if (!ov) continue; const nd = new Date(ov + "T00:00:00"); if (isNaN(nd) || nd < UAT_NOW) { delete launchOverrides[l.orig]; continue; } const back = ((nd.getDay() - 5 + 7) % 7) || 7; // code freeze = Friday before the launch l.launch = nd; l.freeze = new Date(nd.getTime() - back * 86400000); } return list.sort((a, b) => a.launch - b.launch); } let RDNS_LAUNCHES = applyLaunchOverrides(upcomingLaunches([2, 4], 3)); let BT_LAUNCHES = applyLaunchOverrides(upcomingLaunches([3], 3)); // global next freeze (whichever comes first) let NEXT_FREEZE = null; function recomputeLaunches() { RDNS_LAUNCHES = applyLaunchOverrides(upcomingLaunches([2, 4], 3)); BT_LAUNCHES = applyLaunchOverrides(upcomingLaunches([3], 3)); NEXT_FREEZE = RDNS_LAUNCHES[0].freeze < BT_LAUNCHES[0].freeze ? { ...RDNS_LAUNCHES[0], site: "RNDSystems" } : { ...BT_LAUNCHES[0], site: "BT" }; } recomputeLaunches(); function launchDateSpan(l, withYear) { const edited = l.orig !== lkey(l.launch); return `${(withYear ? fmtDy : fmtD)(l.launch)}${edited ? " ✎" : ""}`; } function editLaunchDate(el) { if (!el || el.querySelector("input")) return; const orig = el.getAttribute("data-ldo"); const cur = el.getAttribute("data-ldv"); const inp = document.createElement("input"); inp.type = "date"; inp.value = cur; inp.style.cssText = "font:inherit;font-size:13px;font-weight:700;padding:2px 8px;margin:0 2px;border:1.5px solid var(--accent);border-radius:7px;color:var(--text);background:#fff"; el.textContent = ""; el.appendChild(inp); inp.focus(); try { inp.showPicker && inp.showPicker(); } catch (e) {} let finished = false; const finish = save => { if (finished) return; finished = true; const v = inp.value; if (save && v && v !== cur) { if (v === orig) { delete launchOverrides[orig]; localStorage.setItem(LO_KEY, JSON.stringify(launchOverrides)); recomputeLaunches(); } else if (v >= lkey(UAT_NOW)) { launchOverrides[orig] = v; localStorage.setItem(LO_KEY, JSON.stringify(launchOverrides)); recomputeLaunches(); } else alert("That date is in the past — keeping the scheduled date instead."); } uatRender(); }; inp.addEventListener("keydown", e => { if (e.key === "Enter") finish(true); else if (e.key === "Escape") finish(false); e.stopPropagation(); }); inp.addEventListener("blur", () => finish(true)); } window.editLaunchDate = editLaunchDate; // ---------- Grouping (by launch cycle) ---------- function siteOf(t) { const first = ((t.desc || "").split("|")[0] || "").trim().toLowerCase(); if (/^rnd|^r&d/.test(first)) return "RNDSystems"; if (/^bt\b|^bio/.test(first)) return "BT"; if (/^wms/.test(first)) return "WMS"; if (/^sbd|^spd|^spatial/.test(first)) return "SBD"; return "Other"; } const SITE_ORDER = { "RNDSystems": 10, "BT": 11, "WMS": 12, "SBD": 13 }; const STATE_OPTIONS = ["Draft", "Ready", "Work in Progress", "Peer Review", "QA Testing", "UAT Testing", "Approved", "Awaiting Deployment", "Complete", "Cancelled"]; // priority within a launch section: outreach action needed first, then state readiness const ACTION_ORDER = { 0: 0, 1: 1, 2: 2, 4: 3, 3: 4 }; const STATE_ORDER = { "UAT Testing": 0, "Work in Progress": 1, "Peer Review": 2, "QA Testing": 3, "Draft": 4, "Ready": 5 }; // "sent to bottom" memory (order matters — the order you sent them down) const BOTTOM_KEY = "uat-outreach-bottom-v1"; let bottomOrder = []; try { bottomOrder = JSON.parse(localStorage.getItem(BOTTOM_KEY) || "[]"); } catch { bottomOrder = []; } function saveBottom() { localStorage.setItem(BOTTOM_KEY, JSON.stringify(bottomOrder)); } function moveBottom(id) { if (bottomOrder.includes(id)) bottomOrder = bottomOrder.filter(x => x !== id); else bottomOrder.push(id); saveBottom(); uatRender(); } // ---------- Filters ---------- const els = { statusFilter: document.getElementById("statusFilter"), stateFilter: document.getElementById("stateFilter"), epicFilter: document.getElementById("epicFilter"), search: document.getElementById("search"), showDone: document.getElementById("showDoneToggle"), list: document.getElementById("list"), }; let hideApproved = false; let showHidden = false; const isVisibleState = t => !HARD_EXCLUDED.has(t.state) && (showHidden || !IGNORED_STATES.has(t.state)); function populateFilters() { const states = [...new Set(tickets.map(t => t.state).filter(s => s && !HARD_EXCLUDED.has(s) && (showHidden || !IGNORED_STATES.has(s))))].sort(); const epics = [...new Set(tickets.map(t => t.epic).filter(Boolean))].sort(); const prevState = els.stateFilter.value; const prevEpic = els.epicFilter.value; els.stateFilter.innerHTML = '' + states.map(s => ``).join(""); els.epicFilter.innerHTML = '' + epics.map(s => ``).join(""); if (states.includes(prevState)) els.stateFilter.value = prevState; if (epics.includes(prevEpic)) els.epicFilter.value = prevEpic; } function visibleTickets() { const sf = els.statusFilter.value; const ts = els.stateFilter.value; const ep = els.epicFilter.value; const q = els.search.value.trim().toLowerCase(); return tickets.filter(t => { if (!isVisibleState(t)) return false; if (hideApproved && uatStatusOf(t) === 3 && sf === "") return false; if (sf !== "" && uatStatusOf(t) !== Number(sf)) return false; if (ts && t.state !== ts) return false; if (ep && t.epic !== ep) return false; if (q && !(t.ticket + " " + t.desc + " " + t.assigned_to + " " + t.opened_by + " " + t.epic + " " + (t.watch_list || "")).toLowerCase().includes(q)) return false; return true; }); } // ---------- Render (organized by next launch per site) ---------- function escUat(s) { return (s || "").replace(/[&<>"']/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c])); } function uatRender() { const vis = visibleTickets(); vis.forEach(t => { t.site = siteOf(t); }); // summary (counts over all tickets) const counts = [0, 0, 0, 0, 0]; const active = tickets.filter(t => isVisibleState(t)); active.forEach(t => counts[uatStatusOf(t)]++); for (let i = 0; i < 5; i++) document.getElementById("cnt" + i).textContent = counts[i]; const done = counts[3], total = active.length; const pct = total ? Math.round((done / total) * 100) : 0; document.getElementById("prog").style.width = pct + "%"; document.getElementById("progLabel").textContent = total ? `${done} of ${total} approved (${pct}%) · ${counts[2]} waiting on a response` : ""; // freeze banner (top of page) const bf = document.getElementById("uatBanner"); if (bf) { const n = daysUntil(NEXT_FREEZE.freeze); if (n >= 0 && n <= 7) { bf.style.display = "flex"; bf.innerHTML = `⚠️ Code freeze: ${fmtD(NEXT_FREEZE.freeze)} at 10:00 AM (${n === 0 ? "TODAY" : n + " day" + (n === 1 ? "" : "s") + " from now"}) → launch ${escUat(NEXT_FREEZE.site)} on ${fmtD(NEXT_FREEZE.launch)} · make sure testers are booked & approved stories are ready`; } else bf.style.display = "none"; } // launch calendar cards const lc = document.getElementById("launchCards"); if (lc) { const siteCount = s => vis.filter(t => t.site === s).length; const card = (name, rule, launches, count) => { const hot = daysUntil(launches[0].freeze) <= 7; return `