From 46368e98ddeefd5524d38a84ffcf7588e98ae233 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 28 Aug 2006 20:49:24 +0000 Subject: [PATCH] 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 --- .../scholar/bindings/scholarsearch.xml | 2 +- .../content/scholar/xpcom/itemTreeView.js | 13 ++- .../content/scholar/xpcom/search.js | 88 ++++++++++++++++--- .../locale/en-US/scholar/scholar.properties | 5 +- 4 files changed, 88 insertions(+), 20 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml b/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml index dd1bb4f18..750a65d4b 100644 --- a/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml +++ b/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml @@ -150,7 +150,7 @@ ?'; condSQLParams.push({int:tables[i][j]['value']}); break; - case 'lessThan': - 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; } diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties index a8b6a2c53..c57b01e1f 100644 --- 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