Bug 34083: Add searching for full term on patron auto-complete
To reproduce, on k-t-d: 1) Create a new patron of category 'School' 2) Enter 'Middle school high school' on the mandatory 'Name' field and put something in 'Card number:' 3) Visit patron lists at /cgi-bin/koha/patron_lists/lists.pl and click 'New patron list' 4) Put something in 'Name:' and click 'Save' 5) On the 'Patron search' input, enter 'middle school high school' slowly and observe the auto-complete behaviour 6) Notice how after you start typing the second word, the auto complete results vanish. 7) Apply patch, repeat plan and verify it now works as expected. Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
d7e189b5bf
commit
a8e9b25d8e
1 changed files with 19 additions and 6 deletions
|
@ -16,19 +16,32 @@ function patron_autocomplete(node, options) {
|
|||
}
|
||||
return node.autocomplete({
|
||||
source: function( request, response ) {
|
||||
let subquery_and = [];
|
||||
let q = []
|
||||
|
||||
// Add each pattern in search term for each search field
|
||||
let pattern_subquery_and = [];
|
||||
request.term.split(/[\s,]+/)
|
||||
.filter(function(s){ return s.length })
|
||||
.forEach(function(pattern,i){
|
||||
let subquery_or = [];
|
||||
let pattern_subquery_or = [];
|
||||
defaultPatronSearchFields.split(',').forEach(function(field,i){
|
||||
subquery_or.push(
|
||||
pattern_subquery_or.push(
|
||||
{ ["me." + field]: { 'like': leading_wildcard + pattern + '%' } }
|
||||
);
|
||||
});
|
||||
subquery_and.push(subquery_or);
|
||||
pattern_subquery_and.push(pattern_subquery_or);
|
||||
});
|
||||
let q = {"-and": subquery_and};
|
||||
q.push({ "-and": pattern_subquery_and });
|
||||
|
||||
// Add full search term for each search field
|
||||
let term_subquery_or = [];
|
||||
defaultPatronSearchFields.split(',').forEach(function (field, i) {
|
||||
term_subquery_or.push(
|
||||
{ ["me." + field]: { 'like': leading_wildcard + request.term + '%' } }
|
||||
);
|
||||
});
|
||||
q.push({ "-or": term_subquery_or });
|
||||
|
||||
let params = {
|
||||
'_page': 1,
|
||||
'_per_page': 10,
|
||||
|
|
Loading…
Reference in a new issue