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 419-424
Link Here
|
419 |
}; |
419 |
}; |
420 |
[% END %] |
420 |
[% END %] |
421 |
|
421 |
|
|
|
422 |
let additional_search_descriptions = {}; |
423 |
[% IF display_search_description %] |
424 |
additional_search_descriptions = { |
425 |
main: function(){ |
426 |
let parent_block = $("#[% search_results_block_id | html %]"); |
427 |
let patron_search_form = get_patron_search_form(); |
428 |
let searched = ""; |
429 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
430 |
if ( pattern ) { |
431 |
let field = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
432 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
433 |
searched += _("%s starting with '%s'".format(field, pattern)); |
434 |
} else { |
435 |
searched += _("%s containing '%s'".format(field, pattern)); |
436 |
} |
437 |
} |
438 |
|
439 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
440 |
searched += _(" with sort1 ") |
441 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
442 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
443 |
} |
444 |
else { |
445 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
446 |
} |
447 |
} |
448 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
449 |
searched += _(" with sort2 ") |
450 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
451 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
452 |
} |
453 |
else { |
454 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
455 |
} |
456 |
} |
457 |
return searched; |
458 |
}, |
459 |
surname: function(){ |
460 |
let parent_block = $("#[% search_results_block_id | html %]"); |
461 |
let start_with = parent_block.find(".firstletter_filter").val() |
462 |
if (!start_with) return ""; |
463 |
return _("Surname begins with '%s'".format(start_with)); |
464 |
}, |
465 |
}; |
466 |
[% END %] |
467 |
|
422 |
[% UNLESS default_sort_column %] |
468 |
[% UNLESS default_sort_column %] |
423 |
[% default_sort_column = "name" %] |
469 |
[% default_sort_column = "name" %] |
424 |
[% END %] |
470 |
[% 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 table_dt = patrons_table.DataTable(); |
827 |
let table_dt = patrons_table.DataTable(); |
Lines 810-860
Link Here
|
810 |
$("#searchtype").val($("#searchtype_filter").val()); |
855 |
$("#searchtype").val($("#searchtype_filter").val()); |
811 |
} |
856 |
} |
812 |
|
857 |
|
813 |
function update_search_description(){ |
|
|
814 |
let parent_block = $("#[% search_results_block_id | html %]"); |
815 |
let patron_search_form = get_patron_search_form(); |
816 |
var searched = patron_search_form.find(".searchfieldstype_filter").find("option:selected").text(); |
817 |
let pattern = patron_search_form.find(".search_patron_filter").val(); |
818 |
if ( pattern ) { |
819 |
if ( patron_search_form.find(".searchtype_filter").val() == 'starts_with' ) { |
820 |
searched += _(" starting with "); |
821 |
} else { |
822 |
searched += _(" containing "); |
823 |
} |
824 |
searched += "'" + pattern + "'"; |
825 |
} |
826 |
let firstletter_filter = parent_block.find(".firstletter_filter").val(); |
827 |
if ( firstletter_filter ) { |
828 |
searched += _(" begins with ") + "'" + firstletter_filter +"'"; |
829 |
} |
830 |
|
831 |
if ( patron_search_form.find(".categorycode_filter").val() ) { |
832 |
searched += _(" with category ") + "'" + patron_search_form.find(".categorycode_filter option:selected").text() + "'"; |
833 |
} |
834 |
if ( patron_search_form.find(".branchcode_filter").val() ) { |
835 |
searched += _(" in library ") + patron_search_form.find(".branchcode_filter option:selected").text(); |
836 |
} |
837 |
if ( patron_search_form.find("select[name='sort1_filter']").val() ) { |
838 |
searched += _(" with sort1 ") |
839 |
if ( patron_search_form.find("select[name='sort1_filter']") ) { |
840 |
searched += patron_search_form.find("select[name='sort1_filter'] option:selected").text(); |
841 |
} |
842 |
else { |
843 |
searched += paron_search_form.find("select[name='sort1_filter']").val(); |
844 |
} |
845 |
} |
846 |
if ( patron_search_form.find("select[name='sort2_filter']").val() ) { |
847 |
searched += _(" with sort2 ") |
848 |
if ( patron_search_form.find("select[name='sort2_filter']") ) { |
849 |
searched += patron_search_form.find("select[name='sort2_filter'] option:selected").text(); |
850 |
} |
851 |
else { |
852 |
searched += paron_search_form.find("select[name='sort2_filter']").val(); |
853 |
} |
854 |
} |
855 |
parent_block.find(".searchpattern").text(searched).parent().show(); |
856 |
} |
857 |
|
858 |
function filter() { |
858 |
function filter() { |
859 |
let parent_block = $("#[% search_results_block_id | html %]"); |
859 |
let parent_block = $("#[% search_results_block_id | html %]"); |
860 |
let patron_search_form = get_patron_search_form(); |
860 |
let patron_search_form = get_patron_search_form(); |
Lines 903-911
Link Here
|
903 |
table_dt.settings()[0].loaded_from_state = false; |
903 |
table_dt.settings()[0].loaded_from_state = false; |
904 |
first_draw = 1; // Only redirect if we are coming from here |
904 |
first_draw = 1; // Only redirect if we are coming from here |
905 |
table_dt.draw(); |
905 |
table_dt.draw(); |
906 |
[% IF display_search_description %] |
|
|
907 |
update_search_description(); |
908 |
[% END %] |
909 |
return false; |
906 |
return false; |
910 |
} |
907 |
} |
911 |
|
908 |
|
Lines 925-933
Link Here
|
925 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
922 |
history.pushState( {}, null, window.location.href.split("?" )[0]); |
926 |
[% END %] |
923 |
[% END %] |
927 |
$("#[% table_id | html %]_search_results").hide(); |
924 |
$("#[% table_id | html %]_search_results").hide(); |
928 |
[% IF display_search_description %] |
|
|
929 |
update_search_description(); |
930 |
[% END %] |
931 |
} |
925 |
} |
932 |
|
926 |
|
933 |
// User has clicked on a letter |
927 |
// User has clicked on a letter |
Lines 944-952
Link Here
|
944 |
[% END %] |
938 |
[% END %] |
945 |
|
939 |
|
946 |
patrons_table.DataTable().draw(); |
940 |
patrons_table.DataTable().draw(); |
947 |
[% IF display_search_description %] |
|
|
948 |
update_search_description(); |
949 |
[% END %] |
950 |
} |
941 |
} |
951 |
|
942 |
|
952 |
// modify parent window owner element |
943 |
// modify parent window owner element |