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

Improved Excel button #122

Merged
merged 23 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
53a79e5
Add basic excel button
aclark02-arcus Oct 29, 2024
e31bf06
try moving the button to the right, but failed.
aclark02-arcus Nov 4, 2024
4c0c9bd
Add helper function for DT renderDT() to determine the appropriate dt…
aclark02-arcus Nov 4, 2024
d9d19dc
update news
aclark02-arcus Nov 4, 2024
8576890
Add a default & custom excel filename for any & all listings with a d…
aclark02-arcus Nov 4, 2024
674b75c
clean up some code
aclark02-arcus Nov 4, 2024
b3e8819
move button to right-hand side so that it's not he first thing you see.
aclark02-arcus Nov 4, 2024
d271dfb
boost 'em' slightly for spacing of excel button
aclark02-arcus Nov 4, 2024
15adcb6
Changed 'excel' text on download button to an icon
aclark02-arcus Nov 4, 2024
67a624c
Increment version number to 0.1.0.9005
aclark02-arcus Nov 4, 2024
be88fae
update golem config version
aclark02-arcus Nov 4, 2024
b146fe9
add new json files
aclark02-arcus Nov 4, 2024
785f90d
remove timestamp from the downloadable excel filenames
aclark02-arcus Nov 5, 2024
85bbbce
update json files after removing timestamp
aclark02-arcus Nov 5, 2024
43ea7ef
updating json files now after actually changing them to be sans times…
aclark02-arcus Nov 5, 2024
3278dc5
update json snaps for feature 03
aclark02-arcus Nov 5, 2024
7d65a24
update jsons for study_forms mod snaps
aclark02-arcus Nov 5, 2024
eadd755
fix merge conflicts
aclark02-arcus Nov 6, 2024
72b4350
update w/ whack snaps that remove col reorder ext
aclark02-arcus Nov 6, 2024
0d991b7
update to be more flexible and reference default args for
aclark02-arcus Nov 6, 2024
ee2f6ea
update json snaps that now include col reorder
aclark02-arcus Nov 6, 2024
fc2e446
update description by adding devexVersion and reverting Version field.
aclark02-arcus Nov 8, 2024
130b274
Update NEWS.md with "`devex` changes" section
aclark02-arcus Nov 11, 2024
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: 1 addition & 1 deletion DESCRIPTION
aclark02-arcus marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clinsight
Title: ClinSight
Version: 0.1.0.9008
Version: 0.1.0.9009
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-6252-7639")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
- Fixed warnings in `apply_edc_specific_changes` due to the use of a vector within `dplyr::select`.
- Gave users ability to re-organized the column order in any table.
- Added form type as a class to be used in `create_table()` to display tables.
- Added `Excel` download button to Queries table & patient listings that need review.
- Added helper function to automatically determine when adding said excel button is appropriate.

## Bug fixes

- When using the `shinyproxy` deployment configuration, the user name is now expected to be base64 encoded, and will now be base64 encoded by `clinsight` by default, so that the app can also handle non-ASCII signs in user names that are stored in HTTP headers. To display the user name correctly, use base64 encoding in the `application.yml` in ShinyProxy settings (for example: `http-headers.X_SP_USERNAME: "#{T(java.util.Base64).getEncoder().encodeToString(oidcUser.getFullName().getBytes())}"`).


# clinsight 0.1.0

## Changed
Expand Down
29 changes: 29 additions & 0 deletions R/fct_data_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,35 @@ add_missing_columns <- function(
data
}

