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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (+1 lines)
Lines 70-75 Link Here
70
70
71
<script>
71
<script>
72
    var defaultPatronSearchFields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' | html %]";
72
    var defaultPatronSearchFields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' | html %]";
73
    defaultPatronSearchFields = defaultPatronSearchFields.replaceAll('\|', ',');
73
    var defaultPatronSearchMethod = "[% Koha.Preference('DefaultPatronSearchMethod') || 'contains' | html %]";
74
    var defaultPatronSearchMethod = "[% Koha.Preference('DefaultPatronSearchMethod') || 'contains' | html %]";
74
    var extendedPatronAttributes = "[% Koha.Preference('ExtendedPatronAttributes') | html %]";
75
    var extendedPatronAttributes = "[% Koha.Preference('ExtendedPatronAttributes') | html %]";
75
    var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]';
76
    var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]';
(-)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/staff-global.js (-2 / +2 lines)
Lines 554-560 function buildPatronSearchQuery(term, options) { Link Here
554
    let pattern_subquery_and = [];
554
    let pattern_subquery_and = [];
555
    patterns.forEach(function (pattern, i) {
555
    patterns.forEach(function (pattern, i) {
556
            let pattern_subquery_or = [];
556
            let pattern_subquery_or = [];
557
            search_fields.split('|').forEach(function (field, i) {
557
            search_fields.split(',').forEach(function (field, i) {
558
                pattern_subquery_or.push(
558
                pattern_subquery_or.push(
559
                    { ["me." + field]: { 'like': leading_wildcard + pattern + '%' } }
559
                    { ["me." + field]: { 'like': leading_wildcard + pattern + '%' } }
560
                );
560
                );
Lines 573-579 function buildPatronSearchQuery(term, options) { Link Here
573
573
574
    // Add full search term for each search field
574
    // Add full search term for each search field
575
    let term_subquery_or = [];
575
    let term_subquery_or = [];
576
    search_fields.split('|').forEach(function (field, i) {
576
    search_fields.split(',').forEach(function (field, i) {
577
        term_subquery_or.push(
577
        term_subquery_or.push(
578
            { ["me." + field]: { 'like': leading_wildcard + term + '%' } }
578
            { ["me." + field]: { 'like': leading_wildcard + term + '%' } }
579
        );
579
        );
(-)a/t/db_dependent/selenium/patrons_search.t (-5 / +4 lines)
Lines 163-180 subtest 'Search patrons' => sub { Link Here
163
    $driver->get( $base_url . "/members/members-home.pl" );
163
    $driver->get( $base_url . "/members/members-home.pl" );
164
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
164
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
165
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
165
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
166
    is( $adv_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
166
    is( $adv_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
167
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
167
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
168
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
168
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
169
    is( $filter_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
169
    is( $filter_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
170
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials");
170
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials");
171
    $driver->get( $base_url . "/members/members-home.pl" );
171
    $driver->get( $base_url . "/members/members-home.pl" );
172
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
172
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
173
    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');
173
    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');
174
    is( $adv_options[0]->get_value(), 'firstname|initials', 'Standard search uses DefaultPatronSearchFields when populated');
174
    is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated');
175
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
175
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
176
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
176
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
177
    is( $filter_options[0]->get_value(), 'firstname|initials', 'Standard filter uses DefaultPatronSearchFields when populated');
177
    is( $filter_options[0]->get_value(), 'firstname,initials', 'Standard filter uses DefaultPatronSearchFields when populated');
178
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses");
178
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses");
179
    $driver->get( $base_url . "/members/members-home.pl" );
179
    $driver->get( $base_url . "/members/members-home.pl" );
180
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
180
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
181
- 

Return to bug 29822