- Updated ItemTreeView.selectItem() to clear tag selector and quicksearch and try again if item not initially found

- Fix phrase search in quick search and other brokenness
This commit is contained in:
Dan Stillman 2007-04-17 05:00:27 +00:00
parent fe31d4c789
commit beba35b44a
4 changed files with 49 additions and 29 deletions

View File

@ -46,6 +46,7 @@ var ZoteroPane = new function()
this.toggleTagSelector = toggleTagSelector;
this.updateTagSelectorSize = updateTagSelectorSize;
this.getTagSelection = getTagSelection;
this.clearTagSelection = clearTagSelection;
this.updateTagFilter = updateTagFilter;
this.onCollectionSelected = onCollectionSelected;
this.itemSelected = itemSelected;
@ -637,6 +638,14 @@ var ZoteroPane = new function()
}
function clearTagSelection() {
if (Zotero.hasValues(this.getTagSelection())) {
var tagSelector = document.getElementById('zotero-tag-selector');
tagSelector.clearAll();
}
}
/*
* Sets the tag filter on the items view
*/
@ -1004,8 +1013,11 @@ var ZoteroPane = new function()
function clearQuicksearch() {
document.getElementById('zotero-tb-search').value = "";
document.getElementById('zotero-tb-search').doCommand('cmd_zotero_search');
var search = document.getElementById('zotero-tb-search');
if (search.value != '') {
search.value = '';
search.doCommand('cmd_zotero_search');
}
}

View File

@ -948,14 +948,23 @@ Zotero.ItemGroup.prototype.setTags = function(tags)
}
/*
* Returns TRUE if using quicksearch or tag filter
* Returns TRUE if saved search, quicksearch or tag filter
*/
Zotero.ItemGroup.prototype.isSearchMode = function() {
// Search
if (this.isSearch()) {
return true;
}
// Quicksearch
if (this.searchText != '') {
return true;
}
// Tag filter
if (this.tags) {
for (var i in this.tags) {
var hasTags = true;
break;
return true;
}
}
return this.searchText != '' || hasTags;
}

View File

@ -928,7 +928,7 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
/*
* Select an item
*/
Zotero.ItemTreeView.prototype.selectItem = function(id, expand)
Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse)
{
// If no row map, we're probably in the process of switching collections,
// so store the item to select on the item group for later
@ -955,15 +955,22 @@ Zotero.ItemTreeView.prototype.selectItem = function(id, expand)
// If row with id not visible, check to see if it's hidden under a parent
if(row == undefined)
{
if (!parent || parentRow === null)
{
if (!parent || parentRow === null) {
// No parent -- it's not here
// Clear the quicksearch and tag selection and try again (once)
if (!noRecurse) {
this._ownerDocument.defaultView.ZoteroPane.clearQuicksearch();
this._ownerDocument.defaultView.ZoteroPane.clearTagSelection();
return this.selectItem(id, expand, true);
}
return false;
}
this.toggleOpenState(parentRow); //opens the parent of the item
row = this._itemRowMap[id];
}
this.selection.select(row);
// If _expand_, open container
if (expand && this.isContainer(row) && !this.isContainerOpen(row)) {

View File

@ -353,25 +353,13 @@ Zotero.Search.prototype.search = function(asTempTable){
+ " WHERE sourceItemID IN (SELECT itemID FROM " + tmpTable + "))"
+ ")";
if (asTempTable) {
var tmpTable2 = "tmpSearchResults_" + Zotero.randomString(8);
sql = "CREATE TEMPORARY TABLE " + tmpTable2 + " AS " + sql;
Zotero.DB.query(sql, this._sqlParams);
return tmpTable2;
}
else {
var ids = Zotero.DB.columnQuery(sql, this._sqlParams);
Zotero.DB.query("DROP TABLE " + tmpTable);
return ids;
}
var ids = Zotero.DB.columnQuery(sql, this._sqlParams);
Zotero.DB.query("DROP TABLE " + tmpTable);
}
if (this._scope) {
throw ("Fulltext content search with custom scope not currently supported in Zotero.Search.search()");
else {
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
}
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
//Zotero.debug('IDs from main search: ');
//Zotero.debug(ids);
@ -453,7 +441,12 @@ Zotero.Search.prototype.search = function(asTempTable){
hash[id] = true;
}
var scopeIDs = ids.filter(filter);
if (ids) {
var scopeIDs = ids.filter(filter);
}
else {
var scopeIDs = [];
}
}
// If ANY mode, just use fulltext word index hits for content search,
// since the main results will be added in below
@ -495,7 +488,6 @@ Zotero.Search.prototype.search = function(asTempTable){
//Zotero.debug(ids);
if (asTempTable) {
var ids = this._scope.search();
if (!ids) {
return false;
}
@ -537,7 +529,7 @@ Zotero.Search.prototype._idsToTempTable = function (ids) {
var sql = "INSERT INTO " + tmpTable + " VALUES (?)";
var insertStatement = Zotero.DB.getStatement(sql);
for (var i=0; i<ids.length; i++) {
insertStatement.bindInt32Parameter(1, ids[i]);
insertStatement.bindInt32Parameter(0, ids[i]);
try {
insertStatement.execute();
}