Skip to content

Commit

Permalink
Merge pull request #11 from rbcavanaugh/fix-double-enter
Browse files Browse the repository at this point in the history
Fix double enter
  • Loading branch information
rbcavanaugh authored Nov 21, 2022
2 parents dca7112 + 43c0a03 commit bd00a0c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 37 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: acom
Title: Aphasia Communication Outcome Measure
Version: 4.0.2
Version: 4.0.3
Date: 2021-10-6
Authors@R:
c(
Expand Down
87 changes: 57 additions & 30 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ app_server <- function( input, output, session ) {
results = d, # table of all items parameters and response columns. loaded from sysdata.rda
num_enters = 0, # for moving to the next item
clarify = NA, # for holding the response to the DNA clarification question
disable_enter = 0
)

##############################################################################
Expand Down Expand Up @@ -128,47 +129,70 @@ app_server <- function( input, output, session ) {
##############################################################################
##############################################################################

observe({
if(v$disable_enter == 0){
shinyjs::enable("enter")
} else if (v$disable_enter == 1) {
shinyjs::disable("enter")
}
})

# Everytime you hit enter
observeEvent(input$enter, {

# Disable the enter button if processing a current response
req(v$disable_enter == 0)
# safeguards againt accepting a response while the model is processing
v$disable_enter = 1

# check that a response was entered. if not, show notification
if (is.null(input$select)) {
shiny::showNotification("Enter a response")
}
# don't go further without a response
req(input$select)

# If you select "Doesn't apply to me" open a modal...
# asks for clarification for a DNA response
if (input$select == "Doesn't apply to me") {
showModal(
modalDialog(
size = "m",
title = "Is this due to your communication difficulties or some other reason?",
div(
align = "center",
style = "margin-top: 24px;",
# yes action button. logic for clicking is below
div(actionButton("yes",
tags$b("Due to my communication difficulties"),
width = "100%"), style="margin:20px;"),
# no action button. logic for clicking is below
div(actionButton("no",
tags$b("Due to some other reason"),
width = "100%"), style="margin:20px;")
),
footer = modalButton("Cancel"),
easyClose = FALSE
)
)
v$disable_enter = 0
} else {
# iterate on the number of times the enter button is selected
# controls also the progression of items
v$num_enters = v$num_enters + 1

# don't go further without a response
req(input$select)

# If you select "Doesn't apply to me" open a modal...
# asks for clarification for a DNA response
if (input$select == "Doesn't apply to me") {
showModal(
modalDialog(
size = "m",
title = "Is this due to your communication difficulties or some other reason?",
div(
align = "center",
style = "margin-top: 24px;",
# yes action button. logic for clicking is below
div(actionButton("yes",
tags$b("Due to my communication difficulties"),
width = "100%"), style="margin:20px;"),
# no action button. logic for clicking is below
div(actionButton("no",
tags$b("Due to some other reason"),
width = "100%"), style="margin:20px;")
),
footer = actionButton("cancel_clarification", "Cancel"),
#modalButton("Cancel"),
easyClose = FALSE
)
)
} else {
# iterate on the number of times the enter button is selected
# controls also the progression of items
v$num_enters = v$num_enters + 1
}
}


})

observeEvent(input$cancel_clarification,{
updateRadioButtons(session, "select", selected = character(0))
removeModal()
v$disable_enter = 0
})

# close the modal when the no button is pressed
observeEvent(input$no, {
Expand Down Expand Up @@ -245,6 +269,9 @@ app_server <- function( input, output, session ) {
v$i = v$i + 1 # iterate on the item number
v$itnum = cat_data$next_item # this is the next item
v$clarify = NA # reset clarify to NA
v$disable_enter = 0


}

})
Expand Down
2 changes: 1 addition & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ app_ui <- function(request) {

################################### layout starts here #########################

navbarPage(title = span("acom", span("v4.0.2", style = "font-size:0.8em;color:grey;")), # App title
navbarPage(title = span("acom", span("v4.0.3", style = "font-size:0.8em;color:grey;")), # App title
id = "mainpage", # id of page so you can access current page with input$mainpage
theme = minimal_theme(), # theme function from {bslib}. see theme.R

Expand Down
3 changes: 2 additions & 1 deletion dev/run_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ run_app()
# change version in DESCRIPTION FILE
# change version in README
# change version in CITATION x2
# change tag on github
# change tag on github
# report file
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bibentry(bibtype = "misc",
title = "acom: The Aphasia Communication Outcome Measure. Version 4.0.2",
title = "acom: The Aphasia Communication Outcome Measure. Version 4.0.3",
author=c(person("Robert", "Cavanaugh"), person("Alexander M", "Swiderski"), person("William D", "Hula")),
year = 2022,
url = "https://github.com/rbcavanaugh/acom",
textVersion = paste("Cavanaugh, R., Swiderski, A.M., Hula, W.D. (2022). acom: The Aphasia Communication Outcome Measure. Version 4.0.2", "Available from https://github.com/rbcavanaugh/acom.", sep=" "),
textVersion = paste("Cavanaugh, R., Swiderski, A.M., Hula, W.D. (2022). acom: The Aphasia Communication Outcome Measure. Version 4.0.3", "Available from https://github.com/rbcavanaugh/acom.", sep=" "),
mheader = "To cite in publications use:")
2 changes: 1 addition & 1 deletion inst/report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ knitr::kable(table1, booktabs = TRUE, col.names = NULL)

This report was downloaded on `r params$dt` and generated by the ACOM shiny web app located at https://rb-cavanaugh.shinyapps.io/acom/. This web-app is open source and the source code is located at https://github.com/rbcavanaugh/acom. Comments, feedback, and bug-reports can be made on the github page: https://github.com/rbcavanaugh/acom/issues.

The app can be cited as: Cavanaugh, R., Swiderski, A.M., Hula, W.D. (2022). acom: The Aphasia Communication Outcome Measure. Version 4.0.0 Available from https://github.com/rbcavanaugh/acom.
The app can be cited as: Cavanaugh, R., Swiderski, A.M., Hula, W.D. (2022). acom: The Aphasia Communication Outcome Measure. Version 4.0.3 Available from https://github.com/rbcavanaugh/acom.

```{r, echo = F}
shiny::setProgress(0.9)
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A description of the psychometric characteristics of the current version of the

Comments, feedback, and bug reports are encouraged. Please submit as an issue: https://github.com/rbcavanaugh/acom/issues

Citation: Cavanaugh, R., Swiderski, A.M., Hula, W.D. (2022). acom: The Aphasia Communication Outcome Measure. Version 4.0.2, Available from https://github.com/rbcavanaugh/acom.
Citation: Cavanaugh, R., Swiderski, A.M., Hula, W.D. (2022). acom: The Aphasia Communication Outcome Measure. Version 4.0.3, Available from https://github.com/rbcavanaugh/acom.

### Installing & Using the application

Expand Down

0 comments on commit bd00a0c

Please sign in to comment.