I want to be able to have the items in my sortable list copied after I move them from the original list. I know this is easy to do with sortable_JS() using pull = 'copied', but I like some of the functions of the Sortable Shiny add_rank_list() more (eg, the heights of the 'drag_from' and 'drag_to' boxes are always the same with add_rank_list()) and so far pull = 'copied' inside options = sortable_options(group = list()) hasn't worked for me while using add_rank_list(). I have my best attempt in my MRE, but I'm not very familiar with JS and I am likely missing something important. In fact, it might not be possible to use the R package in this way for all I know.
I'm happy to use sortable_JS, but I figured I would ask this question since I haven't found a workable answer after a day or so of searching. Thanks!
Here is my MRE:
library(shiny)
library(sortable)
ui <- fluidPage(
tags$head(
tags$style(HTML(".bucket-list-container {min-height: 350px;}"))
),
fluidRow(
column(
tags$b(""),
width = 12,
bucket_list(
header = "Drag the items in any desired bucket",
group_name = "bucket_list_group",
orientation = "horizontal",
add_rank_list(
text = "Analysis functions bank",
labels = list("Total movement in a phase",
"Movement after a phase",
"Freezing score",
"Movement during transtion between phases",
"Difference in movement between two select phases, total phase",
"Difference in movement between two select phases, first 30 seconds",
"Difference of first 30 sec light and 30 sec dark",
"Habituation",
"Changes in habituation between two phases, total",
"Linear regession"
),
input_id = "func_bank",
options = sortable_options(
multiDrag = FALSE,
#onRemove = htmlwidgets::JS("document.getElementById('func_bank').appendChild(document.getElementById('func_bank').this.item.cloneNode(true));"),
onAdd = htmlwidgets::JS("function (evt) { this.el.removeChild(evt.item); }")
)
),
add_rank_list(
text = "Selected analysis functions",
labels = NULL,
input_id = "select_funcs",
options = sortable_options(
multiDrag = FALSE
)
)
)
)
),
fluidRow(
column(
width = 12,
tags$b("Result"),
column(
width = 12,
tags$p("input$bucket_list_group"),
verbatimTextOutput("selected_funcs")
)
)
)
)
server <- function(input,output) {
output$selected_funcs <- renderPrint({ input$bucket_list_group })
}
shinyApp(ui, server)