commit 9c0ad6517250d9fb38c20b4005acb5e398ed66d9
parent b3d5136c34426f899fdf807329d0496bb4e5ca53
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 8 Aug 2009 13:21:02 +0000
Fix "Invalid integer value 'null'" error when dragging a regular item and a top-level attachment between libraries, which shouldn't have been allowed
Diffstat:
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js
@@ -995,10 +995,11 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData)
if (dataType == 'zotero/item') {
var ids = data;
var items = Zotero.Items.get(ids);
+ var skip = true;
for each(var item in items) {
// Can only drag top-level items
- if (!(item.isRegularItem() || !item.getSource())) {
- continue;
+ if (!item.isTopLevelItem()) {
+ return false
}
// TODO: for now, only allow regular items to be dragged to groups
@@ -1009,36 +1010,41 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData)
// TODO: for now, skip items that are already linked
if (itemGroup.isWithinGroup() && itemGroup.ref.libraryID != item.libraryID) {
- if (item.getLinkedItem(itemGroup.ref.libraryID)) {
- continue;
+ if (!item.getLinkedItem(itemGroup.ref.libraryID)) {
+ skip = false;
}
+ continue;
}
if (itemGroup.isGroup()) {
// Don't allow drag onto library of same group
if (itemGroup.ref.libraryID == item.libraryID) {
- continue;
+ return false;
}
- return true;
+ continue;
}
// Allow drag of group items to library
if (item.libraryID && (itemGroup.isLibrary()
|| itemGroup.isCollection() && !itemGroup.isWithinGroup())) {
// TODO: for now, skip items that are already linked
- if (item.getLinkedItem()) {
- continue;
+ if (!item.getLinkedItem()) {
+ skip = false;
}
- return true;
+ continue;
}
// Make sure there's at least one item that's not already
// in this collection
if (itemGroup.isCollection() && !itemGroup.ref.hasItem(item.id)) {
- return true;
+ skip = false;
+ continue;
}
}
- return false;
+ if (skip) {
+ return false;
+ }
+ return true;
}
else if (dataType == 'zotero/item-xml') {
var xml = new XML(data.data);