fix
This commit is contained in:
parent
3cca634101
commit
94f7ec85e9
17
index.js
17
index.js
@ -78,6 +78,14 @@ function is_nil (obj) {
|
|||||||
|| (typeof obj === 'number' && isNaN (obj));
|
|| (typeof obj === 'number' && isNaN (obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function to_search_string (element, field) {
|
||||||
|
return Array.isArray (field)
|
||||||
|
? field.map ((f) => element[f])
|
||||||
|
.filter ((v) => typeof v !== 'undefined')
|
||||||
|
.join (' ')
|
||||||
|
: element[field];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter nested objects
|
* filter nested objects
|
||||||
*
|
*
|
||||||
@ -93,14 +101,7 @@ function recursive_filter (input, filters, children_key = 'children') {
|
|||||||
data[i] = e;
|
data[i] = e;
|
||||||
let match = true;
|
let match = true;
|
||||||
for (const filter of filters) {
|
for (const filter of filters) {
|
||||||
const is_multi_filter
|
const search_str = to_search_string(e, filter.field);
|
||||||
= Array.isArray (filter.fields);
|
|
||||||
|
|
||||||
const search_str = is_multi_filter
|
|
||||||
? filter.fields.map ((f) => e[f])
|
|
||||||
.filter ((v) => typeof v !== 'undefined')
|
|
||||||
.join (' ')
|
|
||||||
: e[filter.field];
|
|
||||||
|
|
||||||
if (!filter.filter.test (search_str)) {
|
if (!filter.filter.test (search_str)) {
|
||||||
match = false;
|
match = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user