Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fbe8eb6
feat: make ui changes to improve UI/UX in teal
vedhav Jul 11, 2025
7bb0ed0
chore: remove unused restore input and fix lint errors
vedhav Jul 15, 2025
67c5af3
docs: update NEWS
vedhav Jul 15, 2025
4d0c953
feat: improve the button ui and handle disable/enable
vedhav Jul 15, 2025
a5d3813
feat: make the add card popup buttons consistant with others
vedhav Jul 15, 2025
2305eb0
chore: simplify outline button style
vedhav Jul 15, 2025
5bb2556
chore: remove unused data attributes
vedhav Jul 15, 2025
7f319b3
chore: fix linter
vedhav Jul 15, 2025
04e29c0
chore: remove server code associated with the encoding panel
vedhav Jul 15, 2025
76d5bcb
add download_report_button_module
gogonzo Jul 16, 2025
c938bcf
feat: bring back the new styles
vedhav Jul 16, 2025
09f3646
feat: update preview button style
vedhav Jul 16, 2025
153f7c8
feat: add a count badge to preview button
vedhav Jul 16, 2025
fb0b9e4
[skip style] [skip vbump] Restyle files
github-actions[bot] Jul 17, 2025
4ffd2dc
fix download button
gogonzo Jul 17, 2025
91db06a
remove duplicated stuff
gogonzo Jul 18, 2025
34acddb
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jul 18, 2025
b5cc53b
feat: render report previewer using bslib accordion and make the card…
vedhav Jul 21, 2025
af9706f
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jul 21, 2025
8f76413
feat: improve the previewer sorting
vedhav Jul 22, 2025
6a8829e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Jul 22, 2025
752eb99
fix: place the remove button at the end
vedhav Jul 22, 2025
d38b92e
feat: increase the previewer modal
vedhav Jul 22, 2025
cde93c7
chore: stop using pipes
vedhav Jul 22, 2025
6e2efb0
chore: address @gogonzo comments
vedhav Jul 22, 2025
d93fbca
chore: bring back simple reporter ui
vedhav Jul 22, 2025
4ee3724
docs: use the add to reporter button in the vignette
vedhav Jul 22, 2025
98bd16f
chore: fix broken tests
vedhav Jul 22, 2025
842050a
chore: add package namespace
vedhav Jul 22, 2025
4accf3c
chore: allow to change label and document the param
vedhav Jul 22, 2025
a5cb873
fix: make all buttons have empty label by default except previewer
vedhav Jul 22, 2025
822d1b1
chore: remove some unwanted styles
vedhav Jul 22, 2025
f4d99cb
fix: make sure the download button loader does not increase the butto…
vedhav Jul 22, 2025
3a1f56d
chore: standardize the modal ui elements based on discussion with the…
vedhav Jul 22, 2025
1375a67
chore: re-organize the css
vedhav Jul 23, 2025
e7aefb3
chore: fix button styling and maintain backwards compatibility
vedhav Jul 23, 2025
3e7f93e
docs: update news and deprecation message
vedhav Jul 23, 2025
993d110
feat: show/hide buttons based on `previewer_buttons` for legacy previ…
vedhav Jul 23, 2025
4902461
chore: rename the main module that contains the preview content
vedhav Jul 23, 2025
4ffa082
prefix tagList
gogonzo Jul 23, 2025
11cfd3b
prefix `tags$`
gogonzo Jul 23, 2025
31741c9
docs: update vignette to not use deprecated functions
vedhav Jul 24, 2025
5c09cd2
docs: standardize and organize the function docs in pkgdown site
vedhav Jul 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ URL: https://github.com/insightsengineering/teal.reporter,
https://insightsengineering.github.io/teal.reporter/
BugReports: https://github.com/insightsengineering/teal.reporter/issues
Imports:
bsicons,
bslib (>= 0.8.0),
checkmate (>= 2.1.0),
flextable (>= 0.9.2),
Expand All @@ -35,8 +36,10 @@ Imports:
rtables (>= 0.6.11),
rtables.officer (>= 0.0.2),
shiny (>= 1.6.0),
shinyjs,
shinybusy (>= 0.3.2),
shinyWidgets (>= 0.5.1),
sortable (>= 0.5.0),
yaml (>= 1.1.0),
zip (>= 1.1.0)
Suggests:
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export(add_card_button_ui)
export(as_yaml_auto)
export(download_report_button_srv)
export(download_report_button_ui)
export(preview_report_button_srv)
export(preview_report_button_ui)
export(report_load_srv)
export(report_load_ui)
export(reporter_previewer_srv)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

