From 014c3a74686e92f4f48cfa0a1c7c65153ce5142b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Feb 2022 14:49:51 +0100 Subject: [PATCH] Bug 30055: Restore DefaultPatronSearchFields and fix extended attrs search MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We lost the DefaultPatronSearchFields behaviour, we don't want to search on all data but only DefaultPatronSearchFields Signed-off-by: Tomas Cohen Arazi Signed-off-by: Séverine Queune Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- .../prog/en/modules/members/search.tt | 16 +++++++++------- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt index c1b16a8d22..2fe0fea462 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt @@ -165,20 +165,22 @@ if (!start_with) return ""; return { "like": start_with + "%" } }, - [% IF Koha.Preference('ExtendedPatronAttributes') %] - "-or": function(){ + "-and": function(){ let filter = $("#searchmember_filter").val(); if (!filter) return ""; + [% SET search_fields = Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' %] return [ + [% FOR search_field IN search_fields.split(',') %] + {"me.[% search_field %]":{"like":"%"+filter+"%"}}, + [% END %] + [% IF Koha.Preference('ExtendedPatronAttributes') %] { - "extended_attributes.value": { "like": "%" + filter + "%" } - }, - { + "extended_attributes.value": { "like": "%" + filter + "%" }, "extended_attributes.code": extended_attribute_types } + [% END %] ]; }, - [% END %] }; patrons_table = $("#memberresultst").kohaTable({ "ajax": { @@ -344,7 +346,7 @@ table_dt.column([% loop.count - 1 %]).search(category_id); [% END %] [% END %] - table_dt.search($("#searchmember_filter").val()); + table_dt.search(""); table_dt.draw(); return false; } diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index ffeea60161..077af2ca87 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -618,6 +618,8 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { // It's not the usual DBIC notation! if ( f == '-or' ) { if (v) or_query_parameters.push(v) + } else if ( f == '-and' ) { + if (v) and_query_parameters.push(v) } else if ( v ) { additional_filters[k] = v; } -- 2.39.5