How to Update tuicalendr in Shiny?

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:

  1. Click and drag the time block to a different day
  2. Click and drag the bottom of a schedule block to increase/decrease time
  3. 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?


ui <- fluidPage(

server <- function(input, output) {

    output$my_calendar <- renderCalendar({

       ## Create Calendar
        cal <- calendar(
            defaultDate = Sys.Date(),
            useNav = TRUE,
            readOnly = FALSE
        ) %>%
                narrowWeekend = TRUE,
                scheduleFilter = TRUE

        ## Example from README
        cal %>%
                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"
            ) %>%
                beforeUpdateSchedule = JS("function(event) {console.log(event);}")

shinyApp(ui = ui, server = server)


Edit: Removed unrelated shiny template comments from code chunk

This package is in the Experimental phase


An experimental package is in the very early stages of development. The API will be changing frequently as we rapidly iterate and explore variations in search of the best fit. Experimental packages will make API breaking changes without deprecation, so you are generally best off waiting until the package is more mature before you use it. Experimental packages will not be released on CRAN

This means outside expertise is almost certainly thin on the ground. Have you considered contacting the author directly ? There seems to be a single contributor.

1 Like

I did reach out to the maintainer and author that is credited on the pkgdown site on Saturday via Twitter for some possible help, (Victor Perrier and Fanny Meyer to be precise). I wasn't sure if they would be able to respond quickly due to work schedules. I wanted to check with RStudio Community to see if I get some assistance in learning and heading the right direction :grin:

Here is the link to my tweet reaching out to the devs for reference.

I guess the one suggestion I have for you in the meantime is to read up on the use of proxy for DT::datatable which is a very widely used package. Its an assumption but perhaps reasonable that the tuicalendar makers might use it as a model for that functionality.

1 Like

That is an excellent suggestion! I did do some very minor research on proxies that are used within DT and leaflet. I will continue to look into that more. Thanks, @nirgrahamuk!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.