Fix export from saved search content menu on trunk, changing ZoteroItemPane.getSortedItems() to return Item objects unless asIDs is passed (like getSelectedItems())

This commit is contained in:
Dan Stillman 2008-06-17 20:39:26 +00:00
parent dcccee13a1
commit 35e9f3b3b7
3 changed files with 27 additions and 16 deletions

View file

@ -143,9 +143,8 @@ var Zotero_File_Interface = new function() {
if(!exporter.items) throw ("No items to save"); if(!exporter.items) throw ("No items to save");
// find name // find name
var searchRef = ZoteroPane.getSelectedSavedSearch(); var search = ZoteroPane.getSelectedSavedSearch();
if(searchRef) { if(search) {
var search = new Zotero.Search(searchRef.id);
exporter.name = search.name; exporter.name = search.name;
} }
} }

View file

@ -1322,22 +1322,25 @@ var ZoteroPane = new function()
*/ */
function getSelectedItems(asIDs) function getSelectedItems(asIDs)
{ {
if (this.itemsView) { if (!this.itemsView) {
return this.itemsView.getSelectedItems(asIDs);
}
return []; return [];
} }
return this.itemsView.getSelectedItems(asIDs);
}
/* /*
* Returns an array of item ids of visible items in current sort order * Returns an array of Zotero.Item objects of visible items in current sort order
*
* If asIDs is true, return an array of itemIDs instead
*/ */
function getSortedItems() { function getSortedItems(asIDs) {
if (!this.itemsView) { if (!this.itemsView) {
return false; return [];
} }
return this.itemsView.getSortedItems(); return this.itemsView.getSortedItems(asIDs);
} }

View file

@ -1439,16 +1439,25 @@ Zotero.ItemTreeView.prototype.getVisibleFields = function() {
} }
/* /**
* Returns an array of item ids of visible items in current sort order * Returns an array of items of visible items in current sort order
*
* @param bool asIDs Return itemIDs
* @return array An array of Zotero.Item objects or itemIDs
*/ */
Zotero.ItemTreeView.prototype.getSortedItems = function() { Zotero.ItemTreeView.prototype.getSortedItems = function(asIDs) {
var ids = []; var items = [];
for each(var item in this._dataItems) { for each(var item in this._dataItems) {
ids.push(item.ref.id); if (asIDs) {
items.push(item.ref.id);
} }
return ids; else {
items.push(item.ref);
} }
}
return items;
}
Zotero.ItemTreeView.prototype.getSortField = function() { Zotero.ItemTreeView.prototype.getSortField = function() {
var column = this._treebox.columns.getSortedColumn() var column = this._treebox.columns.getSortedColumn()