Fix "Invalid integer value 'null'" error when dragging a regular item and a top-level attachment between libraries, which shouldn't have been allowed
This commit is contained in:
parent
b3d5136c34
commit
9c0ad65172
1 changed files with 17 additions and 11 deletions
|
@ -995,10 +995,11 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData)
|
||||||
if (dataType == 'zotero/item') {
|
if (dataType == 'zotero/item') {
|
||||||
var ids = data;
|
var ids = data;
|
||||||
var items = Zotero.Items.get(ids);
|
var items = Zotero.Items.get(ids);
|
||||||
|
var skip = true;
|
||||||
for each(var item in items) {
|
for each(var item in items) {
|
||||||
// Can only drag top-level items
|
// Can only drag top-level items
|
||||||
if (!(item.isRegularItem() || !item.getSource())) {
|
if (!item.isTopLevelItem()) {
|
||||||
continue;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: for now, only allow regular items to be dragged to groups
|
// 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
|
// TODO: for now, skip items that are already linked
|
||||||
if (itemGroup.isWithinGroup() && itemGroup.ref.libraryID != item.libraryID) {
|
if (itemGroup.isWithinGroup() && itemGroup.ref.libraryID != item.libraryID) {
|
||||||
if (item.getLinkedItem(itemGroup.ref.libraryID)) {
|
if (!item.getLinkedItem(itemGroup.ref.libraryID)) {
|
||||||
continue;
|
skip = false;
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemGroup.isGroup()) {
|
if (itemGroup.isGroup()) {
|
||||||
// Don't allow drag onto library of same group
|
// Don't allow drag onto library of same group
|
||||||
if (itemGroup.ref.libraryID == item.libraryID) {
|
if (itemGroup.ref.libraryID == item.libraryID) {
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow drag of group items to library
|
// Allow drag of group items to library
|
||||||
if (item.libraryID && (itemGroup.isLibrary()
|
if (item.libraryID && (itemGroup.isLibrary()
|
||||||
|| itemGroup.isCollection() && !itemGroup.isWithinGroup())) {
|
|| itemGroup.isCollection() && !itemGroup.isWithinGroup())) {
|
||||||
// TODO: for now, skip items that are already linked
|
// TODO: for now, skip items that are already linked
|
||||||
if (item.getLinkedItem()) {
|
if (!item.getLinkedItem()) {
|
||||||
continue;
|
skip = false;
|
||||||
}
|
}
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there's at least one item that's not already
|
// Make sure there's at least one item that's not already
|
||||||
// in this collection
|
// in this collection
|
||||||
if (itemGroup.isCollection() && !itemGroup.ref.hasItem(item.id)) {
|
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') {
|
else if (dataType == 'zotero/item-xml') {
|
||||||
var xml = new XML(data.data);
|
var xml = new XML(data.data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue