www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 46368e98ddeefd5524d38a84ffcf7588e98ae233
parent cdd24fe3b7e0b763c7c9e83fe8dbf78989647561
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 28 Aug 2006 20:49:24 +0000

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


Diffstat:
Mchrome/chromeFiles/content/scholar/bindings/scholarsearch.xml | 2+-
Mchrome/chromeFiles/content/scholar/xpcom/itemTreeView.js | 13++++++++++---
Mchrome/chromeFiles/content/scholar/xpcom/search.js | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Mchrome/chromeFiles/locale/en-US/scholar/scholar.properties | 5+++--
4 files changed, 87 insertions(+), 19 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml b/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml @@ -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) diff --git a/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js b/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js @@ -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(); } diff --git a/chrome/chromeFiles/content/scholar/xpcom/search.js b/chrome/chromeFiles/content/scholar/xpcom/search.js @@ -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': - condSQL += '>?'; + case 'isLessThan': + condSQL += '<?'; condSQLParams.push({int:tables[i][j]['value']}); break; - case 'lessThan': - condSQL += '<?'; + case 'isGreaterThan': + 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, @@ -596,6 +599,30 @@ Scholar.SearchConditions = new function(){ }, { + 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: { is: true, @@ -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; } diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties @@ -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 \ No newline at end of file