Update parent item from target selector if item was made a child item
This is necessary for automatic PDF recognition. Addresses zotero/zotero-connectors#220
This commit is contained in:
parent
0f6b712963
commit
00d85fb6da
1 changed files with 14 additions and 12 deletions
|
@ -145,12 +145,13 @@ Zotero.Server.Connector.SaveSession.prototype.update = async function (libraryID
|
||||||
|
|
||||||
// TODO: Update active item saver
|
// TODO: Update active item saver
|
||||||
|
|
||||||
// If a single item was saved, select it
|
// If a single item was saved, select it (or its parent, if it now has one)
|
||||||
if (win && win.collectionsView) {
|
if (win && win.collectionsView) {
|
||||||
if (this._objects && this._objects.item) {
|
if (this._objects && this._objects.item) {
|
||||||
let items = Array.from(this._objects.item).filter(item => item.isTopLevelItem());
|
if (this._objects.item.size == 1) {
|
||||||
if (items.length == 1) {
|
let item = Array.from(this._objects.item)[0];
|
||||||
await win.selectItem(items[0].id);
|
item = item.isTopLevelItem() ? item : item.parentItem;
|
||||||
|
await win.selectItem(item.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,14 +193,15 @@ Zotero.Server.Connector.SaveSession.prototype._updateObjects = async function (o
|
||||||
throw new Error("Can't move objects between libraries");
|
throw new Error("Can't move objects between libraries");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep automatic tags
|
// Assign manual tags and collections to the item, or the parent item if it's now
|
||||||
let originalTags = object.getTags().filter(tag => tag.type == 1);
|
// a child item (e.g., from Retrieve Metadata for PDF)
|
||||||
|
if (objectType == 'item') {
|
||||||
// Assign manual tags and collections to top-level items
|
let item = object.isTopLevelItem() ? object : object.parentItem;
|
||||||
if (objectType == 'item' && object.isTopLevelItem()) {
|
// Keep automatic tags
|
||||||
object.setTags(originalTags.concat(tags));
|
let originalTags = item.getTags().filter(tag => tag.type == 1);
|
||||||
object.setCollections(collectionID ? [collectionID] : []);
|
item.setTags(originalTags.concat(tags));
|
||||||
await object.save();
|
item.setCollections(collectionID ? [collectionID] : []);
|
||||||
|
await item.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue