Hello RStudio Community!
I have been exploring the tuicalendr package by dreamRs. I think it is a fantastic R wrapper for the tui.calendar JS library. It has everything I need. My issue is that I personally do not have a lot of JS experience or experience of the idea of proxies in shiny.
With the calendar I want to be able to:
- Click and drag the time block to a different day
- Click and drag the bottom of a schedule block to increase/decrease time
- Click the schedule button and click Edit to update the times with keystrokes
When I run the shiny app (code below) it allows the movement of a schedule block after a click and drag, but after it is moved to a new location it reverts back to its original location (as it should since the data is not being updated). There is a set_events() function that shows me that in the console it is seeing the changes. There are also many cal_proxy_*() functions that seem to be in the direction I want to go. At this time there are no examples of a shiny app that I can find that utilizes this amazing package.
So my question is, what is the best way to get those changes from the calendar into R so it updates the calendar and a method to access the updated data for viewing in a DT or saving to a file?
library(shiny)
library(tuicalendr)
ui <- fluidPage(
calendarOutput("my_calendar")
)
server <- function(input, output) {
output$my_calendar <- renderCalendar({
## Create Calendar
cal <- calendar(
defaultDate = Sys.Date(),
useNav = TRUE,
readOnly = FALSE
) %>%
set_month_options(
narrowWeekend = TRUE,
scheduleFilter = TRUE
)
## Example from README
cal %>%
add_schedule(
calendarId = "courses",
title = "R - introduction",
body = "What is R?",
start = sprintf("%s 08:00:00", Sys.Date()),
end = sprintf("%s 12:30:00", Sys.Date()),
category = "time"
) %>%
set_events(
beforeUpdateSchedule = JS("function(event) {console.log(event);}")
)
})
}
shinyApp(ui = ui, server = server)
Thanks!
Edit: Removed unrelated shiny template comments from code chunk