showModal(
if(length(input$table_substance_period_rows_selected) == 1) {
# edit_table_modal.R and edit_table_confirmed.R index_subset should match.
index_subset <- timevis_data_cal() |>
mutate(test = (period %in% c("Pre-LMP", "Post-LMP", "Last Week", "Last Two Weeks Before Delivery") & what == "Substance")) |>
pull(test) |>
which()
edited_row <- timevis_data_cal()[index_subset[input$table_substance_period_rows_selected], ]
# Date
value <- edited_row$start
if(edited_row$period == "Pre-LMP") {
min <- dates_study()$P1[1]
max <- dates_study()$P1[2]
}
if(edited_row$period == "Post-LMP") {
min <- dates_study()$P2[1]
max <- dates_study()$P2[2]
}
if(edited_row$period == "Last Week") {
min <- dates_study()$P3[1]
max <- dates_study()$P3[2]
}
if(edited_row$period == "Last Two Weeks Before Delivery") {
min <- dates_study()$P4[1]
max <- dates_study()$P4[2]
}
# Event
event <- edited_row$event
# Substance
substance <- edited_row$substance
# Frequency
frequency <- edited_row$frequency
modalDialog(
title = "Edit Record",
dateInput(
"edit_start",
"Date:",
value = value,
min = min,
max = max),
virtualSelectInput(
"edit_substance",
"Substance:",
choices = substances_names_grouped(),
selected = substance,
disableOptionGroupCheckbox = TRUE,
optionsCount = 8,
html = TRUE
),
virtualSelectInput(
"edit_frequency",
"Frequency:",
choices = 1:100,
selected = frequency
),
footer = tagList(
modalButton("Cancel"),
actionButton("edit_table_confirmed", "Confirm")
),
easyClose = TRUE)
} else
{
modalDialog(
title = "Warning",
"Select a row that you want to edit",
easyClose = TRUE
)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.