commit c4e9e767950cb358494c23db4f93bdffa05de194
parent 61c18639fef70e0a893be94d66f4ec267ef06506
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 22 Aug 2006 04:23:01 +0000
Search (data layer):
- Added 'fulltext' condition as shortcut to add an operator/value against all string-based conditions -- can be used for quicksearch within a view if collectionID/savedSearchID is added as a required condition along with it
Note that the 'fulltext' condition isn't stored internally and addCondition() doesn't return a searchConditionID for it, so it's not really meant to be used for saved searches.
Example:
var search = new Scholar.Search();
search.addCondition('collectionID', 'is', 6856, true);
search.addCondition('fulltext', 'contains', 'wellman');
Scholar.debug(search.search());
- Fixed isNot/doesNotContain for items table fields and collectionID
Diffstat:
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/search.js b/chrome/chromeFiles/content/scholar/xpcom/search.js
@@ -122,6 +122,17 @@ Scholar.Search.prototype.addCondition = function(condition, operator, value, req
throw ("Invalid operator '" + operator + "' for condition " + condition);
}
+ // Shortcut to add a condition on every table -- does not return an id
+ if (condition=='fulltext'){
+ this.addCondition('joinMode', 'any');
+ this.addCondition('title', operator, value, false);
+ this.addCondition('field', operator, value, false);
+ this.addCondition('creator', operator, value, false);
+ this.addCondition('tag', operator, value, false);
+ this.addCondition('note', operator, value, false);
+ return false;
+ }
+
var searchConditionID = ++this._maxSearchConditionID;
this._conditions[searchConditionID] = {
@@ -285,7 +296,6 @@ Scholar.Search.prototype._buildQuery = function(){
// Special table handling
//
switch (i){
- case 'items':
case 'savedSearches':
break;
default:
@@ -306,6 +316,9 @@ Scholar.Search.prototype._buildQuery = function(){
//
switch (tables[i][j]['name']){
case 'field':
+ if (!tables[i][j]['alias']){
+ break;
+ }
condSQL += 'fieldID=? AND ';
condSQLParams.push(
Scholar.ItemFields.getID(tables[i][j]['alias'])
@@ -313,12 +326,7 @@ Scholar.Search.prototype._buildQuery = function(){
break;
case 'collectionID':
- condSQL += "collectionID ";
- if (tables[i][j]['operator']=='isNot'){
- condSQL += "NOT ";
- }
- // Add given collection id
- condSQL += "IN (?,";
+ condSQL += "collectionID IN (?,";
condSQLParams.push({int:tables[i][j]['value']});
// And descendents if recursive search
@@ -540,6 +548,28 @@ Scholar.SearchConditions = new function(){
}
},
+ // Saved search to search within
+ {
+ name: 'savedSearchID',
+ operators: {
+ is: true,
+ isNot: true
+ },
+ table: 'savedSearches',
+ field: 'savedSearchID',
+ special: true
+ },
+
+ {
+ name: 'fulltext',
+ operators: {
+ is: true,
+ isNot: true,
+ contains: true,
+ doesNotContain: true
+ }
+ },
+
//
// Standard conditions
//
@@ -555,18 +585,6 @@ Scholar.SearchConditions = new function(){
field: 'collectionID'
},
- // Saved search to search within
- {
- name: 'savedSearchID',
- operators: {
- is: true,
- isNot: true
- },
- table: 'savedSearches',
- field: 'savedSearchID',
- special: true
- },
-
{
name: 'title',
operators: {