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){
|
Scholar.Search.prototype.load = function(savedSearchID){
|
||||||
var sql = "SELECT savedSearchName, MAX(searchConditionID) AS maxID "
|
var sql = "SELECT savedSearchName, MAX(searchConditionID) AS maxID "
|
||||||
+ "FROM savedSearches NATURAL JOIN savedSearchConditions "
|
+ "FROM savedSearches LEFT JOIN savedSearchConditions "
|
||||||
+ "WHERE savedSearchID=" + savedSearchID + " GROUP BY savedSearchID";
|
+ "USING (savedSearchID) WHERE savedSearchID=" + savedSearchID
|
||||||
|
+ " GROUP BY savedSearchID";
|
||||||
var row = Scholar.DB.rowQuery(sql);
|
var row = Scholar.DB.rowQuery(sql);
|
||||||
|
|
||||||
if (!row){
|
if (!row){
|
||||||
|
@ -151,16 +152,6 @@ Scholar.Search.prototype.removeCondition = function(searchConditionID){
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this._conditions[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 ";
|
sql += " WHERE ";
|
||||||
|
|
||||||
// Join conditions using appropriate operator
|
// Join conditions using appropriate operator
|
||||||
if (joinMode=='ALL'){
|
if (joinMode=='ANY'){
|
||||||
var binOp = ' AND ';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var binOp = ' OR ';
|
var binOp = ' OR ';
|
||||||
}
|
}
|
||||||
|
// Default to AND
|
||||||
|
else {
|
||||||
|
var binOp = ' AND ';
|
||||||
|
}
|
||||||
|
|
||||||
for (i in tables){
|
for (i in tables){
|
||||||
for (var j in tables[i]){
|
for (var j in tables[i]){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue