diff --git a/chrome/content/zotero/advancedSearch.js b/chrome/content/zotero/advancedSearch.js index eec434fc8c..4bb5cefe70 100644 --- a/chrome/content/zotero/advancedSearch.js +++ b/chrome/content/zotero/advancedSearch.js @@ -43,6 +43,7 @@ var ZoteroAdvancedSearch = new function() { var sbc = document.getElementById('zotero-search-box-container'); Zotero.setFontSize(sbc); + _searchBox.onLibraryChange = this.onLibraryChange; var io = window.arguments[0]; _searchBox.search = io.dataIn.search; } @@ -50,24 +51,33 @@ var ZoteroAdvancedSearch = new function() { function search() { _searchBox.updateSearch(); + _searchBox.active = true; // A minimal implementation of Zotero.CollectionTreeView var itemGroup = { isSearchMode: function() { return true; }, getItems: function () { - //var search = _searchBox.search.clone(); + var search = _searchBox.search.clone(); - var s2 = new Zotero.Search(); - s2.setScope(_searchBox.search); - - // FIXME: Hack to exclude group libraries for now - var groups = Zotero.Groups.getAll(); - for each(var group in groups) { - s2.addCondition('libraryID', 'isNot', group.libraryID); + // 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 - - - - - - -