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

This commit is contained in:
Simon Kornblith 2010-07-12 11:24:29 +00:00
parent 3571b41d95
commit 8068c17f8f
3 changed files with 23 additions and 9 deletions

View File

@ -123,7 +123,14 @@ var Zotero_Citation_Dialog = new function () {
// single citation // single citation
toggleMultipleSources(false); toggleMultipleSources(false);
_suppressNextTreeSelect = true; _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) { for(var box in _preserveData) {
var property = _preserveData[box][0]; var property = _preserveData[box][0];
if(io.citation.citationItems[0][box]) { if(io.citation.citationItems[0][box]) {

View File

@ -1672,14 +1672,8 @@ var ZoteroPane = new function()
function getSelectedCollection(asID) { function getSelectedCollection(asID) {
if (this.collectionsView if (this.collectionsView) {
&& this.collectionsView.selection return this.collectionsView.getSelectedCollection(asID);
&& 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;
}
} }
return false; return false;
} }

View File

@ -948,6 +948,19 @@ Zotero.CollectionTreeView.prototype.rememberSelection = function(selection)
} }
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;
}
/* /*
* Creates hash map of collection and search ids to row indexes * Creates hash map of collection and search ids to row indexes