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
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]) {

View file

@ -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;
}

View file

@ -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;
}