Bugzilla – Attachment 158396 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: Preparation: buildPatronSearchQuery
Bug-34058-Preparation-buildPatronSearchQuery.patch (text/plain), 4.73 KB, created by
Katrin Fischer
on 2023-11-04 18:20:44 UTC
(
hide
)
Description:
Bug 34058: Preparation: buildPatronSearchQuery
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-11-04 18:20:44 UTC
Size:
4.73 KB
patch
obsolete
>From 605e42df07e1306af3cd05982d4818510e74e53c Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Tue, 27 Jun 2023 09:07:49 +0000 >Subject: [PATCH] Bug 34058: Preparation: buildPatronSearchQuery > >Add table_prefix argument to buildPatronSearchQuery. >This allows the buildPatronSearchQuery function to also perform the search >on a related table, instead of the default patron table. >This is relevant because the query will be performed on the ILL API endpoint, >so the table being searched will have to be prefixed with 'patron.', instead of the >default 'me.' > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../intranet-tmpl/prog/js/staff-global.js | 28 +++++++++++++------ > 1 file changed, 19 insertions(+), 9 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index a55b4a6455..40f175b180 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -567,13 +567,15 @@ function expandPatronSearchFields(search_fields) { > * Build patron search query > * - term: The full search term input by the user > * You can then pass a list of options: >- * - search_type: String 'contains' or 'starts_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) 'contains' or 'starts_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) contains 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 }); >@@ -583,15 +585,23 @@ function buildPatronSearchQuery(term, options) { > return q; > } > >- // 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 === "contains" ? '%' : ''; >- // 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 = expandPatronSearchFields(options.search_fields); > // If not, we use DefaultPatronSearchFields system preference instead >@@ -605,12 +615,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 > } >@@ -624,7 +634,7 @@ 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 }); >-- >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