Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds decorators to tm_t_pp_basic_info #1282

Conversation

averissimo
Copy link
Contributor

@averissimo averissimo commented Dec 4, 2024

Part of insightsengineering/teal#1371

Working example
# Load packages
pkgload::load_all("../teal.modules.clinical", export_all = FALSE)
# Example below

insert_rlisting_footer_decorator <- function(default_caption = "I am a good new footer", .var_to_replace = "table") {
  teal_transform_module(
    label = "New row",
    ui = function(id) shiny::textInput(shiny::NS(id, "new_footer"), "New footer", value = default_caption),
    server = make_teal_transform_server(
      substitute({
        rlistings::main_footer(.var_to_replace) <- new_footer
      }, env = list(.var_to_replace = as.name(.var_to_replace)))
    )
  )
}

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]

init(
  data = data,
  modules = modules(
    tm_t_pp_basic_info(
      label = "Basic Info",
      dataname = "ADSL",
      patient_col = "USUBJID",
      vars = choices_selected(choices = variable_choices(ADSL), selected = c("ARM", "AGE", "SEX", "COUNTRY", "RACE", "EOSSTT")),
      decorators = list(
        table = insert_rlisting_footer_decorator(.var_to_replace = "table")
      )
    )
  )
) |> shiny::runApp()

…_decorate_output@main

* 1187_decorate_output@main:
  [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
  docs: minor typo gg -> ggplot2
  [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
  docs: documentation simplification
  [skip actions] Bump version to 0.9.1.9037
  fixes error in adverse events when `ASTDY` is of difftime type (#1284)
@averissimo averissimo marked this pull request as ready for review December 6, 2024 10:25
Copy link
Contributor

@llrs-roche llrs-roche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you moved some options from the module to the template function. I think this is to make it easier to have a decorator on the interactive table of the shiny app and one for the static on the reporter.
My only concern with this approach is that the dt_decorator is quite complex (suppose because it cannot use make_teal_transform_server) and I thought that we would only decorate objects that end up on the reporter. Perhaps we can talk about it

R/tm_t_pp_basic_info.R Outdated Show resolved Hide resolved
Copy link
Contributor

@llrs-roche llrs-roche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking with the team I was reminded that we are only adding decorators for objects that are on the reporters. Changes to the table_dt (not used on the reporter) should be reverted.

R/tm_t_pp_basic_info.R Outdated Show resolved Hide resolved
R/tm_t_pp_basic_info.R Outdated Show resolved Hide resolved
R/tm_t_pp_basic_info.R Outdated Show resolved Hide resolved
@averissimo averissimo merged commit 95f11f3 into 1187_decorate_output@main Dec 11, 2024
1 check passed
@averissimo averissimo deleted the tm_t_pp_basic_info@1187_decorate_output@main branch December 11, 2024 14:39
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants