From 68b9499bc0b801dd8ad902e73bd646ca894c0fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Mon, 29 Sep 2025 16:11:11 +0300 Subject: [PATCH] Citation Explorer: Disable buttons when no selection --- .../zotero/integration/citationExplorer.js | 18 +++++++++++------- .../zotero/integration/citationExplorer.xhtml | 12 +++++------- chrome/content/zotero/itemTree.jsx | 5 ++++- .../zotero/xpcom/utilities_internal.js | 19 +++++++++++-------- scss/abstracts/_layout.scss | 4 ++-- scss/components/_citationExplorer.scss | 17 +++++++++++++---- scss/elements/_splitMenuButton.scss | 1 + 7 files changed, 47 insertions(+), 29 deletions(-) diff --git a/chrome/content/zotero/integration/citationExplorer.js b/chrome/content/zotero/integration/citationExplorer.js index 8d33861f0b..0ae8d50ec2 100644 --- a/chrome/content/zotero/integration/citationExplorer.js +++ b/chrome/content/zotero/integration/citationExplorer.js @@ -190,6 +190,7 @@ window.ZoteroDocumentCitations = { regularOnly: true, columns: itemColumns, shouldListenForNotifications: false, + autoSelect: false, onSelectionChange: this.onItemSelectionChange.bind(this), onActivate: this.onItemActivate.bind(this), emptyMessage: Zotero.getString('pane.items.loading'), @@ -272,7 +273,7 @@ window.ZoteroDocumentCitations = { // check if all citation items are linked for (let citationItem of citation.citationItems) { itemMap[citationItem.id].citedIn.push(citationIndex); - isLinked = typeof citationItem.id == 'number'; + isLinked = isLinked && typeof citationItem.id == 'number'; } let title = await citation.field.getText(); if (citation.properties.plainCitation != title) { @@ -343,6 +344,9 @@ window.ZoteroDocumentCitations = { } } itemList.setHighlightedRows(highlightedItems); + const noneSelected = citationList.selection.selected.size === 0; + document.querySelector('#button-show-in-document').disabled = noneSelected; + document.querySelector('#button-edit-citation').disabled = noneSelected; }, onCitationEdit: async function () { @@ -366,22 +370,22 @@ window.ZoteroDocumentCitations = { } const item = itemList.getRow(itemList.selection.focused).ref; const isUnlinked = typeof item.id != 'number'; - const isMultiple = itemList.selection.selected.size > 1; - document.querySelector('#button-show-in-zotero').hidden = isMultiple || isUnlinked; - document.querySelector('#button-relink-item').hidden = isMultiple || !isUnlinked; - document.querySelector('#button-addTo-library').style.display = (isMultiple || !isUnlinked) ? 'none' : 'inherit'; + const noneSelected = itemList.selection.selected.size === 0; + document.querySelector('#button-show-in-zotero').disabled = noneSelected || isUnlinked; + document.querySelector('#button-relink-item').disabled = noneSelected || !isUnlinked; + document.querySelector('#button-addTo-library').disabled = noneSelected || !isUnlinked; await this.refreshCitationList(); }, onItemActivate: async function () { - if (itemList.selection.selected.size > 1) return; const item = itemList.getRow(itemList.selection.focused).ref; if (typeof item.id != 'number') { this.onItemRelink(); } else { - await Zotero.Utilities.Internal.showInLibrary(item); + await Zotero.Utilities.Internal.showInLibrary( + Array.from(itemList.selection.selected).map(index => itemList.getRow(index).ref)); } }, diff --git a/chrome/content/zotero/integration/citationExplorer.xhtml b/chrome/content/zotero/integration/citationExplorer.xhtml index 5f9d7d8db0..5ac5a06816 100644 --- a/chrome/content/zotero/integration/citationExplorer.xhtml +++ b/chrome/content/zotero/integration/citationExplorer.xhtml @@ -78,9 +78,8 @@
- -
- + +
@@ -95,12 +94,11 @@
- -
- + +