# teal.reporter 0.4.0

### Breaking changes

* The functions `reporter_previewer_ui()` and `reporter_previewer_srv()` are deprecated and will be removed in a future release. Please migrate to using the underlying shiny modules independently:
- **UI**: `report_load_ui()`, `download_report_button_ui()`, `reset_report_button_ui()`, and `preview_report_button_ui()`
- **Server**: `report_load_srv()`, `download_report_button_srv()`, `reset_report_button_srv()`, and `preview_report_button_srv()`

### Enhancements

* Reports can now be reloaded. A zip file containing the report can be uploaded to restore the state of the Previewer.
* Report cards are now included in bookmarks. When using the `shiny` bookmarking mechanism, existing report cards will be available in the restored application.
* HTML content can now be added to the report.
* Added `preview_report_button_ui` and `preview_report_button_srv` to create a shiny module that creates a button to open the report previewer in a modal.

# teal.reporter 0.3.1

Expand Down
51 changes: 11 additions & 40 deletions R/AddCardModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,20 @@
#'
#' @param id (`character(1)`) this `shiny` module's id.
#' @param reporter (`Reporter`) instance.
#' @param label (`character(1)`) label of the button. By default it is empty.
#' @param card_fun (`function`) which returns a [`ReportCard`] instance. See `Details`.
#'
#' @return `NULL`.
NULL

