I've been using the awesome shinyjqui
app and want to customize it just a little.
The function order_input
allows you to drag a block from the source to the destination multiple times, but doesn't let you delete blocks [by dragging the block back to the source].
The function jqui_sortable
creates draggable components that can be dragged both ways, but once the block is removed from the source it isn't cloned and only lives in the destination.
I was hoping to:
- Expand on the
jqui_sortable
function using some of the logic of theorder_input
function so when a block is dragged, another one is populated in the source area (like theorder_input
block. - Because the block would be cloned in the source, I would also would like to expand on the code so that dragging the block back from the destination to the source would just delete the block.
Is this possible? I opened an issue here where I think the code might live to make this possible but I'm struggling to implement it. Any help appreciated!!!
library(shiny)
library(shinyjs)
ui <- fluidPage(
sidebarPanel(
fluidRow(column(4, h5("Drag Once"),
jqui_sortable(div(id = "source", div("Block",
style="background-color:grey;text-align:center;color:white;box-shadow: 0 0 10px rgba(0, 0, 0, 0.7)"),
style = "border: 1px solid black;padding:10px;min-height:50px;"),
options = list(connectWith = "#dest", helper = "clone"))),
column(4, h5("Put Here"),
jqui_sortable(div(id = "dest", style = "border: 1px solid black;padding:10px;min-height:50px"),
options = list(connectWith = "#source"))),
# this one I can drag multiple times if we set source = TRUE
# but you can't drag back to the 'dest'
# can we use this clone logic in the jqui_sortable code somehow?
column(4,
orderInput('drag_multiple', "Drag Multiple", items = "Block",
as_source = TRUE, connect = 'dest'))
)
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)