Skip to content
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

items_create ignores multiple parents #242

Open
aappling-usgs opened this issue Jul 6, 2017 · 2 comments
Open

items_create ignores multiple parents #242

aappling-usgs opened this issue Jul 6, 2017 · 2 comments
Assignees
Labels

Comments

@aappling-usgs
Copy link
Contributor

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.

@lindsayplatt
Copy link
Contributor

used in the DL curriculum, so would be good to fix

@aappling-usgs
Copy link
Contributor Author

Seems reasonable to me. @lindsaycarr , you up for taking this one?

@dblodgett-usgs dblodgett-usgs self-assigned this Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants