www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 063ba1de5e6776c3c47f1f8210a84c0d09c41f01
parent 44ac61c33ed88da6fbe27bc57092df48ce5e6b71
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 13 Jan 2012 18:11:00 -0500

Undelete linked item automatically when redragging item to a library

Unlike with Restore to Library, the linked item is first removed from
any collections, so it only ends up in the library root and, if
applicable, the target collection.

Diffstat:
Mchrome/content/zotero/xpcom/collectionTreeView.js | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1242,7 +1242,7 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData) } var linkedItem = item.getLinkedItem(itemGroup.ref.libraryID); - if (linkedItem) { + if (linkedItem && !linkedItem.deleted) { // For drag to root, skip if linked item exists if (itemGroup.isLibrary(true)) { continue; @@ -1373,6 +1373,18 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient) // Check if there's already a copy of this item in the library var linkedItem = item.getLinkedItem(targetLibraryID); if (linkedItem) { + // If linked item is in the trash, undelete it + if (linkedItem.deleted) { + // Remove from any existing collections, or else when it gets + // undeleted it would reappear in those collections + var collectionIDs = linkedItem.getCollections(); + for each(var collectionID in collectionIDs) { + var col = Zotero.Collections.get(collectionID); + col.removeItem(linkedItem.id); + } + linkedItem.deleted = false; + linkedItem.save(); + } return linkedItem.id; /*