-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I save the modifications ? #5
Comments
Hopefully I can get For reference, are you using in |
I think it would be nice to save the output as an R object. I would imagine a syntax like :
where |
what is the status of that? |
@jangorecki, I think this would be a perfect application of Shiny gadgets, but I hesitate to spend a lot of time on it given this discussion in r-lib/lobstr#2. It is relatively easy to get the return value from |
I've just discovered this lovely package but my use case cannot be fulfilled without being able to save the output after modifications. I'll confess and say that I don't understand the lobstr thread timelyportfolio has linked to. This issue currently stands open but the indication is that it isn't going to be solved. Would it be possible to get a little more clarity on whether this will be addressed or not? |
Just after I submitted to CRAN I added this https://github.com/timelyportfolio/listviewer/blob/master/R/jsonedit_gadget.R. See if it works for you. |
I've just had a little play with the example at listviewer/inst/examples/examples_gadget.R and yes, so far I seem to be able to capture an output. It would be interesting if there were a way to "continuously" update a destination object, so each change that was made immediately writes to an object, rather than having to click "Done" and ending the mini shiny session. But for now I think I can do what I need to do. Thank you very much for this nice development, it'll definitely be useful for me! |
Posting a JavaScript workaround I am using in Shiny. Ideally, I think there would be a way to specify an "inputId" on Note - this example returns the JSON object back to the server at every change, thereby allowing for notifications, warnings, etc. if comparing to a Schema object, etc. library(shiny)
library(listviewer)
library(shinyjs)
jsCode <- "shinyjs.updatejsed = function(){
var txt = HTMLWidgets.findAll('.jsonedit').filter(function(item){return item.editor.container.id === 'jsed'})[0].editor.getText();
console.log(txt);
Shiny.onInputChange('jseddata',txt)
}"
ui <- shinyUI(
fluidPage(
useShinyjs()
, actionButton('update','Update Data')
, extendShinyjs(text=jsCode)
, jsoneditOutput( "jsed" )
, verbatimTextOutput('jsedtext')
, jsoneditOutput( 'jsed2')
, verbatimTextOutput('jsed2text')
)
)
server <- function(input,output){
observe(print(input$jsed2data))
output$jsed <- renderJsonedit({
jsonedit(
'{"a":[]}'
,"onChange" = htmlwidgets::JS('shinyjs.updatejsed'))
})
observeEvent(input$update, {shinyjs::js$updatejsed()})
output$jsedtext <- renderText(input$jseddata)
output$jsed2 <- renderJsonedit({
jsonedit(
'{"b":[]}'
,"onChange" = htmlwidgets::JS("() => {
var txt = HTMLWidgets.findAll('.jsonedit').filter(function(item){return item.editor.container.id === 'jsed2'})[0].editor.getText()
console.log(txt)
Shiny.onInputChange('jsed2data',txt)
}")
)
})
output$jsed2text <- renderText(input$jsed2data)
}
runApp( list( ui = ui, server = server ) ) Happy to help contribute to the resolution of this issue, if there is still interest and a desire to maintain this package (which I also find incredibly useful). Thanks! EDIT: If using within a shiny module, it looks like using ns may need to be done on generation of the string. Full disclosure: I have not tested EDIT2: the "onChange" handler unfortunately does not set the initial value of the data (notice that clicking the "Update Button" is required). I have worked around this using |
The new |
That's a very nice editor but I don't understand how I can save the modification in an R object.
The text was updated successfully, but these errors were encountered: