Search updates:
- Remaining searchConditionIDs are no longer affected by removeCondition() (i.e. they now act like autoincrements), which should make interface code simpler - Changed default join mode to ALL - Fixed loading of saved searches with no search conditions
This commit is contained in:
parent
0061a8d0df
commit
4fe960d190
1 changed files with 8 additions and 16 deletions
|
@ -27,8 +27,9 @@ Scholar.Search.prototype.setName = function(name){
|
|||
*/
|
||||
Scholar.Search.prototype.load = function(savedSearchID){
|
||||
var sql = "SELECT savedSearchName, MAX(searchConditionID) AS maxID "
|
||||
+ "FROM savedSearches NATURAL JOIN savedSearchConditions "
|
||||
+ "WHERE savedSearchID=" + savedSearchID + " GROUP BY savedSearchID";
|
||||
+ "FROM savedSearches LEFT JOIN savedSearchConditions "
|
||||
+ "USING (savedSearchID) WHERE savedSearchID=" + savedSearchID
|
||||
+ " GROUP BY savedSearchID";
|
||||
var row = Scholar.DB.rowQuery(sql);
|
||||
|
||||
if (!row){
|
||||
|
@ -151,16 +152,6 @@ Scholar.Search.prototype.removeCondition = function(searchConditionID){
|
|||
}
|
||||
|
||||
delete this._conditions[searchConditionID];
|
||||
|
||||
var i = searchConditionID + 1;
|
||||
while (typeof this._conditions[i] != 'undefined'){
|
||||
this._conditions[i-1] = this._conditions[i];
|
||||
this._conditions[i-1]['id']--;
|
||||
delete this._conditions[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
this._maxSearchConditionID--;
|
||||
}
|
||||
|
||||
|
||||
|
@ -264,12 +255,13 @@ Scholar.Search.prototype._buildQuery = function(){
|
|||
sql += " WHERE ";
|
||||
|
||||
// Join conditions using appropriate operator
|
||||
if (joinMode=='ALL'){
|
||||
var binOp = ' AND ';
|
||||
}
|
||||
else {
|
||||
if (joinMode=='ANY'){
|
||||
var binOp = ' OR ';
|
||||
}
|
||||
// Default to AND
|
||||
else {
|
||||
var binOp = ' AND ';
|
||||
}
|
||||
|
||||
for (i in tables){
|
||||
for (var j in tables[i]){
|
||||
|
|
Loading…
Reference in a new issue