Closes #176, Customize search operators for itemData fields

Implemented isBefore and isAfter operators and added to date conditions -- currently have to type dates in SQL format, but we'll have a chooser or something by Beta 2 (this should probably be a known issue)

Added isLessThan and isGreaterThan to 'pages', 'section', 'accessionNumber', 'seriesNumber', and 'issue' fields, though somebody should probably check me on that list

Removed JS strict warning on empty search results
This commit is contained in:
Dan Stillman 2006-08-28 20:49:24 +00:00
parent cdd24fe3b7
commit 46368e98dd
4 changed files with 88 additions and 20 deletions

View file

@ -150,7 +150,7 @@
<implementation>
<constructor>
<![CDATA[
var operators = new Array('is', 'isNot', 'contains', 'doesNotContain', 'lessThan', 'greaterThan', 'isBefore', 'isAfter');
var operators = new Array('is', 'isNot', 'contains', 'doesNotContain', 'isLessThan', 'isGreaterThan', 'isBefore', 'isAfter');
var operatorsList = this.id('operatorsmenu');
for(var i in operators)

View file

@ -68,9 +68,16 @@ Scholar.ItemTreeView.prototype.refresh = function()
this.rowCount = 0;
var newRows = this._itemGroup.getChildItems();
for(var i = 0; i < newRows.length; i++)
if(newRows[i])
this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],0,false), i+1); //item ref, before row
if (newRows.length)
{
for(var i = 0, len = newRows.length; i < len; i++)
{
if(newRows[i])
{
this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],0,false), i+1); //item ref, before row
}
}
}
this._refreshHashMap();
}

View file

@ -316,6 +316,7 @@ Scholar.Search.prototype._buildQuery = function(){
//
switch (tables[i][j]['name']){
case 'field':
case 'datefield':
if (!tables[i][j]['alias']){
break;
}
@ -392,22 +393,24 @@ Scholar.Search.prototype._buildQuery = function(){
condSQLParams.push(tables[i][j]['value']);
break;
case 'greaterThan':
case 'isLessThan':
condSQL += '<?';
condSQLParams.push({int:tables[i][j]['value']});
break;
case 'isGreaterThan':
condSQL += '>?';
condSQLParams.push({int:tables[i][j]['value']});
break;
case 'lessThan':
condSQL += '<?';
condSQLParams.push({int:tables[i][j]['value']});
break;
case 'isBefore':
// TODO
condSQL += '<?';
condSQLParams.push({string:tables[i][j]['value']});
break;
case 'isAfter':
// TODO
condSQL += '>?';
condSQLParams.push({string:tables[i][j]['value']});
break;
}
}
@ -503,13 +506,13 @@ Scholar.SearchConditions = new function(){
* Define the advanced search operators
*/
var _operators = {
// Standard
// Standard -- these need to match those in scholarsearch.xml
is: true,
isNot: true,
contains: true,
doesNotContain: true,
lessThan: true,
greaterThan: true,
isLessThan: true,
isGreaterThan: true,
isBefore: true,
isAfter: true,
@ -595,6 +598,30 @@ Scholar.SearchConditions = new function(){
field: 'title'
},
{
name: 'dateAdded',
operators: {
is: true,
isNot: true,
isBefore: true,
isAfter: true
},
table: 'items',
field: 'DATE(dateAdded)'
},
{
name: 'dateModified',
operators: {
is: true,
isNot: true,
isBefore: true,
isAfter: true
},
table: 'items',
field: 'DATE(dateModified)'
},
{
name: 'itemTypeID',
operators: {
@ -660,7 +687,40 @@ Scholar.SearchConditions = new function(){
},
table: 'itemData',
field: 'value',
aliases: Scholar.DB.columnQuery("SELECT fieldName FROM fields"),
aliases: Scholar.DB.columnQuery("SELECT fieldName FROM fields " +
"WHERE fieldName NOT IN ('accessDate', 'date', 'pages', " +
"'section','accessionNumber','seriesNumber','issue')"),
template: true // mark for special handling
},
{
name: 'datefield',
operators: {
is: true,
isNot: true,
isBefore: true,
isAfter: true
},
table: 'itemData',
field: 'DATE(value)',
aliases: ['accessDate', 'date'],
template: true // mark for special handling
},
{
name: 'numberfield',
operators: {
is: true,
isNot: true,
contains: true,
doesNotContain: true,
isLessThan: true,
isGreaterThan: true
},
table: 'itemData',
field: 'value',
aliases: ['pages', 'section', 'accessionNumber',
'seriesNumber','issue'],
template: true // mark for special handling
}
];
@ -734,7 +794,7 @@ Scholar.SearchConditions = new function(){
if (!_initialized){
_init();
}
Scholar.debug(_standardConditions);
// TODO: return copy instead
return _standardConditions;
}

View file

@ -101,8 +101,8 @@ searchOperator.is = is
searchOperator.isNot = is not
searchOperator.contains = contains
searchOperator.doesNotContain = does not contain
searchOperator.lessThan = is less than
searchOperator.greaterThan = is greater than
searchOperator.isLessThan = is less than
searchOperator.isGreaterThan = is greater than
searchOperator.isBefore = is before
searchOperator.isAfter = is after
@ -112,6 +112,7 @@ searchConditions.tag = Tag
searchConditions.note = Note
searchConditions.creator = Creator
searchConditions.thesisType = Thesis Type
searchConditions.dateModified = Date Modified
exportOptions.exportNotes = Export Notes
exportOptions.exportFileData = Export Files