@@ -291,7 +291,6 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
291
291
searches ,
292
292
function ( item , cb ) {
293
293
var searchDoc = { } ;
294
- // console.log(searchCriteria);
295
294
if ( filter ) {
296
295
extend ( searchDoc , filter ) ;
297
296
if ( filter [ item . field ] ) {
@@ -313,16 +312,10 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
313
312
that . filteredFind ( item . resource , req , null , searchDoc , item . resource . options . searchOrder , limit + 60 , null , function ( err , docs ) {
314
313
if ( ! err && docs && docs . length > 0 ) {
315
314
async . map ( docs , function ( aDoc , cbdoc ) {
316
-
317
315
// Do we already have them in the list?
318
- var thisId = aDoc . _id ,
319
- resultObject ,
320
- resultPos ;
321
- for ( resultPos = results . length - 1 ; resultPos >= 0 ; resultPos -- ) {
322
- if ( results [ resultPos ] . id . id === thisId . id ) {
323
- break ;
324
- }
325
- }
316
+ var thisId :string = aDoc . _id . toString ( ) ,
317
+ resultObject : any ,
318
+ resultPos : number ;
326
319
327
320
function handleResultsInList ( ) {
328
321
resultObject . searchImportance = item . resource . options . searchImportance || 99 ;
@@ -334,6 +327,12 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
334
327
results . splice ( _ . sortedIndex ( results , resultObject , calcResultValue ) , 0 , resultObject ) ;
335
328
cbdoc ( null ) ;
336
329
}
330
+
331
+ for ( resultPos = results . length - 1 ; resultPos >= 0 ; resultPos -- ) {
332
+ if ( results [ resultPos ] . id . toString ( ) === thisId ) {
333
+ break ;
334
+ }
335
+ }
337
336
if ( resultPos >= 0 ) {
338
337
resultObject = { } ;
339
338
extend ( resultObject , results [ resultPos ] ) ;
@@ -357,7 +356,7 @@ DataForm.prototype.internalSearch = function (req, resourcesToSearch, includeRes
357
356
cbdoc ( err ) ;
358
357
} else {
359
358
resultObject = {
360
- id : thisId ,
359
+ id : aDoc . _id ,
361
360
weighting : 9999 ,
362
361
text : description
363
362
} ;
@@ -508,7 +507,7 @@ DataForm.prototype.preprocess = function (resource: Resource, paths, formSchema)
508
507
if ( paths [ element ] . options . match ) {
509
508
outPath [ element ] . options . match = paths [ element ] . options . match . source ;
510
509
}
511
- let schemaListInfo = paths [ element ] . options . list ;
510
+ let schemaListInfo : any = paths [ element ] . options . list ;
512
511
if ( schemaListInfo ) {
513
512
var listFieldInfo :ListField = { field : element } ;
514
513
if ( typeof schemaListInfo === 'object' && Object . keys ( schemaListInfo ) . length > 0 ) {
@@ -691,10 +690,10 @@ DataForm.prototype.reportInternal = function (req, resource, schema, options, ca
691
690
var translations = [ ] ; // array of form {ref:'lookupname',translations:[{value:xx, display:' '}] }
692
691
// if we need to do any column translations add the function to the tasks list
693
692
if ( schema . columnTranslations ) {
694
- toDo . applyTranslations = [ 'runAggregation' , function ( cb , results ) {
693
+ toDo . applyTranslations = [ 'runAggregation' , function ( cb , results : any ) {
695
694
696
695
function doATranslate ( column , theTranslation ) {
697
- results . runAggregation . forEach ( function ( resultRow ) {
696
+ results [ ' runAggregation' ] . forEach ( function ( resultRow ) {
698
697
var valToTranslate = resultRow [ column . field ] ;
699
698
valToTranslate = ( valToTranslate ? valToTranslate . toString ( ) : '' ) ;
700
699
var thisTranslation = _ . find ( theTranslation . translations , function ( option ) {
0 commit comments