View | Details | Raw Unified | Return to bug 34083
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js (-6 / +18 lines)
Lines 15-33 function patron_autocomplete(node, options) { Link Here
15
    }
15
    }
16
    return node.autocomplete({
16
    return node.autocomplete({
17
        source: function( request, response ) {
17
        source: function( request, response ) {
18
            let subquery_and = [];
18
            let q = []
19
20
            // Add each pattern in search term for each search field
21
            let pattern_subquery_and = [];
19
            request.term.split(/[\s,]+/)
22
            request.term.split(/[\s,]+/)
20
                .filter(function(s){ return s.length })
23
                .filter(function(s){ return s.length })
21
                .forEach(function(pattern,i){
24
                .forEach(function(pattern,i){
22
                    let subquery_or = [];
25
                    let pattern_subquery_or = [];
23
                    defaultPatronSearchFields.split(',').forEach(function(field,i){
26
                    defaultPatronSearchFields.split(',').forEach(function(field,i){
24
                        subquery_or.push(
27
                        pattern_subquery_or.push(
25
                            {["me."+field]: {'like': pattern + '%'}}
28
                            {["me."+field]: {'like': pattern + '%'}}
26
                        );
29
                        );
27
                    });
30
                    });
28
                    subquery_and.push(subquery_or);
31
                    pattern_subquery_and.push(pattern_subquery_or);
29
                });
32
                });
30
            let q = {"-and": subquery_and};
33
            q.push({ "-and": pattern_subquery_and });
34
35
            // Add full search term for each search field
36
            let term_subquery_or = [];
37
            defaultPatronSearchFields.split(',').forEach(function (field, i) {
38
                term_subquery_or.push(
39
                    { ["me." + field]: { 'like': request.term + '%' } }
40
                );
41
            });
42
            q.push({ "-or": term_subquery_or });
43
31
            let params = {
44
            let params = {
32
                '_page': 1,
45
                '_page': 1,
33
                '_per_page': 10,
46
                '_per_page': 10,
34
- 

Return to bug 34083