Skip to content

Commit

Permalink
fix(search): 'get result' on numerical or user defined fields didnt work
Browse files Browse the repository at this point in the history
Closes #897
  • Loading branch information
ventura-eesc authored and Sean committed Jul 25, 2019
1 parent b006c54 commit 04109b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/definitions/modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ $.fn.search = function(parameters) {
},
result: function(value, results) {
var
lookupFields = ['title', 'id'],
result = false
;
value = (value !== undefined)
Expand All @@ -451,7 +450,7 @@ $.fn.search = function(parameters) {
module.debug('Finding result that matches', value);
$.each(results, function(index, category) {
if(Array.isArray(category.results)) {
result = module.search.object(value, category.results, lookupFields)[0];
result = module.search.object(value, category.results)[0];
// don't continue searching if a result is found
if(result) {
return false;
Expand All @@ -461,7 +460,7 @@ $.fn.search = function(parameters) {
}
else {
module.debug('Finding result in results object', value);
result = module.search.object(value, results, lookupFields)[0];
result = module.search.object(value, results)[0];
}
return result || false;
},
Expand Down Expand Up @@ -633,10 +632,15 @@ $.fn.search = function(parameters) {
$.each(searchFields, function(index, field) {
$.each(source, function(label, content) {
var
fieldExists = (typeof content[field] == 'string')
fieldExists = (typeof content[field] == 'string') || (typeof content[field] == 'number')
;
if(fieldExists) {
var text = module.remove.diacritics(content[field]);
var text;
if (typeof content[field] === 'string'){
text = module.remove.diacritics(content[field]);
} else {
text = content[field].toString();
}
if( text.search(matchRegExp) !== -1) {
// content starts with value (first in results)
addResult(results, content);
Expand Down Expand Up @@ -1247,6 +1251,7 @@ $.fn.search.settings = {

// fields to search
searchFields : [
'id',
'title',
'description'
],
Expand Down

0 comments on commit 04109b2

Please sign in to comment.