toastui icon indicating copy to clipboard operation
toastui copied to clipboard

How to print all the data inside of calendar?

Open agronomofiorentini opened this issue 3 years ago • 6 comments

Dear Creators, I actually tried different ways in order to print all the schedules/data inside of the calendar, but i couldn't find a solution.

Could you help me?

library(shiny)
library(toastui)

ui <- fluidPage(
  titlePanel("Calendar Toastui exemple to save data"),
  
  sidebarLayout(
    sidebarPanel(
    ),
    
    mainPanel(
      radioButtons(
        inputId = "view",
        label = "Change view:",
        choices = c("day", "week", "month"),
        inline = TRUE
      ),
      calendarOutput("my_calendar"),
      actionButton("save_calendar",
                   "Save calendar",
                   icon = icon("cloud-upload-alt"))
    )
  )
)

server <- function(input, output, session) {
  
  output$my_calendar<-renderCalendar({
    
    calendar(cal_demo_data(), 
             view = "month",
             taskView = TRUE,
             useCreationPopup = TRUE,
             useNavigation = TRUE,
             navigation = TRUE,
             isReadOnly = FALSE) %>%
      
      cal_month_options(startDayOfWeek  = 1, 
                        narrowWeekend = TRUE)
    
  })

  observeEvent(input$my_calendar_add, {
    str(input$my_calendar_add)
    cal_proxy_add("my_calendar", input$my_calendar_add)
  })
  
  observeEvent(input$my_calendar_update, {
    str(input$my_calendar_update)
    cal_proxy_update("my_calendar", input$my_calendar_update)
  })
  
  observeEvent(input$my_calendar_delete, {
    str(input$my_calendar_delete)
    cal_proxy_delete("my_calendar", input$my_calendar_delete)
  })
  
  observeEvent(
    input$view,
    cal_proxy_view("my_calendar", input$view),
    ignoreInit = TRUE
  )
  
  observeEvent(input$save_calendar, {
    print(input$my_calendar_data)
  })
  
}

shinyApp(ui = ui, server = server)

agronomofiorentini avatar Jan 22 '22 18:01 agronomofiorentini

I have modified the previouse lines

  observeEvent(input$save_calendar, {
    print(input$my_calendar_data)
  })

with the follow one

  observeEvent(input$save_calendar, {
    print(input$my_calendar_schedules)
  })

and now it prints out one schedule and not all the schedules.

I Would like to get a dataframe with all the information contained insiede the calendar. it is that possible?

Thanks.

agronomofiorentini avatar Jan 25 '22 07:01 agronomofiorentini

No currently there's no method to retrieve all schedules at once. You have to watch on input$outputId_add to get schedules added, input$outputId_delete for schedules deleted and input$outputId_update for change on a schedule.

Note that it's recommended to add a custom ID to schedule before adding them, with something like

new <- input$my_calendar_add
new$id <- "ID" # generate unique ID here
cal_proxy_add("my_calendar", new)

Otherwise a random ID is added and you won't be able to identify schedules deleted or updated.

Let me know how it works for you, I can implement something but not immediately.

Victor

pvictor avatar Jan 26 '22 16:01 pvictor

Thanks a lot for your tip, i will take it all.

I have implemented a postgres database as backend in order to keep track the user change, such as add, delete and update.

But every time that the user will add, update and delete the calendar, the application must connect to the database in order to keep track of the user change.

It is working, but of course it will be great to have a function or a way to get all the schedules at once and write it into the database.

I will wait the implementation of such good tool.

agronomofiorentini avatar Jan 27 '22 08:01 agronomofiorentini

Hi there, Any news related to this issue?

Thanks, Marco

agronomofiorentini avatar Mar 15 '22 18:03 agronomofiorentini

i am sorry to bother you again, i would like to know if there are some updates for this issue

Thanks again

agronomofiorentini avatar May 26 '22 12:05 agronomofiorentini

This feature does not exist in the JavaScript library and will not be implemented, but you can always ask (see https://github.com/nhn/tui.calendar/issues/872) And I don't have the time or the need to implement it myself. I still think that's better to write to the database each time an entry is added or deleted, it limits the risks of information loss in case of application crash or unexpected disconnection.

pvictor avatar Jun 01 '22 15:06 pvictor