From 0210f0af5ffc5fed8f60e547ba4d454b00fca66a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 21 May 2024 12:11:46 -0500 Subject: [PATCH] CLDR-17465 Dashboard: fix xlsx download - fix parameters to sheet construction - refactor XLSX sheet and file calculation - #3640 restructured some of the front-end data --- tools/cldr-apps/js/src/esm/cldrDash.mjs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/cldr-apps/js/src/esm/cldrDash.mjs b/tools/cldr-apps/js/src/esm/cldrDash.mjs index 3509405024a..fe4b1189aca 100644 --- a/tools/cldr-apps/js/src/esm/cldrDash.mjs +++ b/tools/cldr-apps/js/src/esm/cldrDash.mjs @@ -391,6 +391,9 @@ function getCheckmarkUrl(entry, locale) { async function downloadXlsx(data, locale, cb) { const xpathMap = cldrSurvey.getXpathMap(); const { coverageLevel, entries } = data; + const coverageLevelName = (coverageLevel || "default").toLowerCase(); + const xlsSheetName = `${locale}.${coverageLevelName}`; + const xlsFileName = `Dash_${locale}_${coverageLevelName}.xlsx`; // Fetch all XPaths in parallel since it'll take a while cb(`Loading…`); @@ -425,7 +428,7 @@ async function downloadXlsx(data, locale, cb) { for (let e of entries) { const xpath = - section === "Reports" ? "-" : (await xpathMap.get(xpstrid)).path; + e.section === "Reports" ? "-" : (await xpathMap.get(e.xpstrid)).path; const url = `https://st.unicode.org/cldr-apps/v#/${e.locale}/${e.page}/${e.xpstrid}`; ws_data.push([ e.cat, @@ -445,13 +448,9 @@ async function downloadXlsx(data, locale, cb) { const ws = XLSX.utils.aoa_to_sheet(ws_data); // cldrXlsx.pushComment(ws, "C1", `As of ${new Date().toISOString()}`); const wb = XLSX.utils.book_new(); - XLSX.utils.book_append_sheet( - wb, - ws, - `${locale}.${coverageLevel.toLowerCase()}` - ); + XLSX.utils.book_append_sheet(wb, ws, xlsSheetName); cb(`Writing…`); - XLSX.writeFile(wb, `Dash_${locale}_${coverageLevel.toLowerCase()}.xlsx`); + XLSX.writeFile(wb, xlsFileName); cb(null); }