|
Lines 147-153
Link Here
|
| 147 |
[% END %] |
147 |
[% END %] |
| 148 |
</div> |
148 |
</div> |
| 149 |
|
149 |
|
| 150 |
<h3 style="display: none;">Patrons found for: <span class="searchpattern"></span></h3> |
150 |
<h3 style="display: none;" class="search_description" data-prefix="[% I18N.t("Patrons found for: %s") %]"></h3> |
| 151 |
|
151 |
|
| 152 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
152 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
| 153 |
<div class="info alert alert-info" style="display: none; margin: 1em 0;"></div> |
153 |
<div class="info alert alert-info" style="display: none; margin: 1em 0;"></div> |
|
Lines 422-427
Link Here
|
| 422 |
}; |
422 |
}; |
| 423 |
[% END %] |
423 |
[% END %] |
| 424 |
|
424 |
|
|
|
425 |
let additional_search_descriptions = {}; |
| 426 |
[% IF display_search_description %] |
| 427 |
additional_search_descriptions = { |
| 428 |
main: function(){ |
| 429 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 430 |
let patron_search_form = get_patron_search_form(); |
| 431 |
let searched = ""; |
| 432 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
| 433 |
if ( pattern ) { |
| 434 |
let field = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
| 435 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
| 436 |
searched += _("%s starting with '%s'".format(field, pattern)); |
| 437 |
} else { |
| 438 |
searched += _("%s containing '%s'".format(field, pattern)); |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
| 443 |
searched += _(" with sort1 ") |
| 444 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
| 445 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
| 446 |
} |
| 447 |
else { |
| 448 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
| 449 |
} |
| 450 |
} |
| 451 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
| 452 |
searched += _(" with sort2 ") |
| 453 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
| 454 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
| 455 |
} |
| 456 |
else { |
| 457 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
| 458 |
} |
| 459 |
} |
| 460 |
return searched; |
| 461 |
}, |
| 462 |
surname: function(){ |
| 463 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 464 |
let start_with = parent_block.find(".firstletter_filter").val() |
| 465 |
if (!start_with) return ""; |
| 466 |
return _("Surname begins with '%s'".format(start_with)); |
| 467 |
}, |
| 468 |
}; |
| 469 |
[% END %] |
| 470 |
|
| 425 |
[% UNLESS default_sort_column %] |
471 |
[% UNLESS default_sort_column %] |
| 426 |
[% default_sort_column = "name" %] |
472 |
[% default_sort_column = "name" %] |
| 427 |
[% END %] |
473 |
[% END %] |
|
Lines 734-740
Link Here
|
| 734 |
}, |
780 |
}, |
| 735 |
[% END %] |
781 |
[% END %] |
| 736 |
fixedHeader: false, |
782 |
fixedHeader: false, |
| 737 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters, undefined, external_filter_nodes); |
783 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters, undefined, external_filter_nodes, parent_block.find(".search_description"), additional_search_descriptions ); |
| 738 |
|
784 |
|
| 739 |
patron_search_form.on('submit', filter); |
785 |
patron_search_form.on('submit', filter); |
| 740 |
patron_search_form.on('submit', update_search_type); |
786 |
patron_search_form.on('submit', update_search_type); |
|
Lines 780-786
Link Here
|
| 780 |
patron_search_form.find(".clear_search").on("click",function(e){ |
826 |
patron_search_form.find(".clear_search").on("click",function(e){ |
| 781 |
e.preventDefault(); |
827 |
e.preventDefault(); |
| 782 |
clearFilters(); |
828 |
clearFilters(); |
| 783 |
parent_block.find(".searchpattern").parent().hide(); |
|
|
| 784 |
}); |
829 |
}); |
| 785 |
|
830 |
|
| 786 |
let loaded_from_state = patrons_table.data('loaded_from_state'); |
831 |
let loaded_from_state = patrons_table.data('loaded_from_state'); |
|
Lines 813-863
Link Here
|
| 813 |
$("#searchtype").val($("#searchtype_filter").val()); |
858 |
$("#searchtype").val($("#searchtype_filter").val()); |
| 814 |
} |
859 |
} |
| 815 |
|
860 |
|
| 816 |
function update_search_description(){ |
|
|
| 817 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 818 |
let patron_search_form = get_patron_search_form(); |
| 819 |
var searched = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
| 820 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
| 821 |
if ( pattern ) { |
| 822 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
| 823 |
searched += _(" starting with "); |
| 824 |
} else { |
| 825 |
searched += _(" containing "); |
| 826 |
} |
| 827 |
searched += "'" + pattern + "'"; |
| 828 |
} |
| 829 |
let firstletter_filter = parent_block.find(".firstletter_filter").val(); |
| 830 |
if ( firstletter_filter ) { |
| 831 |
searched += _(" begins with ") + "'" + firstletter_filter +"'"; |
| 832 |
} |
| 833 |
|
| 834 |
if ( patron_search_form.find(".categorycode_filter").val() ) { |
| 835 |
searched += _(" with category ") + "'" + patron_search_form.find(".categorycode_filter option:selected").text() + "'"; |
| 836 |
} |
| 837 |
if ( patron_search_form.find(".branchcode_filter").val() ) { |
| 838 |
searched += _(" in library ") + patron_search_form.find(".branchcode_filter option:selected").text(); |
| 839 |
} |
| 840 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
| 841 |
searched += _(" with sort1 ") |
| 842 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
| 843 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
| 844 |
} |
| 845 |
else { |
| 846 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
| 847 |
} |
| 848 |
} |
| 849 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
| 850 |
searched += _(" with sort2 ") |
| 851 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
| 852 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
| 853 |
} |
| 854 |
else { |
| 855 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
| 856 |
} |
| 857 |
} |
| 858 |
parent_block.find(".searchpattern").text(searched).parent().show(); |
| 859 |
} |
| 860 |
|
| 861 |
function filter() { |
861 |
function filter() { |
| 862 |
let parent_block = $("#[% search_results_block_id | html %]"); |
862 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 863 |
let patron_search_form = get_patron_search_form(); |
863 |
let patron_search_form = get_patron_search_form(); |
|
Lines 906-914
Link Here
|
| 906 |
patrons_table.data('loaded_from_state', false); |
906 |
patrons_table.data('loaded_from_state', false); |
| 907 |
first_draw = 1; // Only redirect if we are coming from here |
907 |
first_draw = 1; // Only redirect if we are coming from here |
| 908 |
table_dt.draw(); |
908 |
table_dt.draw(); |
| 909 |
[% IF display_search_description %] |
|
|
| 910 |
update_search_description(); |
| 911 |
[% END %] |
| 912 |
return false; |
909 |
return false; |
| 913 |
} |
910 |
} |
| 914 |
|
911 |
|
|
Lines 928-936
Link Here
|
| 928 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
925 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
| 929 |
[% END %] |
926 |
[% END %] |
| 930 |
$("#[% table_id | html %]_search_results").hide(); |
927 |
$("#[% table_id | html %]_search_results").hide(); |
| 931 |
[% IF display_search_description %] |
|
|
| 932 |
update_search_description(); |
| 933 |
[% END %] |
| 934 |
} |
928 |
} |
| 935 |
|
929 |
|
| 936 |
// User has clicked on a letter |
930 |
// User has clicked on a letter |
|
Lines 947-955
Link Here
|
| 947 |
[% END %] |
941 |
[% END %] |
| 948 |
|
942 |
|
| 949 |
patrons_table.DataTable().draw(); |
943 |
patrons_table.DataTable().draw(); |
| 950 |
[% IF display_search_description %] |
|
|
| 951 |
update_search_description(); |
| 952 |
[% END %] |
| 953 |
} |
944 |
} |
| 954 |
|
945 |
|
| 955 |
// modify parent window owner element |
946 |
// modify parent window owner element |