HTML Tree: fix item deletion breakage when child items are selected.
Closes #2174
This commit is contained in:
parent
873846261e
commit
94c4d975a9
1 changed files with 35 additions and 28 deletions
|
@ -1727,36 +1727,43 @@ var ItemTree = class ItemTree extends LibraryTree {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapse open items
|
try {
|
||||||
for (var i=0; i<this.rowCount; i++) {
|
this.selection.selectEventsSuppressed = true;
|
||||||
if (this.selection.isSelected(i) && this.isContainer(i)) {
|
|
||||||
this._closeContainer(i, true, true);
|
// Collapse open items
|
||||||
|
for (var i = 0; i < this.rowCount; i++) {
|
||||||
|
if (this.selection.isSelected(i) && this.isContainer(i)) {
|
||||||
|
await this._closeContainer(i, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._refreshRowMap();
|
||||||
|
this.tree.invalidate();
|
||||||
|
|
||||||
|
// Create an array of selected items
|
||||||
|
var ids = Array.from(this.selection.selected).map(index => this.getRow(index).id);
|
||||||
|
|
||||||
|
var collectionTreeRow = this.collectionTreeRow;
|
||||||
|
|
||||||
|
if (collectionTreeRow.isBucket()) {
|
||||||
|
collectionTreeRow.ref.deleteItems(ids);
|
||||||
|
}
|
||||||
|
if (collectionTreeRow.isTrash()) {
|
||||||
|
await Zotero.Items.erase(ids);
|
||||||
|
}
|
||||||
|
else if (collectionTreeRow.isLibrary(true) || force) {
|
||||||
|
await Zotero.Items.trashTx(ids);
|
||||||
|
}
|
||||||
|
else if (collectionTreeRow.isCollection()) {
|
||||||
|
await Zotero.DB.executeTransaction(async () => {
|
||||||
|
await collectionTreeRow.ref.removeItems(ids);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (collectionTreeRow.isPublications()) {
|
||||||
|
await Zotero.Items.removeFromPublications(ids.map(id => Zotero.Items.get(id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._refreshRowMap();
|
finally {
|
||||||
this.tree.invalidate();
|
this.selection.selectEventsSuppressed = false;
|
||||||
|
|
||||||
// Create an array of selected items
|
|
||||||
var ids = Array.from(this.selection.selected).map(index => this.getRow(index).id);
|
|
||||||
|
|
||||||
var collectionTreeRow = this.collectionTreeRow;
|
|
||||||
|
|
||||||
if (collectionTreeRow.isBucket()) {
|
|
||||||
collectionTreeRow.ref.deleteItems(ids);
|
|
||||||
}
|
|
||||||
if (collectionTreeRow.isTrash()) {
|
|
||||||
await Zotero.Items.erase(ids);
|
|
||||||
}
|
|
||||||
else if (collectionTreeRow.isLibrary(true) || force) {
|
|
||||||
await Zotero.Items.trashTx(ids);
|
|
||||||
}
|
|
||||||
else if (collectionTreeRow.isCollection()) {
|
|
||||||
await Zotero.DB.executeTransaction(async () => {
|
|
||||||
await collectionTreeRow.ref.removeItems(ids);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (collectionTreeRow.isPublications()) {
|
|
||||||
await Zotero.Items.removeFromPublications(ids.map(id => Zotero.Items.get(id)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue