Take object instead of id in Utilities.Internal.showInLibrary()

Not updating quickFormat.js, since we'll be removing that
This commit is contained in:
Dan Stillman 2025-03-05 22:44:26 -05:00 • committed by Dan Stillman
parent 6d52656a92
commit 764dd1a9da
3 changed files with 15 additions and 5 deletions

View file

@ -71,7 +71,7 @@ export class CitationDialogPopupsHandler {
this._getNode("#itemDetails .show").addEventListener("click", (_) => {
this.discardItemDetailsEdits = true;
this._getNode("#itemDetails").hidePopup();
Zotero.Utilities.Internal.showInLibrary(this.item.id);
Zotero.Utilities.Internal.showInLibrary(this.item);
});
this._getNode("#itemDetails .done").addEventListener("click", (_) => {
this._getNode("#itemDetails").hidePopup();
@ -232,7 +232,7 @@ export class CitationDialogPopupsHandler {
}
// Show in library
if (result == 2) {
Zotero.Utilities.Internal.showInLibrary(item.id);
Zotero.Utilities.Internal.showInLibrary(item);
return false;
}
// Checked "Do not warn about this item"

View file

@ -362,7 +362,7 @@ window.ZoteroDocumentCitations = {
this.onItemRelink();
}
else {
await Zotero.Utilities.Internal.showInLibrary(item.id);
await Zotero.Utilities.Internal.showInLibrary(item);
}
},

View file

@ -1737,7 +1737,12 @@ Zotero.Utilities.Internal = {
},
showInLibrary: async function (itemID) {
/**
* Select an object in the library tab of the main window
*
* @param {Zotero.DataObject} - Data object (e.g., Zotero.Item) to select
*/
showInLibrary: async function (dataObject) {
var pane = Zotero.getActiveZoteroPane();
// Open main window if it's not open (Mac)
if (!pane) {
@ -1751,7 +1756,12 @@ Zotero.Utilities.Internal = {
});
pane = win.ZoteroPane;
}
pane.selectItem(itemID);
if (dataObject instanceof Zotero.Item) {
pane.selectItem(dataObject.id);
}
else {
throw new Error("Unimplemented");
}
// Pull window to foreground
Zotero.Utilities.Internal.activate(pane.document.defaultView);