Select parent item after metadata retrieval if only PDF was selected

TODO: select all parents
This commit is contained in:
Dan Stillman 2018-03-09 06:39:27 -05:00
parent 16ad422e89
commit 6c8cf71c9a

View File

@ -349,6 +349,16 @@ Zotero.RecognizePDF = new function () {
throw new Zotero.Exception.Alert('recognizePDF.error');
}
var zp = Zotero.getActiveZoteroPane();
var selectParent = false;
if (zp) {
let selected = zp.getSelectedItems();
if (selected.length) {
// If only the PDF was selected, select the parent when we're done
selectParent = selected.length == 1 && selected[0] == attachment;
}
}
let parentItem = await _recognize(attachment);
if (!parentItem) {
return null;
@ -387,6 +397,18 @@ Zotero.RecognizePDF = new function () {
await attachment.saveTx();
}
try {
zp = Zotero.getActiveZoteroPane();
if (zp) {
if (selectParent) {
await zp.selectItem(parentItem.id);
}
}
}
catch (e) {
Zotero.logError(e);
}
_newItems.set(
parentItem,
{