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

(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-4 / +4 lines)
Lines 523-535 function expandPatronSearchFields(search_fields) { Link Here
523
            return defaultPatronSearchFields;
523
            return defaultPatronSearchFields;
524
            break;
524
            break;
525
        case 'full_address':
525
        case 'full_address':
526
            return 'streetnumber,streettype,address,address2,city,state,zipcode,country';
526
            return 'streetnumber|streettype|address|address2|city|state|zipcode|country';
527
            break;
527
            break;
528
        case 'all_emails':
528
        case 'all_emails':
529
            return 'email,emailpro,B_email';
529
            return 'email|emailpro|B_email';
530
            break;
530
            break;
531
        case 'all_phones':
531
        case 'all_phones':
532
            return 'phone,phonepro,B_phone,altcontactphone,mobile';
532
            return 'phone|phonepro|B_phone|altcontactphone|mobile';
533
            break;
533
            break;
534
        default:
534
        default:
535
            return search_fields;
535
            return search_fields;
Lines 595-601 function buildPatronSearchQuery(term, options) { Link Here
595
595
596
    // Add full search term for each search field
596
    // Add full search term for each search field
597
    let term_subquery_or = [];
597
    let term_subquery_or = [];
598
    search_fields.split('|').forEach(function (field, i) {
598
    search_fields.split('\|').forEach(function (field, i) {
599
        term_subquery_or.push(
599
        term_subquery_or.push(
600
            { ["me." + field]: { 'like': leading_wildcard + term + '%' } }
600
            { ["me." + field]: { 'like': leading_wildcard + term + '%' } }
601
        );
601
        );
(-)a/t/db_dependent/selenium/patrons_search.t (-5 / +4 lines)
Lines 170-187 subtest 'Search patrons' => sub { Link Here
170
    $driver->get( $base_url . "/members/members-home.pl" );
170
    $driver->get( $base_url . "/members/members-home.pl" );
171
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
171
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
172
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
172
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
173
    is( $adv_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
173
    is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"');
174
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
174
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
175
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
175
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
176
    is( $filter_options[0]->get_value(), 'firstname|middle_name|surname|othernames|cardnumber|userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
176
    is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set');
177
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials");
177
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials");
178
    $driver->get( $base_url . "/members/members-home.pl" );
178
    $driver->get( $base_url . "/members/members-home.pl" );
179
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
179
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
180
    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');
180
    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');
181
    is( $adv_options[0]->get_value(), 'firstname|initials', 'Standard search uses DefaultPatronSearchFields when populated');
181
    is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"');
182
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
182
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
183
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
183
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
184
    is( $filter_options[0]->get_value(), 'firstname|initials', 'Standard filter uses DefaultPatronSearchFields when populated');
184
    is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"');
185
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses");
185
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials|horses");
186
    $driver->get( $base_url . "/members/members-home.pl" );
186
    $driver->get( $base_url . "/members/members-home.pl" );
187
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
187
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
188
- 

Return to bug 33428