#' Configure DT helper
#'
#' Small wrapper that helps handle some messiness preparing the correct `DT`
#' dom, extensions, & options when needed. Specifically, when & how to add an
#' Excel download button.
#'
#' @param data A data frame used for display in a DT table. Number of rows will
#' be assessed
#' @param table_name character string, usually the form name
#'
#' @keywords internal
#' @return list with three named objects: `dom`, `exts`, and `opts`
dt_config <- function(data, table_name = "form") {
default_args<- formals(datatable_custom)
if(nrow(data) > 0 & isTRUE(get_golem_config("allow_listing_download"))) {
dt_dom <- 'Bfti'
dt_exts <- c("Buttons", eval(default_args$extensions))
dt_opts <- list(buttons=list(list(extend = 'excel',
text = '<i class="fa-solid fa-download"></i>',
filename = paste("clinsight", gsub(" ", "-", table_name), sep = ".")
)))
} else {
dt_dom <- default_args$dom |> eval()
dt_exts <- default_args$extensions |> eval()
dt_opts <- default_args$options |> eval()
}
return(list(dom = dt_dom, exts = dt_exts, opts = dt_opts))
}

#' Custom interactive datatable
#'
#' Small wrapper around [DT::datatable()]. Will be used to create tables in a
Expand Down
22 changes: 18 additions & 4 deletions R/mod_common_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ mod_common_forms_server <- function(
)) |>
adjust_colnames("^SAE ")
if(!input$show_all_data) SAE_data$subject_id <- NULL
datatable_custom(SAE_data, rename_vars = table_names, rownames= FALSE,
title = "Serious Adverse Events", escape = FALSE)

# determine DT dom / exts / opts
DT <- dt_config(SAE_data,
table_name = paste("SAE", ifelse(input$show_all_data,
"all_patients", r$subject_id), sep = "."))
datatable_custom(
SAE_data, rename_vars = table_names, rownames= FALSE,
title = "Serious Adverse Events", escape = FALSE,
dom = DT$dom, extensions = DT$exts, options = DT$opts
)
})

output[["common_form_table"]] <- DT::renderDT({
Expand All @@ -145,8 +153,14 @@ mod_common_forms_server <- function(
dplyr::select(-dplyr::starts_with("SAE"))
}
if(!input$show_all_data) df$subject_id <- NULL
datatable_custom(df, rename_vars = table_names, rownames= FALSE,
title = form, escape = FALSE)

# determine DT dom / exts / opts
DT <- dt_config(df,
table_name = paste(form, ifelse(input$show_all_data,
"all_patients", r$subject_id), sep = "."))
datatable_custom(
df, rename_vars = table_names, rownames= FALSE,title = form,
escape = FALSE, dom = DT$dom, extensions = DT$exts, options = DT$opts)
})

})
Expand Down
8 changes: 7 additions & 1 deletion R/mod_queries.R
jthompson-arcus marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,17 @@ mod_queries_server <- function(id, r, navinfo, all_forms, db_path, table_names){
query_cols <- c("resolved", query_cols)
table_title <- "All queries"
}

# determine DT dom / exts / opts
DT <- dt_config(initial_queries()[query_cols],
table_name = paste(ifelse(input$show_resolved, "all", "open"),
"queries", sep = "."))
datatable_custom(
initial_queries()[query_cols],
table_names,
title = table_title,
callback = dblclick_to_form(ns("go_to_form"))
callback = dblclick_to_form(ns("go_to_form")),
dom = DT$dom, extensions = DT$exts, options = DT$opts
)
})

