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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-6 / +25 lines)
Lines 195-200 Link Here
195
    [% Asset.js("lib/hc-sticky.js") | $raw %]
195
    [% Asset.js("lib/hc-sticky.js") | $raw %]
196
    [% Asset.js("js/members-menu.js") | $raw %]
196
    [% Asset.js("js/members-menu.js") | $raw %]
197
    <script>
197
    <script>
198
        var dtMemberResults;
199
        var search = 1;
200
        /* popstate event triggered by forward and back button. Need to refresh search */
201
        window.addEventListener('popstate', (event) => {
202
            getSearchByLocation();
203
        });
204
198
        $(document).ready(function() {
205
        $(document).ready(function() {
199
            $('#merge-patrons').prop('disabled', true);
206
            $('#merge-patrons').prop('disabled', true);
200
            $('#memberresultst').on('change', 'input.selection', function() {
207
            $('#memberresultst').on('change', 'input.selection', function() {
Lines 312-322 Link Here
312
            });
319
            });
313
            $("#searchform").on("submit", filter);
320
            $("#searchform").on("submit", filter);
314
321
315
        });
316
317
        var dtMemberResults;
318
        var search = 1;
319
        $(document).ready(function() {
320
            [% IF searchmember %]
322
            [% IF searchmember %]
321
                $("#searchmember_filter").val("[% searchmember | html %]");
323
                $("#searchmember_filter").val("[% searchmember | html %]");
322
            [% END %]
324
            [% END %]
Lines 419-424 Link Here
419
                            // redirect if there is only 1 result.
421
                            // redirect if there is only 1 result.
420
                            if ( json.aaData.length == 1 ) {
422
                            if ( json.aaData.length == 1 ) {
421
                                var borrowernumber = json.aaData[0].borrowernumber;
423
                                var borrowernumber = json.aaData[0].borrowernumber;
424
                                /* remove any search string added by firstletter search since only one result was returned */
425
                                history.pushState( {}, null, window.location.href.split("?" )[0]);
422
                                document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
426
                                document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
423
                                return false;
427
                                return false;
424
                            }
428
                            }
Lines 461-468 Link Here
461
                }
465
                }
462
            }, columns_settings);
466
            }, columns_settings);
463
            update_searched();
467
            update_searched();
468
            /* Initial page load doesn't trigger the popstate event, so we explicitly call this */
469
            getSearchByLocation();
470
464
        });
471
        });
465
472
473
        function getSearchByLocation(){
474
            if( location.search != ""){
475
                var params = new URLSearchParams( location.search );
476
                var firstletter = params.get("firstletter");
477
                if( firstletter ){
478
                    filterByFirstLetterSurname( firstletter );
479
                }
480
            }
481
        }
482
466
        // Update the string "Results found ..."
483
        // Update the string "Results found ..."
467
        function update_searched(){
484
        function update_searched(){
468
            var searched = $("#searchfieldstype_filter").find("option:selected").text();
485
            var searched = $("#searchfieldstype_filter").find("option:selected").text();
Lines 502-507 Link Here
502
            $("#firstletter_filter").val('');
519
            $("#firstletter_filter").val('');
503
            $("#searchmember_filter").val('');
520
            $("#searchmember_filter").val('');
504
            if(redraw) {
521
            if(redraw) {
522
                /* remove any search string added by firstletter search */
523
                history.pushState( {}, null, window.location.href.split("?" )[0]);
505
                search = 1;
524
                search = 1;
506
                $("#searchresults").show();
525
                $("#searchresults").show();
507
                dtMemberResults.fnDraw();
526
                dtMemberResults.fnDraw();
Lines 512-517 Link Here
512
        function filterByFirstLetterSurname(letter) {
531
        function filterByFirstLetterSurname(letter) {
513
            clearFilters(false);
532
            clearFilters(false);
514
            $("#firstletter_filter").val(letter);
533
            $("#firstletter_filter").val(letter);
534
            history.pushState( null, null, "?firstletter=" + letter );
515
            update_searched();
535
            update_searched();
516
            search = 1;
536
            search = 1;
517
            $("#searchresults").show();
537
            $("#searchresults").show();
518
- 

Return to bug 27725