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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-1 / +2 lines)
Lines 307-318 Link Here
307
                    let search_fields = $("#searchfieldstype_filter").val();
307
                    let search_fields = $("#searchfieldstype_filter").val();
308
                    if ( !search_fields ) {
308
                    if ( !search_fields ) {
309
                        search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' | html %]";
309
                        search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' | html %]";
310
                        search_fields.replaceAll('\|', ',');
310
                    }
311
                    }
311
312
312
                    let subquery_and = [];
313
                    let subquery_and = [];
313
                    patterns.forEach(function(pattern,i){
314
                    patterns.forEach(function(pattern,i){
314
                        let sub_or = [];
315
                        let sub_or = [];
315
                        search_fields.split('|').forEach(function(attr,ii){
316
                        search_fields.split(',').forEach(function(attr,ii){
316
                            sub_or.push({["me."+attr]:{"like":(search_type == "contain" ? "%" : "" ) + pattern + "%"}});
317
                            sub_or.push({["me."+attr]:{"like":(search_type == "contain" ? "%" : "" ) + pattern + "%"}});
317
                            if ( attr == 'dateofbirth' ) {
318
                            if ( attr == 'dateofbirth' ) {
318
                                try {
319
                                try {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc (-1 / +1 lines)
Lines 87-93 Link Here
87
        <select name="searchfieldstype" id="searchfieldstype_filter">
87
        <select name="searchfieldstype" id="searchfieldstype_filter">
88
    [% END %]
88
    [% END %]
89
        [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' %]
89
        [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' %]
90
        [% standard.replace('|', ',') %]
90
        [% standard = standard.replace('\|', ',') %]
91
        [% SET full_address = 'streetnumber,streettype,address,address2,city,state,zipcode,country' %]
91
        [% SET full_address = 'streetnumber,streettype,address,address2,city,state,zipcode,country' %]
92
        [% SET all_emails = 'email,emailpro,B_email' %]
92
        [% SET all_emails = 'email,emailpro,B_email' %]
93
        [% SET all_phones = 'phone,phonepro,B_phone,altcontactphone,mobile' %]
93
        [% SET all_phones = 'phone,phonepro,B_phone,altcontactphone,mobile' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js (-1 / +1 lines)
Lines 20-26 function patron_autocomplete(node, options) { Link Here
20
                .filter(function(s){ return s.length })
20
                .filter(function(s){ return s.length })
21
                .forEach(function(pattern,i){
21
                .forEach(function(pattern,i){
22
                    let subquery_or = [];
22
                    let subquery_or = [];
23
                    defaultPatronSearchFields.split('|').forEach(function(field,i){
23
                    defaultPatronSearchFields.split('\|').forEach(function(field,i){
24
                        subquery_or.push(
24
                        subquery_or.push(
25
                            {["me."+field]: {'like': pattern + '%'}}
25
                            {["me."+field]: {'like': pattern + '%'}}
26
                        );
26
                        );
(-)a/t/db_dependent/selenium/patrons_search.t (-5 / +4 lines)
Lines 161-178 subtest 'Search patrons' => sub { Link Here
161
    $driver->get( $base_url . "/members/members-home.pl" );
161
    $driver->get( $base_url . "/members/members-home.pl" );
162
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
162
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
163
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
163
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
164
    is( $adv_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
164
    is( $adv_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
165
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
165
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
166
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
166
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
167
    is( $filter_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
167
    is( $filter_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
168
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials");
168
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials");
169
    $driver->get( $base_url . "/members/members-home.pl" );
169
    $driver->get( $base_url . "/members/members-home.pl" );
170
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
170
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
171
    is( scalar @adv_options, $nb_standard_fields, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields');
171
    is( scalar @adv_options, $nb_standard_fields, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields');
172
    is( $adv_options[0]->get_value(), 'firstname|initials', 'Standard search uses DefaultPatronSearchFields when populated');
172
    is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated');
173
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
173
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
174
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
174
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
175
    is( $filter_options[0]->get_value(), 'firstname|initials', 'Standard filter uses DefaultPatronSearchFields when populated');
175
    is( $filter_options[0]->get_value(), 'firstname,initials', 'Standard filter uses DefaultPatronSearchFields when populated');
176
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses");
176
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses");
177
    $driver->get( $base_url . "/members/members-home.pl" );
177
    $driver->get( $base_url . "/members/members-home.pl" );
178
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
178
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
179
- 

Return to bug 29822