www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f5ce2d238eb20dcf39f1d3ef8712a45a343c65d0
parent c1a581168abe5f43bc7533f7d203f63a1d8aaae0
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu,  9 Apr 2015 02:57:29 -0400

Fixes #546, Advanced search : match "any" is broken

Diffstat:
Mchrome/content/zotero/advancedSearch.js | 20+-------------------
Mchrome/content/zotero/xpcom/collectionTreeView.js | 15---------------
Mchrome/content/zotero/xpcom/search.js | 22++++++++++++++++++++--
3 files changed, 21 insertions(+), 36 deletions(-)

diff --git a/chrome/content/zotero/advancedSearch.js b/chrome/content/zotero/advancedSearch.js @@ -62,25 +62,7 @@ var ZoteroAdvancedSearch = new function() { isSearchMode: function() { return true; }, getItems: function () { var search = _searchBox.search.clone(); - - // Hack to create a condition for the search's library -- - // this logic should really go in the search itself instead of here - // and in collectionTreeView.js - var conditions = search.getSearchConditions(); - if (!conditions.some(function (condition) condition.condition == 'libraryID')) { - let libraryID = _searchBox.search.libraryID; - // TEMP: libraryIDInt - if (libraryID) { - search.addCondition('libraryID', 'is', libraryID); - } - else { - let groups = Zotero.Groups.getAll(); - for (let i=0; i<groups.length; i++) { - search.addCondition('libraryID', 'isNot', groups[i].libraryID); - } - } - } - + search.libraryID = _libraryID; return Zotero.Items.get(search.search()); }, isLibrary: function () { return false; }, diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -2148,21 +2148,6 @@ Zotero.ItemGroup.prototype.getSearchResults = function(asTempTable) { if(!Zotero.ItemGroupCache.lastResults) { var s = this.getSearchObject(); - - // FIXME: Hack to exclude group libraries for now - if (this.isSearch()) { - var currentLibraryID = this.ref.libraryID; - if (currentLibraryID) { - s.addCondition('libraryID', 'is', currentLibraryID); - } - else { - var groups = Zotero.Groups.getAll(); - for each(var group in groups) { - s.addCondition('libraryID', 'isNot', group.libraryID); - } - } - } - Zotero.ItemGroupCache.lastResults = s.search(); Zotero.ItemGroupCache.lastItemGroup = this; } diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js @@ -36,7 +36,7 @@ Zotero.Search = function() { Zotero.Search.prototype._init = function () { // Public members for access by public methods -- do not access directly this._id = null; - this._libraryID = null; + this._libraryID; // TEMP: libraryIDInt this._key = null; this._name = null; this._dateAdded = null; @@ -290,7 +290,7 @@ Zotero.Search.prototype.save = function(fixGaps) { this._changed.dateModified ? this.dateModified : Zotero.DB.transactionDateTime, Zotero.DB.transactionDateTime, - this.libraryID ? this.libraryID : this.libraryID, + this.libraryID ? this.libraryID : null, key ]; @@ -1139,6 +1139,23 @@ Zotero.Search.prototype._buildQuery = function(){ + ")"; } + // Limit to library search belongs to + // + // This is equivalent to adding libraryID as a search condition, + // but it works with ANY + if (this.libraryID !== undefined) { + sql += " AND (itemID IN (SELECT itemID FROM items WHERE libraryID"; + // TEMP: libraryIDInt + if (this.libraryID) { + sql += "=?"; + sqlParams.push(this.libraryID); + } + else { + sql += " IS NULL"; + } + sql += "))"; + } + if (this._hasPrimaryConditions) { sql += " AND "; @@ -1755,6 +1772,7 @@ Zotero.Searches = new function(){ for each(var row in rows) { var search = new Zotero.Search; search.id = row.id; + search.libraryID = libraryID; searches.push(search); } return searches;