Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/classes/searchProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,25 @@
return fieldMap;
};

var getAllPrimitiveValues = function(value) {
if(typeof value === "object") {
var arr = [];
for(var prop in value) {
arr = arr.concat(getAllPrimitiveValues(value[prop]));
}

return arr;
}
else {
return [value];
}
};

var searchEntireRow = function(condition, item, fieldMap){
var result;
for (var prop in item) {
if (item.hasOwnProperty(prop)) {
var c = fieldMap[prop.toLowerCase()];
if (!c) {
continue;
}
var pVal = item[prop];
if(typeof pVal === 'object' && !(pVal instanceof Date)) {
var objectFieldMap = convertToFieldMap(c);
Expand All @@ -43,7 +54,7 @@
if (pVal !== null && pVal !== undefined) {
if (typeof f === "function") {
// Have to slice off the quotes the parser would have removed
var filterRes = f(pVal, s[1].slice(1,-1)).toString();
var filterRes = f(pVal, s[1] ? s[1].slice(1,-1) : "").toString();
result = condition.regex.test(filterRes);
} else {
result = condition.regex.test(pVal.toString());
Expand Down Expand Up @@ -75,7 +86,10 @@
result = condition.regex.test(filterResults);
}
else {
result = condition.regex.test(typeof value === "object" ? evalObject(value, col.field).toString() : value.toString());
var primitiveValues = getAllPrimitiveValues(evalObject(value, col.field));
for(var prop in primitiveValues) {
result |= condition.regex.test(primValues[prop]);
}
}
if (result) {
return true;
Expand Down