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