From cd93c404a213ba44554b809653ed14d8c563822e Mon Sep 17 00:00:00 2001 From: mpadge Date: Mon, 22 Apr 2024 11:29:17 +0200 Subject: [PATCH 01/17] rm unused pkgs from ed-rev for #12 --- DESCRIPTION | 2 +- codemeta.json | 2 +- quarto/ed-reviews.qmd | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9cf099b..b0dcd7a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.1.8.024 +Version: 0.1.8.025 Authors@R: person(given = "First", family = "Last", diff --git a/codemeta.json b/codemeta.json index f1a0a6d..fe64bc9 100644 --- a/codemeta.json +++ b/codemeta.json @@ -6,7 +6,7 @@ "name": "dashboard: What the Package Does (One Line, Title Case)", "codeRepository": "https://github.com/ropensci-review-tools/dashboard", "license": "https://spdx.org/licenses/MIT", - "version": "0.1.8.024", + "version": "0.1.8.025", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/quarto/ed-reviews.qmd b/quarto/ed-reviews.qmd index 0e6c1fc..cb9adaa 100644 --- a/quarto/ed-reviews.qmd +++ b/quarto/ed-reviews.qmd @@ -11,11 +11,6 @@ format: ```{r load-pkg-ed-rev, echo = FALSE, message = FALSE} library (dashboard) -library (gt) -library (ggplot2) -library (tidyr) -library (dplyr) -library (viridis) ``` ```{r get-ed-dat, echo = FALSE, message = FALSE} From e61e50274603e557116d029de2a92bab9f173ce7 Mon Sep 17 00:00:00 2001 From: mpadge Date: Mon, 22 Apr 2024 12:08:01 +0200 Subject: [PATCH 02/17] start observable table for reviews page #12 --- DESCRIPTION | 2 +- codemeta.json | 2 +- quarto/_colorTable_fn.qmd | 72 +++++++++++++++++++++++++++++++++++++++ quarto/reviews.qmd | 65 +++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b0dcd7a..305b643 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dashboard Title: What the Package Does (One Line, Title Case) -Version: 0.1.8.025 +Version: 0.1.8.026 Authors@R: person(given = "First", family = "Last", diff --git a/codemeta.json b/codemeta.json index fe64bc9..cca87ae 100644 --- a/codemeta.json +++ b/codemeta.json @@ -6,7 +6,7 @@ "name": "dashboard: What the Package Does (One Line, Title Case)", "codeRepository": "https://github.com/ropensci-review-tools/dashboard", "license": "https://spdx.org/licenses/MIT", - "version": "0.1.8.025", + "version": "0.1.8.026", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/quarto/_colorTable_fn.qmd b/quarto/_colorTable_fn.qmd index 5a9be21..7cd2250 100644 --- a/quarto/_colorTable_fn.qmd +++ b/quarto/_colorTable_fn.qmd @@ -73,3 +73,75 @@ function colorTable(data, { return form; } ``` + +```{ojs} +// And modified verison for open reviews table +function reviewTable(data, { + colorColumn, + colorOpacity = 0.5, + issueNumColumn, + titleColumn, + columns = undefined, + format = {}, ...options}) { + const [row] = data; + if(!row) return Inputs.table(data, options); + + let index = Object.keys(row).indexOf(colorColumn); + if(index < 0) throw Error("colorColumn not found in data"); + if(format[colorColumn]) throw Error("colorColumn is reserved"); + if(columns && columns.indexOf(colorColumn) < 0) columns.push(colorColumn); + if(columns) index = columns.indexOf(colorColumn); + const nth = `nth-child(${index + 2})`; + + // Observable Table doesn't know about rows, so need to convert the + // "titleColumn" into an array with the title and issue number + // so then pass to the `format` call below to construct href + // objects: + const preprocessedData = data.map(row => ({ + ...row, + [titleColumn]: [row[titleColumn],row[issueNumColumn]] + }));`` + + const form = Inputs.table(preprocessedData, { + format: { + ...format, + [colorColumn]: d => htl.html`
`, + [issueNumColumn]: d => htl.html`${d}`, + [titleColumn]: d => htl.html`${d[0]}`, + }, + columns, + ...options + }); + + const scope = DOM.uid().id; + form.classList.add(scope); + + form.append(htl.html`