mirror of
https://github.com/zotero/zotero.git
synced 2026-09-27 01:21:27 +00:00
parent
f8a517d286
commit
971c57fedd
1 changed files with 11 additions and 17 deletions
|
|
@ -2345,6 +2345,7 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
|
||||
// In library, allow children to be dragged out of parent
|
||||
else if (collectionTreeRow.isLibrary(true) || collectionTreeRow.isCollection()) {
|
||||
let targetRow = row != -1 ? this.getRow(row) : null;
|
||||
for (let item of items) {
|
||||
// Don't allow drag if any top-level items
|
||||
if (item.isTopLevelItem()) {
|
||||
|
|
@ -2365,24 +2366,17 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Don't allow children to be dragged within their own parents
|
||||
var parentItemID = item.parentItemID;
|
||||
var parentIndex = this._rowMap[parentItemID];
|
||||
if (row != -1 && this.getLevel(row) > 0) {
|
||||
if (this.getRow(this.getParentIndex(row)).ref.id == parentItemID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Including immediately after the parent
|
||||
if (orient == 1) {
|
||||
if (row == parentIndex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// And immediately before the next parent
|
||||
// Can always drop into empty space
|
||||
if (!targetRow) continue;
|
||||
// Can only drop before or after a top-level item
|
||||
if (!targetRow.ref.isTopLevelItem()) return false;
|
||||
// Cannot drop between an opened container and the first child row
|
||||
if (orient == 1 && targetRow.isOpen) return false;
|
||||
// Cannot drop after the last child of a parent container
|
||||
if (orient == -1) {
|
||||
var nextParentIndex = null;
|
||||
for (var i = parentIndex + 1; i < this.rowCount; i++) {
|
||||
let parentIndex = this._rowMap[item.parentItemID];
|
||||
let nextParentIndex = null;
|
||||
for (let i = parentIndex + 1; i < this.rowCount; i++) {
|
||||
if (this.getLevel(i) == 0) {
|
||||
nextParentIndex = i;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue