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

Refactor/modularize parameter datasets #188

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions inst/shiny/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ source("modules/tab_visuals.R")

source("functions/mapping_selectize_inputs.R")
source("functions/generate_col_defs.R")

source("modules/parameter_datasets.R")
75 changes: 75 additions & 0 deletions inst/shiny/modules/parameter_datasets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
parameter_datasets_ui <- function(id) {
ns <- NS(id)
navset_pill(
nav_panel("PP", DTOutput(ns("pp_dataset"))),
nav_panel("ADPP", DTOutput(ns("adpp_dataset")))
)
}

parameter_datasets_server <- function(id, res_nca) {
moduleServer(id, function(input, output, session) {
CDISC <- reactive({
req(res_nca())
export_cdisc(res_nca())
})

output$pp_dataset <- DT::renderDataTable({
DT::datatable(
data = CDISC()$pp,
rownames = FALSE,
extensions = c("FixedHeader", "Buttons"),
options = list(
scrollX = TRUE,
scrollY = TRUE,
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: allow user to copy/download all rows with a whole display of the dataset

Suggested change
scrollY = TRUE,
scrollY = TRUE,
pageLength = -1,

searching = TRUE,
fixedColumns = TRUE,
fixedHeader = TRUE,
autoWidth = TRUE,
dom = "Bfrtip",
buttons = list(
list(
extend = "copy",
title = paste0("PP_Dataset", "_", Sys.Date())
),
list(
extend = "csv",
title = paste0("PP_Dataset", "_", Sys.Date())
),
list(
extend = "excel",
title = paste0("PP_Dataset", "_", Sys.Date())
)
)
)
)
})

output$adpp_dataset <- DT::renderDataTable({
DT::datatable(
data = CDISC()$adpp,
Copy link
Collaborator

@Gero1999 Gero1999 Feb 6, 2025

Choose a reason for hiding this comment

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

suggestion: do not display row names

Suggested change
data = CDISC()$adpp,
data = CDISC()$adpp,
rownames = FALSE,

extensions = c("FixedHeader", "Buttons"),
options = list(
scrollX = TRUE,
scrollY = TRUE,
lengthMenu = list(c(10, 25, -1), c("10", "25", "All")),
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: allow user to copy/download all rows with a whole display of the dataset
(note: menu won't work & is not needed anyways)

Suggested change
lengthMenu = list(c(10, 25, -1), c("10", "25", "All")),
pageLength = -1,

fixedHeader = TRUE,
dom = "Bfrtip",
buttons = list(
list(
extend = "copy",
title = paste0("ADPP_Dataset", "_", Sys.Date())
),
list(
extend = "csv",
title = paste0("ADPP_Dataset", "_", Sys.Date())
),
list(
extend = "excel",
title = paste0("ADPP_Dataset", "_", Sys.Date())
)
)
)
)
})
})
}
63 changes: 1 addition & 62 deletions inst/shiny/tabs/nca.R
Original file line number Diff line number Diff line change
Expand Up @@ -787,65 +787,4 @@ output$manual_slopes2 <- renderTable({
# Parameter datasets ------------------------------------------------------------------------

# Create CDISC parameter datasets (PP, ADPP)
observeEvent(res_nca(), {
CDISC <- export_cdisc(res_nca())

output$pp_dataset <- DT::renderDataTable({
DT::datatable(
data = CDISC$pp,
rownames = FALSE,
extensions = c("FixedHeader", "Buttons"),
options = list(
scrollX = TRUE,
scrollY = TRUE,
searching = TRUE,
fixedColumns = TRUE,
fixedHeader = TRUE,
autoWidth = TRUE,
dom = "Bfrtip",
buttons = list(
list(
extend = "copy",
title = paste0("PP_Dataset", "_", Sys.Date())
),
list(
extend = "csv",
title = paste0("PP_Dataset", "_", Sys.Date())
),
list(
extend = "excel",
title = paste0("PP_Dataset", "_", Sys.Date())
)
)
)
)
}, server = FALSE)

output$adpp_dataset <- DT::renderDataTable({
DT::datatable(
data = CDISC$adpp,
extensions = c("FixedHeader", "Buttons"),
options = list(
scrollX = TRUE,
scrollY = TRUE,
lengthMenu = list(c(10, 25, -1), c("10", "25", "All")),
fixedHeader = TRUE,
dom = "Bfrtip",
buttons = list(
list(
extend = "copy",
title = paste0("ADPP_Dataset", "_", Sys.Date())
),
list(
extend = "csv",
title = paste0("ADPP_Dataset", "_", Sys.Date())
),
list(
extend = "excel",
title = paste0("ADPP_Dataset", "_", Sys.Date())
)
)
)
)
})
})
parameter_datasets_server("parameter_datasets", res_nca)
8 changes: 1 addition & 7 deletions inst/shiny/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,7 @@ fluidPage(
"Exclusions",
tableOutput("manual_slopes2")
),
tabPanel("Parameter Datasets",
tabsetPanel(
tabPanel("PP",
DTOutput("pp_dataset")),
tabPanel("ADPP",
DTOutput("adpp_dataset"))
))
tabPanel("Parameter Datasets", parameter_datasets_ui("parameter_datasets"))
)
)
)
Expand Down