showModal(
if(length(input$table_substance_routine_rows_selected) == 1) {
# edit_routine_modal.R and edit_routine_confirmed.R should match
id_to_edit <- table_substance_routine_data()[input$table_substance_routine_rows_selected, ] |>
pull(Id)
# Existing values
edited_row <- table_substance_routine_data() |> filter(Id == id_to_edit)
days <- edited_row$Days
substance <- edited_row$Substance
frequency <- edited_row$Frequency
if(input$all_substances) {
choices <- substances |>
prepare_choices(name_short_html, name_short_html, group)
}
if(! input$all_substances) {
choices <- substances_names_grouped()
}
modalDialog(
title = "Edit Record",
virtualSelectInput(
"edit_routine_days",
"Days of the Week:",
choices = days_of_the_week,
selected = stringr::str_split(days, ", ")[[1]],
multiple = TRUE
),
virtualSelectInput(
"edit_routine_substance",
"Substance:",
choices = choices,
selected = substance,
disableOptionGroupCheckbox = TRUE,
optionsCount = 8,
html = TRUE
),
virtualSelectInput(
"edit_routine_frequency",
"Frequency:",
choices = 1:100,
selected = frequency
),
footer = tagList(
modalButton("Cancel"),
actionButton("edit_routine_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.