|
Lines 149-155
Link Here
|
| 149 |
[% END %] |
149 |
[% END %] |
| 150 |
</div> |
150 |
</div> |
| 151 |
|
151 |
|
| 152 |
<h3 style="display: none;">Patrons found for: <span class="searchpattern"></span></h3> |
152 |
<h3 style="display: none;" class="search_description" data-prefix="[% I18N.t("Patrons found for: %s") %]"></h3> |
| 153 |
|
153 |
|
| 154 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
154 |
<div id="[% table_id | html %]_search_results" style="display:none;"> |
| 155 |
|
155 |
|
|
Lines 412-417
Link Here
|
| 412 |
} |
412 |
} |
| 413 |
}; |
413 |
}; |
| 414 |
|
414 |
|
|
|
415 |
let additional_search_descriptions = {}; |
| 416 |
[% IF display_search_description %] |
| 417 |
additional_search_descriptions = { |
| 418 |
main: function(){ |
| 419 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 420 |
let patron_search_form = get_patron_search_form(); |
| 421 |
let searched = ""; |
| 422 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
| 423 |
if ( pattern ) { |
| 424 |
let field = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
| 425 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
| 426 |
searched += _("%s starting with '%s'".format(field, pattern)); |
| 427 |
} else { |
| 428 |
searched += _("%s containing '%s'".format(field, pattern)); |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
| 433 |
searched += _(" with sort1 ") |
| 434 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
| 435 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
| 436 |
} |
| 437 |
else { |
| 438 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
| 439 |
} |
| 440 |
} |
| 441 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
| 442 |
searched += _(" with sort2 ") |
| 443 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
| 444 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
| 445 |
} |
| 446 |
else { |
| 447 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
| 448 |
} |
| 449 |
} |
| 450 |
return searched; |
| 451 |
}, |
| 452 |
surname: function(){ |
| 453 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 454 |
let start_with = parent_block.find(".firstletter_filter").val() |
| 455 |
if (!start_with) return ""; |
| 456 |
return _("Surname begins with '%s'".format(start_with)); |
| 457 |
}, |
| 458 |
}; |
| 459 |
[% END %] |
| 460 |
|
| 415 |
[% UNLESS default_sort_column %] |
461 |
[% UNLESS default_sort_column %] |
| 416 |
[% default_sort_column = "name" %] |
462 |
[% default_sort_column = "name" %] |
| 417 |
[% END %] |
463 |
[% END %] |
|
Lines 727-733
Link Here
|
| 727 |
}, |
773 |
}, |
| 728 |
[% END %] |
774 |
[% END %] |
| 729 |
fixedHeader: false, |
775 |
fixedHeader: false, |
| 730 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters); |
776 |
}, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters, undefined, parent_block.find(".search_description"), additional_search_descriptions ); |
| 731 |
|
777 |
|
| 732 |
patron_search_form.on('submit', filter); |
778 |
patron_search_form.on('submit', filter); |
| 733 |
patron_search_form.on('submit', update_search_type); |
779 |
patron_search_form.on('submit', update_search_type); |
|
Lines 773-779
Link Here
|
| 773 |
patron_search_form.find(".clear_search").on("click",function(e){ |
819 |
patron_search_form.find(".clear_search").on("click",function(e){ |
| 774 |
e.preventDefault(); |
820 |
e.preventDefault(); |
| 775 |
clearFilters(); |
821 |
clearFilters(); |
| 776 |
patron_search_form.find(".searchpattern").parent().hide(); |
|
|
| 777 |
}); |
822 |
}); |
| 778 |
|
823 |
|
| 779 |
let table_dt = patrons_table.DataTable(); |
824 |
let table_dt = patrons_table.DataTable(); |
|
Lines 807-857
Link Here
|
| 807 |
$("#searchtype").val($("#searchtype_filter").val()); |
852 |
$("#searchtype").val($("#searchtype_filter").val()); |
| 808 |
} |
853 |
} |
| 809 |
|
854 |
|
| 810 |
function update_search_description(){ |
|
|
| 811 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 812 |
let patron_search_form = get_patron_search_form(); |
| 813 |
var searched = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
| 814 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
| 815 |
if ( pattern ) { |
| 816 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
| 817 |
searched += _(" starting with "); |
| 818 |
} else { |
| 819 |
searched += _(" containing "); |
| 820 |
} |
| 821 |
searched += "'" + pattern + "'"; |
| 822 |
} |
| 823 |
let firstletter_filter = parent_block.find(".firstletter_filter").val(); |
| 824 |
if ( firstletter_filter ) { |
| 825 |
searched += _(" begins with ") + "'" + firstletter_filter +"'"; |
| 826 |
} |
| 827 |
|
| 828 |
if ( patron_search_form.find(".categorycode_filter").val() ) { |
| 829 |
searched += _(" with category ") + "'" + patron_search_form.find(".categorycode_filter option:selected").text() + "'"; |
| 830 |
} |
| 831 |
if ( patron_search_form.find(".branchcode_filter").val() ) { |
| 832 |
searched += _(" in library ") + patron_search_form.find(".branchcode_filter option:selected").text(); |
| 833 |
} |
| 834 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
| 835 |
searched += _(" with sort1 ") |
| 836 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
| 837 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
| 838 |
} |
| 839 |
else { |
| 840 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
| 841 |
} |
| 842 |
} |
| 843 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
| 844 |
searched += _(" with sort2 ") |
| 845 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
| 846 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
| 847 |
} |
| 848 |
else { |
| 849 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
| 850 |
} |
| 851 |
} |
| 852 |
parent_block.find(".searchpattern").text(searched).parent().show(); |
| 853 |
} |
| 854 |
|
| 855 |
function filter() { |
855 |
function filter() { |
| 856 |
let parent_block = $("#[% search_results_block_id | html %]"); |
856 |
let parent_block = $("#[% search_results_block_id | html %]"); |
| 857 |
let patron_search_form = get_patron_search_form(); |
857 |
let patron_search_form = get_patron_search_form(); |
|
Lines 900-908
Link Here
|
| 900 |
table_dt.settings()[0].loaded_from_state = false; |
900 |
table_dt.settings()[0].loaded_from_state = false; |
| 901 |
first_draw = 1; // Only redirect if we are coming from here |
901 |
first_draw = 1; // Only redirect if we are coming from here |
| 902 |
table_dt.draw(); |
902 |
table_dt.draw(); |
| 903 |
[% IF display_search_description %] |
|
|
| 904 |
update_search_description(); |
| 905 |
[% END %] |
| 906 |
return false; |
903 |
return false; |
| 907 |
} |
904 |
} |
| 908 |
|
905 |
|
|
Lines 922-930
Link Here
|
| 922 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
919 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
| 923 |
[% END %] |
920 |
[% END %] |
| 924 |
$("#[% table_id | html %]_search_results").hide(); |
921 |
$("#[% table_id | html %]_search_results").hide(); |
| 925 |
[% IF display_search_description %] |
|
|
| 926 |
update_search_description(); |
| 927 |
[% END %] |
| 928 |
} |
922 |
} |
| 929 |
|
923 |
|
| 930 |
// User has clicked on a letter |
924 |
// User has clicked on a letter |
|
Lines 941-949
Link Here
|
| 941 |
[% END %] |
935 |
[% END %] |
| 942 |
|
936 |
|
| 943 |
patrons_table.DataTable().draw(); |
937 |
patrons_table.DataTable().draw(); |
| 944 |
[% IF display_search_description %] |
|
|
| 945 |
update_search_description(); |
| 946 |
[% END %] |
| 947 |
} |
938 |
} |
| 948 |
|
939 |
|
| 949 |
// modify parent window owner element |
940 |
// modify parent window owner element |