-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
I want the following code to create the following items under user_id():
* bigitem
* item 1
* item 2
* top-level item
Here's the code:
new_folder <- item_create(title='bigitem')
add_mult <- items_create(
parent_id = c(new_folder$id, new_folder$id, user_id()),
title = c("item 1", "item 2", "top-level item"))What I get is three items nested under bigitem instead of bigitem and 'top-level item' being siblings:
* bigitem
* item 1
* item 2
* top-level item
I think this is a bug, and I think it's due to a faulty else option in this line: https://github.com/USGS-R/sbtools/blob/master/R/items_create.R#L61. Rather than the current line,
item <- if (length(item) == 1) rep(item[[1]]$id, length(title)) else item[[1]]$id I suggest this:
item <- if (length(item) == 1) rep(item[[1]]$id, length(title)) else sapply(item, function(i) i$id) followed by some testing to make sure the change actually permits multiple parents for multiple items.