- 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:
parent
fe31d4c789
commit
beba35b44a
|
@ -46,6 +46,7 @@ var ZoteroPane = new function()
|
||||||
this.toggleTagSelector = toggleTagSelector;
|
this.toggleTagSelector = toggleTagSelector;
|
||||||
this.updateTagSelectorSize = updateTagSelectorSize;
|
this.updateTagSelectorSize = updateTagSelectorSize;
|
||||||
this.getTagSelection = getTagSelection;
|
this.getTagSelection = getTagSelection;
|
||||||
|
this.clearTagSelection = clearTagSelection;
|
||||||
this.updateTagFilter = updateTagFilter;
|
this.updateTagFilter = updateTagFilter;
|
||||||
this.onCollectionSelected = onCollectionSelected;
|
this.onCollectionSelected = onCollectionSelected;
|
||||||
this.itemSelected = itemSelected;
|
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
|
* Sets the tag filter on the items view
|
||||||
*/
|
*/
|
||||||
|
@ -1004,8 +1013,11 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
|
|
||||||
function clearQuicksearch() {
|
function clearQuicksearch() {
|
||||||
document.getElementById('zotero-tb-search').value = "";
|
var search = document.getElementById('zotero-tb-search');
|
||||||
document.getElementById('zotero-tb-search').doCommand('cmd_zotero_search');
|
if (search.value != '') {
|
||||||
|
search.value = '';
|
||||||
|
search.doCommand('cmd_zotero_search');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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() {
|
Zotero.ItemGroup.prototype.isSearchMode = function() {
|
||||||
|
// Search
|
||||||
|
if (this.isSearch()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quicksearch
|
||||||
|
if (this.searchText != '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tag filter
|
||||||
if (this.tags) {
|
if (this.tags) {
|
||||||
for (var i in this.tags) {
|
for (var i in this.tags) {
|
||||||
var hasTags = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.searchText != '' || hasTags;
|
|
||||||
}
|
}
|
|
@ -928,7 +928,7 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
||||||
/*
|
/*
|
||||||
* Select an item
|
* 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,
|
// 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
|
// 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 with id not visible, check to see if it's hidden under a parent
|
||||||
if(row == undefined)
|
if(row == undefined)
|
||||||
{
|
{
|
||||||
if (!parent || parentRow === null)
|
if (!parent || parentRow === null) {
|
||||||
{
|
|
||||||
// No parent -- it's not here
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
this.toggleOpenState(parentRow); //opens the parent of the item
|
this.toggleOpenState(parentRow); //opens the parent of the item
|
||||||
row = this._itemRowMap[id];
|
row = this._itemRowMap[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selection.select(row);
|
this.selection.select(row);
|
||||||
// If _expand_, open container
|
// If _expand_, open container
|
||||||
if (expand && this.isContainer(row) && !this.isContainerOpen(row)) {
|
if (expand && this.isContainer(row) && !this.isContainerOpen(row)) {
|
||||||
|
|
|
@ -353,25 +353,13 @@ Zotero.Search.prototype.search = function(asTempTable){
|
||||||
+ " WHERE sourceItemID IN (SELECT itemID FROM " + tmpTable + "))"
|
+ " WHERE sourceItemID IN (SELECT itemID FROM " + tmpTable + "))"
|
||||||
+ ")";
|
+ ")";
|
||||||
|
|
||||||
if (asTempTable) {
|
var ids = Zotero.DB.columnQuery(sql, this._sqlParams);
|
||||||
var tmpTable2 = "tmpSearchResults_" + Zotero.randomString(8);
|
Zotero.DB.query("DROP TABLE " + tmpTable);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (this._scope) {
|
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
|
||||||
throw ("Fulltext content search with custom scope not currently supported in Zotero.Search.search()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ids = Zotero.DB.columnQuery(this._sql, this._sqlParams);
|
|
||||||
|
|
||||||
//Zotero.debug('IDs from main search: ');
|
//Zotero.debug('IDs from main search: ');
|
||||||
//Zotero.debug(ids);
|
//Zotero.debug(ids);
|
||||||
|
|
||||||
|
@ -453,7 +441,12 @@ Zotero.Search.prototype.search = function(asTempTable){
|
||||||
hash[id] = true;
|
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,
|
// If ANY mode, just use fulltext word index hits for content search,
|
||||||
// since the main results will be added in below
|
// since the main results will be added in below
|
||||||
|
@ -495,7 +488,6 @@ Zotero.Search.prototype.search = function(asTempTable){
|
||||||
//Zotero.debug(ids);
|
//Zotero.debug(ids);
|
||||||
|
|
||||||
if (asTempTable) {
|
if (asTempTable) {
|
||||||
var ids = this._scope.search();
|
|
||||||
if (!ids) {
|
if (!ids) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +529,7 @@ Zotero.Search.prototype._idsToTempTable = function (ids) {
|
||||||
var sql = "INSERT INTO " + tmpTable + " VALUES (?)";
|
var sql = "INSERT INTO " + tmpTable + " VALUES (?)";
|
||||||
var insertStatement = Zotero.DB.getStatement(sql);
|
var insertStatement = Zotero.DB.getStatement(sql);
|
||||||
for (var i=0; i<ids.length; i++) {
|
for (var i=0; i<ids.length; i++) {
|
||||||
insertStatement.bindInt32Parameter(1, ids[i]);
|
insertStatement.bindInt32Parameter(0, ids[i]);
|
||||||
try {
|
try {
|
||||||
insertStatement.execute();
|
insertStatement.execute();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user