rstudio / sortable

R htmlwidget for Sortable.js
https://rstudio.github.io/sortable/
Other
130 stars 30 forks source link

Experiment with different API for `bucketable_list` #20

Open andrie opened 5 years ago

andrie commented 5 years ago

Continued from #17 .

The current API is:

bucketable_list(
  text = "This is a bucketable list. You can drag items between the lists.",
  group_name = "bucketable",
  add_sortable_list(
    text = "Drag from here",
    labels = c("a", "bb", "ccc")
  ),
  add_sortable_list(
    text = "to here",
    labels = NULL
  )
)

It would be useful to be able to insert any object into the bucketable_list, so the API becomes:

bucketable_list(
  text = "",
  ...
)

Where the ... can be replaced by one or more sortable_list() calls.

This would require either:

  1. intercept the call and modify the call, or
  2. modify the (deeply nested) list constructed by sortable_list().

I experimented with both approaches and came to the conclusion:

  1. is dangerous, because the user may have constructed the call in any of a number of ways
  2. is very difficult, since the underlying structure of the sortable_list can easily change in future versions, so knowing exactly where to modify the list is hard.

@schloerke is going to look at this.