Lines 13-32
function patron_autocomplete(node, options) {
Link Here
|
13 |
on_select_callback = options['on-select-callback']; |
13 |
on_select_callback = options['on-select-callback']; |
14 |
} |
14 |
} |
15 |
} |
15 |
} |
16 |
const search_fields = ['me.surname', 'me.firstname', 'me.cardnumber']; |
|
|
17 |
return node.autocomplete({ |
16 |
return node.autocomplete({ |
18 |
source: function( request, response ) { |
17 |
source: function( request, response ) { |
19 |
let subquery_and = []; |
18 |
let subquery_and = []; |
20 |
request.term.split(' ') |
19 |
request.term.split(' ') |
21 |
.filter(function(s){ return s.length }) |
20 |
.filter(function(s){ return s.length }) |
22 |
.forEach(function(pattern,i){ |
21 |
.forEach(function(pattern,i){ |
23 |
subquery_and.push( |
22 |
let subquery_or = []; |
24 |
[ |
23 |
defaultPatronSearchFields.split(',').forEach(function(field,i){ |
25 |
{'me.surname': {'like': '%' + pattern + '%'}}, |
24 |
subquery_or.push( |
26 |
{'me.firstname': {'like': '%' + pattern + '%'}}, |
25 |
{["me."+field]: {'like': '%' + pattern + '%'}} |
27 |
{'me.cardnumber': {'like': pattern + '%'}}, |
26 |
); |
28 |
] |
27 |
}); |
29 |
); |
28 |
subquery_and.push(subquery_or); |
30 |
}); |
29 |
}); |
31 |
let q = {"-and": subquery_and}; |
30 |
let q = {"-and": subquery_and}; |
32 |
let params = { |
31 |
let params = { |
33 |
- |
|
|