zotero/zotero — pull request #353 by aurimasv (2013-07-27 09:47:22+00:00)
Title: Tweaks to collections on import

* Use itemID for mapping items to collections on import
Not entirely sure why there was such an implicit distinction between itemID for items and id when adding collections. For an example, see http://www.zotero.org/support/dev/translators/coding#creating_collections

This would now be:
```
var item = new Zotero.Item("book");
item.itemID = "my-item-id"; // any string or number
item.complete();

var collection = new Zotero.Collection();
collection.name = "Test Collection";
collection.type = "collection"; //it's also not clear to me why this is not set automatically in the Zotero.Collections constructor
collection.children = [item];
collection.complete();
```

* Don't add all items to base collection on import
I never really noticed the problem here, because I always use recursive collections. But basically, if somebody's organization strategy involves having uncatergorized items in the root of the library (or a collection that is being exported), when importing those items would be mixed in with the items in subcollections.

I don't particularly like the idea of performing and additional DB lookup for every single item that's being imported, but I don't currently have a better solution. I was going to keep track of items that are being assigned to collections in the "collectionDone" handler, but unfortunately there is no way to map items between those passed to `collection.complete` and those that are in the translator object passed to the "done" handler. My initial attempt was to use itemID, but itemID is not preserved when the item is saved and is actually internally redirected to `item.id`.