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

Small fixes #85

Merged
merged 7 commits into from
Nov 4, 2023
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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Imports:
markdown,
lifecycle,
rlang,
stats
stats,
fontawesome
RoxygenNote: 7.2.3
Suggests:
testthat,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(mod_title_page_server)
export(mod_title_page_ui)
export(mod_xml_report_server)
export(mod_xml_report_ui)
export(print_conflict_statement)
export(print_contrib_affil)
export(print_credit_roles)
export(print_funding)
Expand Down
3 changes: 3 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ app_server <- function(input, output,session) {
# Show funding information in viewer window
mod_funding_information_server("funding_information", input_data = read_out$data)

# Show conflict of interest statement
mod_conflict_statement_server("conflict_statement", input_data = read_out$data)

# Hide on launch waiter screen
waiter::waiter_hide()
}
34 changes: 21 additions & 13 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ app_ui <- function() {
golem_add_external_resources(),

navbarPage(
# Header
header = tagList(
div(id = "support-div",
a(id = "support-btn",
class = "btn",
href = "https://opencollective.com/tenzing",
target = "_blank",
"Support us",
)
)
),
# Title
title = list(
div(
Expand All @@ -30,7 +41,7 @@ app_ui <- function() {
div(
class = "help-icon-container",
title = "Copy the contributors table template in Google Drive. Go to File -> Make a copy",
icon("far fa-question-circle", lib = "font-awesome", class = "help-icon")
fontawesome::fa_i(name = "fas fa-circle-question", style = "color: #D45F68; font-size: 2em;")
)
),
wellPanel(
Expand All @@ -40,7 +51,8 @@ app_ui <- function() {
tags$a(href = "https://docs.google.com/spreadsheets/d/1Gl0cwqN_nTsdFH9yhSvi9NypBfDCEhViGq4A3MnBrG8/edit?usp=sharing",
"contributors table template",
target="_blank",
style = "display: inline; color: #ffdf57; text-decoration: underline;")
style = "display: inline; color: #ffdf57; text-decoration: underline;",
class = "link")
)
),
# Second step
Expand All @@ -55,7 +67,7 @@ app_ui <- function() {
div(
class = "help-icon-container",
title = "Use the share URL of the filled out contributors table and click on the upload button. OR upload your contributors table in a .csv, .tsv or .xlsx format.",
icon("far fa-question-circle", lib = "font-awesome", class = "help-icon")
fontawesome::fa_i(name = "fas fa-circle-question", style = "color: #D45F68; font-size: 2em;")
)
),
wellPanel(
Expand All @@ -76,7 +88,7 @@ app_ui <- function() {
div(
class = "help-icon-container",
title = "You need a valid contributors table to generate the outputs. Once you have it, click on one of the output buttons to preview and download the output.",
icon("far fa-question-circle", lib = "font-awesome", class = "help-icon")
fontawesome::fa_i(name = "fas fa-circle-question", style = "color: #D45F68; font-size: 2em;")
)
),
wellPanel(
Expand All @@ -85,21 +97,17 @@ app_ui <- function() {
mod_title_page_ui("title_page"),
mod_xml_report_ui("xml_report"),
mod_show_yaml_ui("show_yaml"),
mod_funding_information_ui("funding_information")
mod_funding_information_ui("funding_information"),
mod_conflict_statement_ui("conflict_statement")
)
),
# Citation
HTML(
"<p><b>Citation:</b></br>
Kovacs, M., Holcombe, A., Aust, F., & Aczel, B. (2021). <a href='https://doi.org/10.3233/ISU-210109'; target='_blank'>Tenzing and the importance of tool development for research efficiency.</a> <i>Information Services & Use, 41</i>, 123-130.
<BR>
Holcombe, A. O., Kovacs, M., Aust, F., & Aczel, B. (2020). <a href='https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0244611'; target='_blank'>Documenting contributions to scholarly articles using CRediT and tenzing.</a> <i>PLOS ONE, 15</i>(12), e0244611.</p>"
Kovacs, M., Holcombe, A., Aust, F., & Aczel, B. (2021). <a href='https://doi.org/10.3233/ISU-210109'; target='_blank'>Tenzing and the importance of tool development for research efficiency.</a> <i>Information Services & Use, 41</i>, 123-130.
<BR>
Holcombe, A. O., Kovacs, M., Aust, F., & Aczel, B. (2020). <a href='https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0244611'; target='_blank'>Documenting contributions to scholarly articles using CRediT and tenzing.</a> <i>PLOS ONE, 15</i>(12), e0244611.</p>"
),
# Donation
HTML(
"<p><b>Donation:</b></br>
<a href='https://opencollective.com/tenzing'; target='_blank'>Open Collective</a></p>"
),
# Privacy notice
HTML("<p><b>Privacy:</b><BR>
To get a sense of how many users we have, we log a masked version of IP addresses. You are not identifiable by the logged information.</p>")
Expand Down
154 changes: 154 additions & 0 deletions R/mod_conflict_statement.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#' conflict_statement UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_conflict_statement_ui <- function(id){

tagList(
div(class = "out-btn",
actionButton(
NS(id, "show_report"),
label = "Show conflict of interest statement",
class = "btn btn-primary btn-validate")
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click show', 'Conflict information'])"
)
)
}

#' conflict_statement Server Function
#'
#' @noRd
mod_conflict_statement_server <- function(id, input_data){

moduleServer(id, function(input, output, session) {
ns <- session$ns
# Preview ---------------------------
## Render preview
output$preview <- renderUI({
if(all(is.na(input_data()[["Conflict of interest"]]))) {
"There are no conflict of interest statements provided for any of the contributors."
} else {
HTML(print_conflict_statement(contributors_table = input_data(), initials = input$initials))
}
})

## Build modal
modal <- function() {
modalDialog(
rclipboard::rclipboardSetup(),
h3("Conflict of interest statement"),
# Toggle between initials and full names
div(
shinyWidgets::materialSwitch(
NS(id, "initials"),
label = "Full names",
inline = TRUE),
span("Initials")
),
hr(),
uiOutput(NS(id, "preview")),
easyClose = TRUE,
footer = tagList(
div(
style = "display: inline-block",
uiOutput(session$ns("clip"))
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click clip', 'Conflict information'])"
),
div(
style = "display: inline-block",
downloadButton(
NS(id, "report"),
label = "Download file",
class = "download-report"
)
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click download', 'Conflict information'])"
),
modalButton("Close")
)
)
}

## Show preview modal
observeEvent(input$show_report, {
showModal(modal())
})

# Download ---------------------------
## Set up loading bar
waitress <- waiter::Waitress$new(theme = "overlay", infinite = TRUE)

## Restructure dataframe for the output
to_download_and_clip <- reactive({
if(all(is.na(input_data()[["Funding"]]))) {
"There are no conflict of interest statements provided for any of the contributors."
} else {
print_conflict_statement(contributors_table = input_data(), initials = input$initials)
}
})

## Set up parameters to pass to Rmd document
params <- reactive({
list(conflict_statement = to_download_and_clip())
})

## Render output Rmd
output$report <- downloadHandler(
# Set filename
filename = function() {
paste0("conflict_statement_", Sys.Date(), ".doc")
},
# Set content of the file
content = function(file) {
# Start progress bar
waitress$notify()
# Copy the report file to a temporary directory before processing it
file_path <- file.path("inst/app/www/", "conflict_statement.Rmd")
file.copy("conflict_statement.Rmd", file_path, overwrite = TRUE)

# Knit the document
callr::r(
render_report,
list(input = file_path, output = file, format = "word_document", params = params())
)
# Stop progress bar
waitress$close()
}
)

# Clip ---------------------------
## Add clipboard buttons
output$clip <- renderUI({
rclipboard::rclipButton(
inputId = "clip_btn",
label = "Copy output to clipboard",
clipText = to_download_and_clip(),
icon = icon("clipboard"),
modal = TRUE)
})

## Workaround for execution within RStudio version < 1.2
observeEvent(input$clip_btn, clipr::write_clip(to_download_and_clip()))
})

}

## To be copied in the UI
# mod_conflict_statement_ui("conflict_statement")

## To be copied in the server
# mod_conflict_statement_server("conflict_statement")

32 changes: 24 additions & 8 deletions R/mod_credit_roles.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod_credit_roles_ui <- function(id){
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click show', 'Author information'])"
)
)
)
}

Expand Down Expand Up @@ -80,12 +80,23 @@ mod_credit_roles_server <- function(id, input_data){
div(
style = "display: inline-block",
uiOutput(session$ns("clip"))
),
downloadButton(
NS(id, "report"),
label = "Download file",
class = "download-report"
),
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click clip', 'Author information'])"
),
div(
style = "display: inline-block",
downloadButton(
NS(id, "report"),
label = "Download file",
class = "download-report"
)
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click download', 'Author information'])"
),
modalButton("Close")
)
)
Expand Down Expand Up @@ -154,7 +165,12 @@ mod_credit_roles_server <- function(id, input_data){

## Add clipboard buttons
output$clip <- renderUI({
rclipboard::rclipButton("clip_btn", "Copy output to clipboard", to_clip(), icon("clipboard"), modal = TRUE)
rclipboard::rclipButton(
inputId = "clip_btn",
label = "Copy output to clipboard",
clipText = to_clip(),
icon = icon("clipboard"),
modal = TRUE)
})

## Workaround for execution within RStudio version < 1.2
Expand Down
34 changes: 27 additions & 7 deletions R/mod_funding_information.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ mod_funding_information_ui <- function(id){
NS(id, "show_report"),
label = "Show funding information",
class = "btn btn-primary btn-validate")
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click show', 'Funding information'])"
)
)
}
Expand Down Expand Up @@ -56,12 +60,23 @@ mod_funding_information_server <- function(id, input_data){
div(
style = "display: inline-block",
uiOutput(session$ns("clip"))
),
downloadButton(
NS(id, "report"),
label = "Download file",
class = "download-report"
),
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click clip', 'Funding information'])"
),
div(
style = "display: inline-block",
downloadButton(
NS(id, "report"),
label = "Download file",
class = "download-report"
)
) %>%
tagAppendAttributes(
# Track click event with Matomo
onclick = "_paq.push(['trackEvent', 'Output', 'Click download', 'Funding information'])"
),
modalButton("Close")
)
)
Expand Down Expand Up @@ -117,7 +132,12 @@ mod_funding_information_server <- function(id, input_data){
# Clip ---------------------------
## Add clipboard buttons
output$clip <- renderUI({
rclipboard::rclipButton("clip_btn", "Copy output to clipboard", to_download_and_clip(), icon("clipboard"), modal = TRUE)
rclipboard::rclipButton(
inputId = "clip_btn",
label = "Copy output to clipboard",
clipText = to_download_and_clip(),
icon = icon("clipboard"),
modal = TRUE)
})

## Workaround for execution within RStudio version < 1.2
Expand Down
Loading
Loading