#' @rdname add_card_button
#' @export
add_card_button_ui <- function(id) {
ns <- shiny::NS(id)

# Buttons with custom css and
# js code to disable the add card button when clicked to prevent multi-clicks
shiny::tagList(
shiny::singleton(
shiny::tags$head(shiny::includeCSS(system.file("css/custom.css", package = "teal.reporter")))
),
shiny::singleton(
shiny::tags$head(
shiny::tags$script(
shiny::HTML(
sprintf(
'
$(document).ready(function(event) {
$("body").on("click", "#%s", function() {
$(this).addClass("disabled");
})
})',
ns("add_card_ok")
)
)
)
)
),
shiny::actionButton(
ns("add_report_card_button"),
title = "Add Card",
class = "teal-reporter simple_report_button btn-primary",
`data-val` = shiny::restoreInput(id = ns("add_report_card_button"), default = NULL),
shiny::tags$span(
shiny::icon("plus")
)
)
add_card_button_ui <- function(id, label = NULL) {
checkmate::assert_string(label, null.ok = TRUE)
.outline_button(
shiny::NS(id, "add_report_card_button"),
icon = "plus-lg",
label = label
)
}

Expand All @@ -97,7 +69,8 @@ add_card_button_srv <- function(id, reporter, card_fun) {

add_modal <- function() {
shiny::div(
class = "teal-widgets reporter-modal",
class = "teal-reporter reporter-modal",
.custom_css_dependency(),
shiny::modalDialog(
easyClose = TRUE,
shiny::tags$h3("Add a Card to the Report"),
Expand Down Expand Up @@ -131,17 +104,15 @@ add_card_button_srv <- function(id, reporter, card_fun) {
footer = shiny::div(
shiny::tags$button(
type = "button",
class = "btn btn-secondary",
`data-dismiss` = "modal",
class = "btn btn-outline-secondary",
`data-bs-dismiss` = "modal",
NULL,
"Cancel"
"Dismiss"
),
shiny::tags$button(
id = ns("add_card_ok"),
type = "button",
class = "btn btn-primary action-button",
`data-val` = shiny::restoreInput(id = ns("add_card_ok"), default = NULL),
NULL,
"Add Card"
)
Expand Down
70 changes: 30 additions & 40 deletions R/DownloadModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#'
#' @param id (`character(1)`) this `shiny` module's id.
#' @param reporter (`Reporter`) instance.
#' @param label (`character(1)`) label of the button. By default it is empty.
#' @param global_knitr (`list`) of `knitr` parameters (passed to `knitr::opts_chunk$set`)
#' for customizing the rendering process.
#' @inheritParams reporter_download_inputs
Expand All @@ -21,21 +22,12 @@ NULL

#' @rdname download_report_button
#' @export
download_report_button_ui <- function(id) {
ns <- shiny::NS(id)
shiny::tagList(
shiny::singleton(
shiny::tags$head(shiny::includeCSS(system.file("css/custom.css", package = "teal.reporter")))
),
shiny::actionButton(
ns("download_button"),
class = "teal-reporter simple_report_button btn-primary",
title = "Download",
`data-val` = shiny::restoreInput(id = ns("download_button"), default = NULL),
shiny::tags$span(
shiny::icon("download")
)
)
download_report_button_ui <- function(id, label = NULL) {
checkmate::assert_string(label, null.ok = TRUE)
.outline_button(
shiny::NS(id, "download_button"),
label = label,
icon = "download"
)
}

Expand All @@ -44,15 +36,8 @@ download_report_button_ui <- function(id) {
download_report_button_srv <- function(id,
reporter,
global_knitr = getOption("teal.reporter.global_knitr"),
rmd_output = c(
"html" = "html_document", "pdf" = "pdf_document",
"powerpoint" = "powerpoint_presentation", "word" = "word_document"
),
rmd_yaml_args = list(
author = "NEST", title = "Report",
date = as.character(Sys.Date()), output = "html_document",
toc = FALSE
)) {
rmd_output = getOption("teal.reporter.rmd_output"),
rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args")) {
checkmate::assert_class(reporter, "Reporter")
checkmate::assert_subset(names(global_knitr), names(knitr::opts_chunk$get()))
checkmate::assert_subset(
Expand All @@ -78,37 +63,37 @@ download_report_button_srv <- function(id,

download_modal <- function() {
nr_cards <- length(reporter$get_cards())
downb <- shiny::tags$a(
id = ns("download_data"),
class = paste("btn btn-primary shiny-download-link", if (nr_cards) NULL else "disabled"),
style = if (nr_cards) NULL else "pointer-events: none;",
href = "",
target = "_blank",
download = NA,
shiny::icon("download"),
"Download"
downb <- shiny::downloadButton(
outputId = ns("download_data"),
label = "Download",
class = c(
"btn", "teal-reporter", "download-ok", "btn-primary", "shiny-download-link",
if (nr_cards == 0) "disabled"
),
icon = shiny::icon("download")
)
shiny::tags$div(
class = "teal-widgets reporter-modal",
class = "teal-reporter reporter-modal",
.custom_css_dependency(),
shiny::modalDialog(
easyClose = TRUE,
shiny::tags$h3("Download the Report"),
shiny::tags$hr(),
if (length(reporter$get_cards()) == 0) {
shiny::tags$div(
class = "mb-4",
shiny::tags$p(
class = "text-danger",
shiny::tags$strong("No Cards Added")
)
),
shiny::tags$br()
)
} else {
shiny::tags$div(
class = "mb-4",
shiny::tags$p(
class = "text-success",
shiny::tags$strong(paste("Number of cards: ", nr_cards))
),
shiny::tags$br()
)
},
reporter_download_inputs(
Expand All @@ -120,11 +105,10 @@ download_report_button_srv <- function(id,
footer = shiny::tagList(
shiny::tags$button(
type = "button",
class = "btn btn-secondary",
`data-dismiss` = "modal",
class = "btn btn-outline-secondary",
`data-bs-dismiss` = "modal",
NULL,
"Cancel"
"Dismiss"
),
downb
)
Expand All @@ -136,6 +120,12 @@ download_report_button_srv <- function(id,
shiny::showModal(download_modal())
})

shiny::observeEvent(reporter$get_reactive_add_card(), {
shinyjs::toggleClass(
id = "download_button", condition = reporter$get_reactive_add_card() == 0, class = "disabled"
)
})

output$download_data <- shiny::downloadHandler(
filename = function() {
paste0(
Expand Down
74 changes: 37 additions & 37 deletions R/LoadReporterModule.R
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
#' User Interface to Load `Reporter`
#' Load `Reporter` button module
#'
#' @description `r lifecycle::badge("experimental")`
#' Button to upload `ReporterCard`(s) to the `Reporter`.
#'
#' For more details see the vignette: `vignette("simpleReporter", "teal.reporter")`.
#' Provides a button to upload `ReporterCard`(s) to the `Reporter`.
#'
#' For more information, refer to the vignette: `vignette("simpleReporter", "teal.reporter")`.
#'
#' @name load_report_button
#'
#' @param id `character(1)` this `shiny` module's id.
#' @param label (`character(1)`) label of the button. By default it is empty.
#' @param reporter [`Reporter`] instance.
NULL

#' @rdname load_report_button
#' @return `shiny::tagList`
#' @export
report_load_ui <- function(id) {
ns <- shiny::NS(id)

shiny::tagList(
shiny::singleton(
shiny::tags$head(shiny::includeCSS(system.file("css/custom.css", package = "teal.reporter")))
),
shiny::actionButton(
ns("reporter_load"),
class = "teal-reporter simple_report_button btn-primary",
title = "Load",
shiny::tags$span(
shiny::icon("upload")
)
)
report_load_ui <- function(id, label = NULL) {
checkmate::assert_string(label, null.ok = TRUE)
.outline_button(
shiny::NS(id, "reporter_load"),
label = label,
icon = "upload"
)
}

#' Server to Load `Reporter`
#' @description `r lifecycle::badge("experimental")`
#' Server to load `ReporterCard`(s) to the `Reporter`
#'
#' For more details see the vignette: `vignette("simpleReporter", "teal.reporter")`.
#'
#' @param id `character(1)` this `shiny` module's id.
#' @param reporter [`Reporter`] instance.
#'

#' @rdname load_report_button
#' @return `shiny::moduleServer`
#' @export
report_load_srv <- function(id, reporter) {
Expand All @@ -47,7 +41,8 @@ report_load_srv <- function(id, reporter) {
archiver_modal <- function() {
nr_cards <- length(reporter$get_cards())
shiny::div(
class = "teal-widgets reporter-modal",
class = "teal-reporter reporter-modal",
.custom_css_dependency(),
shiny::modalDialog(
easyClose = TRUE,
shiny::tags$h3("Load the Report"),
Expand All @@ -59,24 +54,29 @@ report_load_srv <- function(id, reporter) {
footer = shiny::div(
shiny::tags$button(
type = "button",
class = "btn btn-danger",
`data-dismiss` = "modal",
class = "btn btn-outline-secondary",
`data-bs-dismiss` = "modal",
NULL,
"Cancel"
"Dismiss"
),
shiny::tags$button(
id = ns("reporter_load_main"),
type = "button",
class = "btn btn-primary action-button",
NULL,
"Load"
shinyjs::disabled(
shiny::tags$button(
id = ns("reporter_load_main"),
type = "button",
class = "btn btn-primary action-button",
NULL,
"Load"
)
)
)
)
)
}

shiny::observeEvent(input$archiver_zip, {
shinyjs::enable(id = "reporter_load_main")
})

shiny::observeEvent(input$reporter_load, {
shiny::showModal(archiver_modal())
})
Expand Down
Loading
Loading