Skip to content

Commit

Permalink
set name of PDF document
Browse files Browse the repository at this point in the history
  • Loading branch information
aghaynes committed Apr 26, 2024
1 parent 0404a0f commit 32dc082
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Add support for costings from the DM reporting group.
* Refer to Institution rather than Sponsor on the costing PDF.
* MZ noticed that the filename in adobe is sometimes shown as "A test document". This update changes it to the filename instead.

# CTUCosting 0.4.9 (2024-04-10)

Expand Down
3 changes: 2 additions & 1 deletion R/gen_pdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ gen_pdf <- function(output,
fte = inputs$fte,
include_design = inputs$include_design,
include_int = inputs$include_int,
include_participants = inputs$include_participants
include_participants = inputs$include_participants,
filename = inputs$filename
),
clean = FALSE
)
Expand Down
9 changes: 9 additions & 0 deletions inst/app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,14 @@ function(input, output, session){

# downloads ----
## PDF ----
fname <- function(cons_num,
proj_num,
studyname){
num <- cons_num
if(!is.na(proj_num)) num <- paste0("Amendment_P", proj_num)
paste0("Costing_", num, "_", studyname, "_", Sys.Date(), ".pdf")
}

output$pdf <- downloadHandler(
filename = function(cons_num = info()$consultingnum,
proj_num = info()$projnum,
Expand Down Expand Up @@ -601,6 +609,7 @@ function(input, output, session){
inputs$include_design <- input$include_design
inputs$include_int <- input$include_int
inputs$include_participants <- input$include_participants
inputs$filename <- fname(info()$consultingnum, info()$projnum, info()$acronym)

inputs$break_tasks <- unlist(strsplit(input$break_tasks, ","))

Expand Down
3 changes: 2 additions & 1 deletion inst/ext/template.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "A test document"
title: "`r params$filename`"
output:
pagedown::html_paged
knit: pagedown::chrome_print
Expand Down Expand Up @@ -35,6 +35,7 @@ params:
include_design: TRUE
include_int: TRUE
include_participants: TRUE
filename: "filename"
header-logo: "`r system.file('ext/ub_Logo_english_2019_RGB_wb.png', package = 'ctucosting')`"
---

Expand Down

0 comments on commit 32dc082

Please sign in to comment.