From d5fdbc6cbe8ddc91890b394cd8ca8ea66341d7c8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 17 Jun 2008 20:39:26 +0000 Subject: [PATCH] Fix export from saved search content menu on trunk, changing ZoteroItemPane.getSortedItems() to return Item objects unless asIDs is passed (like getSelectedItems()) --- chrome/content/zotero/fileInterface.js | 5 ++--- chrome/content/zotero/overlay.js | 17 ++++++++++------- chrome/content/zotero/xpcom/itemTreeView.js | 21 +++++++++++++++------ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 864077686..4d88712ec 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -143,9 +143,8 @@ var Zotero_File_Interface = new function() { if(!exporter.items) throw ("No items to save"); // find name - var searchRef = ZoteroPane.getSelectedSavedSearch(); - if(searchRef) { - var search = new Zotero.Search(searchRef.id); + var search = ZoteroPane.getSelectedSavedSearch(); + if(search) { exporter.name = search.name; } } diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 043d9138d..21cf10853 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -1322,22 +1322,25 @@ var ZoteroPane = new function() */ function getSelectedItems(asIDs) { - if (this.itemsView) { - return this.itemsView.getSelectedItems(asIDs); + if (!this.itemsView) { + 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) { - return false; + return []; } - return this.itemsView.getSortedItems(); + return this.itemsView.getSortedItems(asIDs); } diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 9aba838b6..7303910d3 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1439,17 +1439,26 @@ 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() { - var ids = []; +Zotero.ItemTreeView.prototype.getSortedItems = function(asIDs) { + var items = []; for each(var item in this._dataItems) { - ids.push(item.ref.id); + if (asIDs) { + items.push(item.ref.id); + } + else { + items.push(item.ref); + } } - return ids; + return items; } + Zotero.ItemTreeView.prototype.getSortField = function() { var column = this._treebox.columns.getSortedColumn() if (!column) {