Expand Down
7 changes: 6 additions & 1 deletion R/mod_study_forms.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ mod_study_forms_server <- function(

output[["table"]] <- DT::renderDT({
req(table_data_active())
datatable_custom(table_data_active(), table_names, escape = FALSE)
# determine DT dom / exts / opts
DT <- dt_config(table_data_active(),
table_name = paste(form, ifelse(input$show_all,
"all_patients", r$subject_id), sep = "."))
datatable_custom(table_data_active(), table_names, escape = FALSE,
dom = DT$dom, extensions = DT$exts, options = DT$opts)
})

if(form %in% c("Vital signs", "Vitals adjusted")){
Expand Down
5 changes: 5 additions & 0 deletions inst/app/www/custom.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

.dataTables_wrapper .dt-buttons {
padding-left: 0.75em;
float: right;
}

.bslib-value-box .value-box-area {
padding: 0.1rem 0rem 0.1rem 1rem;
}
Expand Down
3 changes: 2 additions & 1 deletion inst/golem-config.yml
aclark02-arcus marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
golem_name: clinsight
golem_version: 0.1.0.9008
golem_version: 0.1.0.9009
app_prod: no
user_identification: test_user
study_data: !expr clinsight::clinsightful_data
Expand All @@ -11,6 +11,7 @@ default:
Medical Monitor: medical_monitor
Data Manager: data_manager
allow_to_review: [admin, medical_monitor]
allow_listing_download: TRUE
dev:
golem_wd: !expr golem::pkg_path()
test:
Expand Down
23 changes: 23 additions & 0 deletions man/dt_config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 43 additions & 1 deletion tests/testthat/_snaps/app_feature_01/app-feature-1-002.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"filter": "none",
"vertical": false,
"extensions": [
"Buttons",
"Scroller",
"ColReorder"
],
Expand All @@ -251,8 +252,15 @@
"scrollResize": true,
"scrollCollapse": true,
"colReorder": true,
"buttons": [
{
"extend": "excel",
"text": "<i class=\"fa-solid fa-download\"><\/i>",
"filename": "clinsight.Adverse-events.BEL_04_772"
}
],
"initComplete": "function() {\n$(this.api().table().container()).find('.header').html(\"Adverse events\")\n}",
"dom": "f<\"header h5\">ti",
"dom": "Bf<\"header h5\">ti",
"columnDefs": [
{
"className": "dt-right",
Expand Down Expand Up @@ -389,6 +397,40 @@
"attachment": null,
"all_files": true
},
{
"name": "jszip",
"version": "1.13.6",
"src": {
"href": "jszip-1.13.6"
},
"meta": null,
"script": "jszip.min.js",
"stylesheet": null,
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-buttons-bootstrap5",
"version": "1.13.6",
"src": {
"href": "dt-ext-buttons-bootstrap5-1.13.6"
},
"meta": null,
"script": [
"js/dataTables.buttons.min.js",
"js/buttons.html5.min.js",
"js/buttons.colVis.min.js",
"js/buttons.print.min.js",
"js/buttons.bootstrap5.min.js"
],
"stylesheet": "css/buttons.bootstrap5.min.css",
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-scroller-bootstrap5",
"version": "1.13.6",
Expand Down
44 changes: 43 additions & 1 deletion tests/testthat/_snaps/app_feature_01/app-feature-1-003.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"filter": "none",
"vertical": false,
"extensions": [
"Buttons",
"Scroller",
"ColReorder"
],
Expand All @@ -251,8 +252,15 @@
"scrollResize": true,
"scrollCollapse": true,
"colReorder": true,
"buttons": [
{
"extend": "excel",
"text": "<i class=\"fa-solid fa-download\"><\/i>",
"filename": "clinsight.Adverse-events.BEL_04_772"
}
],
"initComplete": "function() {\n$(this.api().table().container()).find('.header').html(\"Adverse events\")\n}",
"dom": "f<\"header h5\">ti",
"dom": "Bf<\"header h5\">ti",
"columnDefs": [
{
"className": "dt-right",
Expand Down Expand Up @@ -389,6 +397,40 @@
"attachment": null,
"all_files": true
},
{
"name": "jszip",
"version": "1.13.6",
"src": {
"href": "jszip-1.13.6"
},
"meta": null,
"script": "jszip.min.js",
"stylesheet": null,
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-buttons-bootstrap5",
"version": "1.13.6",
"src": {
"href": "dt-ext-buttons-bootstrap5-1.13.6"
},
"meta": null,
"script": [
"js/dataTables.buttons.min.js",
"js/buttons.html5.min.js",
"js/buttons.colVis.min.js",
"js/buttons.print.min.js",
"js/buttons.bootstrap5.min.js"
],
"stylesheet": "css/buttons.bootstrap5.min.css",
"head": null,
"attachment": null,
"package": null,
"all_files": false
},
{
"name": "dt-ext-scroller-bootstrap5",
"version": "1.13.6",
Expand Down
Loading
Loading