commit 8068c17f8f4fccbb41cb916e0a5e692439393c96
parent 3571b41d95651763f7b7291e2e6473163bf4ef4e
Author: Simon Kornblith <simon@simonster.com>
Date: Mon, 12 Jul 2010 11:24:29 +0000
closes #1689, When editing a citation, the reference is not selected if it does not exist in the currently selected collection within the Zotero pane
Diffstat:
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/chrome/content/zotero/integration/addCitationDialog.js b/chrome/content/zotero/integration/addCitationDialog.js
@@ -123,7 +123,14 @@ var Zotero_Citation_Dialog = new function () {
// single citation
toggleMultipleSources(false);
_suppressNextTreeSelect = true;
- itemsView.selectItem(io.citation.citationItems[0].id); // treeview from xpcom/itemTreeView.js
+
+ // switch to library if item doesn't exist in current selection
+ if(!collectionsView.getSelectedCollection().hasItem(io.citation.citationItems[0].id)) {
+ var item = Zotero.Items.get(io.citation.citationItems[0].id);
+ collectionsView.selectLibrary(item.libraryID);
+ }
+ itemsView.selectItem(io.citation.citationItems[0].id);
+
for(var box in _preserveData) {
var property = _preserveData[box][0];
if(io.citation.citationItems[0][box]) {
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -1672,14 +1672,8 @@ var ZoteroPane = new function()
function getSelectedCollection(asID) {
- if (this.collectionsView
- && this.collectionsView.selection
- && this.collectionsView.selection.count > 0
- && this.collectionsView.selection.currentIndex != -1) {
- var collection = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
- if (collection && collection.isCollection()) {
- return asID ? collection.ref.id : collection.ref;
- }
+ if (this.collectionsView) {
+ return this.collectionsView.getSelectedCollection(asID);
}
return false;
}
diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js
@@ -946,6 +946,19 @@ Zotero.CollectionTreeView.prototype.rememberSelection = function(selection)
break;
}
}
+
+
+Zotero.CollectionTreeView.prototype.getSelectedCollection = function(asID) {
+ if (this.selection
+ && this.selection.count > 0
+ && this.selection.currentIndex != -1) {
+ var collection = this._getItemAtRow(this.selection.currentIndex);
+ if (collection && collection.isCollection()) {
+ return asID ? collection.ref.id : collection.ref;
+ }
+ }
+ return false;
+}