From 9f91d240b060039c7e89594e232793fd39c19c20 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 15 May 2014 03:19:49 -0400 Subject: [PATCH] Library switcher in advanced search window When opening the advanced search window, the current library is selected, and a different library can be selected to change the search scope. If a library is read-only, the saved search button is disabled. For saved searches, the appropriate library is selected and the drop-down is disabled. Also: - Close the advanced search window after a search is saved - The default name for saved searches ("Untitled 2", etc.) was based on collections rather than searches - Once an initial search has been performed, the drop-downs and checkboxes now update the results - More consistent spacing in advanced search window - (dev) Zotero.DB.getNextName() now takes a libraryID as its first parameter instead of always using My Library; the old parameters are deprecated but still work --- chrome/content/zotero/advancedSearch.js | 48 ++++++++--- chrome/content/zotero/advancedSearch.xul | 56 ++++++------- .../content/zotero/bindings/zoterosearch.xml | 84 +++++++++++++++++-- chrome/content/zotero/xpcom/db.js | 23 ++++- chrome/content/zotero/xpcom/search.js | 3 +- chrome/content/zotero/zoteroPane.js | 1 + chrome/locale/en-US/zotero/searchbox.dtd | 2 + .../skin/default/zotero/bindings/search.css | 40 +++++---- chrome/skin/default/zotero/overlay.css | 5 -- chrome/skin/default/zotero/zotero.css | 14 ++++ 10 files changed, 198 insertions(+), 78 deletions(-) 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 - - - - - - -