Giter Club home page Giter Club logo

Comments (3)

pvictor avatar pvictor commented on June 11, 2024 1

Hello @KoderKow ,

Thanks for openning the issue. I made some changes in the code to make possible to edit schedules, so please re-install the package with :

remotes::install_github("dreamRs/tuicalendr")

After that you can try the following example where you can create and edit schedules interactively :

library(shiny)
library(tuicalendr)

ui <- fluidPage(
  tags$h2("Create and edit schedule"),
  fluidRow(
    column(
      width = 9,
      calendarOutput("my_calendar")
    ),
    column(
      width = 3,
      uiOutput("schedule_update")
    )
  )
)

server <- function(input, output) {
  
  output$my_calendar <- renderCalendar({
    cal <- calendar(
      defaultDate = Sys.Date(),
      useNav = TRUE,
      readOnly = FALSE,
      useCreationPopup = TRUE
    ) %>%
      set_month_options(narrowWeekend = TRUE) %>%
      add_schedule(
        id = "r_intro",
        calendarId = "courses",
        title = "R - introduction",
        body = "What is R?",
        start = paste(Sys.Date(), "08:00:00"),
        end = paste(Sys.Date(), "12:30:00"),
        category = "time"
      )
  })
  
  output$schedule_update <- renderUI({
    if (!is.null(input$my_calendar_update)) {
      changes <- input$my_calendar_update$changes
      tags$div(
        "Schedule",
        tags$b(input$my_calendar_update$schedule$id),
        "have been updated with:",
        tags$ul(
          lapply(
            seq_along(changes),
            function(i) {
              tags$li(
                tags$b(names(changes)[i], ":"),
                changes[[i]]
              )
            }
          )
        )
      )
    }
  })
  
  observeEvent(input$my_calendar_add, {
    cal_proxy_create(
      proxy = "my_calendar",
      .list = input$my_calendar_add
    )
  })
  
  observeEvent(input$my_calendar_update, {
    cal_proxy_update(
      proxy = "my_calendar",
      .list = input$my_calendar_update
    )
  })
  
}

# Run the application
shinyApp(ui = ui, server = server)

Careful I changed the name of shiny input generated by the package ! (in example I send you earlier there was an input input$<ID>_schedule_add now it's just input$<ID>_add)

I plan to write a vignette to explain usage in shiny apps, but been a little busy. Don't hesitate to open issue, or share what can be better in the package.

Victor

from tuicalendr.

KoderKow avatar KoderKow commented on June 11, 2024

@pvictor Wow thank you so much for doing the updates and for providing an example! This is so cool!

I have it all working on my machine. My last remaining question is what is the most efficient way of presenting the data in either a data table within the shiny app or either saving the new data or rewriting.

I currently have 1000+ schedule entries on a calendar. I tried looking into the different input$... available but I could not find a way to extract the data from the calendar. I looked at str(cal) and I can see the data. How do I navigate to that?

from tuicalendr.

pvictor avatar pvictor commented on June 11, 2024

There's currently no method to retrieve all schedules from calendar, in my mind it was best to add entries when input$my_calendar_add is triggered, and update entries when input$my_calendar_update is triggered, like that you control what users add or modify in your calendar.

from tuicalendr.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.