forms-angular/forms-angular — pull request #54 by DerekDomino (2014-10-06 09:39:07+00:00)
Title: Fixing searchAll, where at some point some object reference where changed

There is an issue when searching in all collections. It seems that a reference is overwritten making impossible to search in all collections (only partial):

For example, here is a console.log of searchDoc i in the callback of to the call to this.searchFunc(), around line 245 of data_form.js. Look at the 5th line of the log, strangely, the $regex has changed, as well as the $options.

````javascript
searchDoc { name: { '$regex': '^(courg)', '$options': 'i' } }
searchDoc { name: { '$regex': '^(courg)', '$options': 'i' } }
searchDoc { reference: { '$regex': '^(courg)', '$options': 'i' } }
searchDoc { active: { '$regex': '^(courg)', '$options': 'i' } }
searchDoc { name: { '$regex': true, '$options': true } }
searchDoc { code: { '$regex': 'true', '$options': 'true' } }
searchDoc { name: { '$regex': 'true', '$options': 'true' } }
searchDoc { yid: { '$regex': 'true', '$options': 'true' } }
searchDoc { categorization: { '$regex': 'true', '$options': 'true' } }
searchDoc { title: { '$regex': 'true', '$options': 'true' } }
searchDoc { name: { '$regex': 'true', '$options': 'true' } }
searchDoc { nid: { '$regex': 'true', '$options': 'true' } }
searchDoc { name: { '$regex': 'true', '$options': 'true' } }
searchDoc { reference: { '$regex': 'true', '$options': 'true' } }
searchDoc { name: { '$regex': 'true', '$options': 'true' } }
searchDoc { category: { '$regex': 'true', '$options': 'true' } }
searchDoc { subCategory: { '$regex': 'true', '$options': 'true' } }
searchDoc { code: { '$regex': 'true', '$options': 'true' } }
searchDoc { name: { '$regex': 'true', '$options': 'true' } }
searchDoc { firstname: { '$regex': 'true', '$options': 'true' } }
searchDoc { lastname: { '$regex': 'true', '$options': 'true' } }
searchDoc { email: { '$regex': 'true', '$options': 'true' } }
````

The fix (hack?) is to regenerate the searchCriteria at each call to the callback by searchFunc. May be it is worth investigating why the reference searchDoc[item.field].$regex (and .$options) does change.