Bugzilla – Attachment 152701 Details for
Bug 34058
ILL - Left filters not considering all terms in input
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34058: WIP
Bug-34058-WIP.patch (text/plain), 6.17 KB, created by
Pedro Amorim
on 2023-06-26 16:49:58 UTC
(
hide
)
Description:
Bug 34058: WIP
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-06-26 16:49:58 UTC
Size:
6.17 KB
patch
obsolete
>From fc945e4df79e2fadce895ef04d62ca871347181e Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Mon, 26 Jun 2023 16:49:38 +0000 >Subject: [PATCH] Bug 34058: WIP > >Patron search is now considering all inputs using new buildSearchPatronQuery >Still missing keyword input >--- > .../intranet-tmpl/prog/js/ill-list-table.js | 18 ++++------- > .../intranet-tmpl/prog/js/staff-global.js | 31 +++++++++++++------ > 2 files changed, 27 insertions(+), 22 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >index 61ed8aaa45..712b4a7fd5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >@@ -89,19 +89,13 @@ $(document).ready(function() { > if (!patron && !status) return ""; > > if(patron){ >- const patron_search_fields = "me.borrowernumber,patron.cardnumber,patron.firstname,patron.surname"; >- patron_search_fields.split(',').forEach(function(attr){ >- let operator = "="; >- let patron_data = patron; >- if ( attr != "me.borrowernumber" && attr != "patron.cardnumber") { >- operator = "like"; >- patron_data = "%" + patron + "%"; >+ let patronquery = buildPatronSearchQuery( >+ patron, >+ { >+ table_prefix: 'patron', > } >- patron_sub_or.push({ >- [attr]:{[operator]: patron_data } >- }); >- }); >- subquery_and.push(patron_sub_or); >+ ); >+ subquery_and.push(patronquery); > } > > if(status){ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 3ab3a006dd..736320391a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -514,13 +514,15 @@ function patron_autocomplete(node, options) { > * Build patron search query > * - term: The full search term input by the user > * You can then pass a list of options: >- * - search_type: String 'contain' or 'start_with', defaults to DefaultPatronSearchMethod system preference >- * - search_fields: String comma-separated list of specific fields, defaults to DefaultPatronSearchFields system preference >- * - extended_attribute_types: JSON object containing the patron attribute types to be searched on >+ * - search_type: (String) 'contain' or 'start_with', defaults to defaultPatronSearchMethod (see js_includes.inc) >+ * - search_fields: (String) comma-separated list of specific fields, defaults to defaultPatronSearchFields (see js_includes.inc) >+ * - extended_attribute_types: (JSON object) containing the patron searchable attribute types to be searched on (see patron-search.inc) >+ * - table_prefix: (String) table name to prefix the fields with, defaults to 'me' > */ > function buildPatronSearchQuery(term, options) { > > let q = []; >+ let table_prefix; > let leading_wildcard; > let search_fields; > let patterns = term.split(/[\s,]+/).filter(function (s) { return s.length }); >@@ -530,18 +532,26 @@ function buildPatronSearchQuery(term, options) { > return; > } > >- // Leading wildcard: If search_type option exists, we use that >+ // Table prefix: If table_prefix options exists, use that >+ if (typeof options !== 'undefined' && options.table_prefix) { >+ table_prefix = options.table_prefix; >+ // If not, default to 'me' >+ } else { >+ table_prefix = 'me'; >+ } >+ >+ // Leading wildcard: If search_type option exists, use that > if (typeof options !== 'undefined' && options.search_type) { > leading_wildcard = options.search_type === "contain" ? '%' : ''; >- // If not, we use DefaultPatronSearchMethod system preference instead >+ // If not, use DefaultPatronSearchMethod system preference instead > } else { > leading_wildcard = defaultPatronSearchMethod === 'contains' ? '%' : ''; > } > >- // Search fields: If search_fields option exists, we use that >+ // Search fields: If search_fields option exists, use that > if (typeof options !== 'undefined' && options.search_fields) { > search_fields = options.search_fields; >- // If not, we use DefaultPatronSearchFields system preference instead >+ // If not, use DefaultPatronSearchFields system preference instead > } else { > search_fields = defaultPatronSearchFields; > } >@@ -552,12 +562,12 @@ function buildPatronSearchQuery(term, options) { > let pattern_subquery_or = []; > search_fields.split(',').forEach(function (field, i) { > pattern_subquery_or.push( >- { ["me." + field]: { 'like': leading_wildcard + pattern + '%' } } >+ { [table_prefix + "." + field]: { 'like': leading_wildcard + pattern + '%' } } > ); > if (field == 'dateofbirth') { > try { > let d = $date_to_rfc3339(pattern); >- pattern_subquery_or.push({ ["me." + field]: d }); >+ pattern_subquery_or.push({ [table_prefix + "." + field]: d }); > } catch { > // Hide the warning if the date is not correct > } >@@ -571,12 +581,13 @@ function buildPatronSearchQuery(term, options) { > let term_subquery_or = []; > search_fields.split(',').forEach(function (field, i) { > term_subquery_or.push( >- { ["me." + field]: { 'like': leading_wildcard + term + '%' } } >+ { [table_prefix + "." + field]: { 'like': leading_wildcard + term + '%' } } > ); > }); > q.push({ "-or": term_subquery_or }); > > // Add each pattern for each extended patron attributes >+ // extendedPatronAttributes: ExtendedPatronAttributes system preference (see js_includes.inc) > if (typeof options !== 'undefined' && options.extended_attribute_types && extendedPatronAttributes) { > extended_attribute_subquery_and = []; > patterns.forEach(function (pattern, i) { >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34058
:
152701
|
152709
|
152710
|
152867
|
152868
|
153391
|
153392
|
156375
|
156376
|
156732
|
156733
|
158396
|
158397
|
158743
|
158744