Lines 56-61
Link Here
|
56 |
[% END %] |
56 |
[% END %] |
57 |
</select> |
57 |
</select> |
58 |
</li> |
58 |
</li> |
|
|
59 |
[% CASE 'sort1' %] |
60 |
<li> |
61 |
<label for="sort1_filter">Sort1:</label> |
62 |
<select class="select2" id="sort1_filter"> |
63 |
<option value="">Any</option> |
64 |
[% FOREACH s1 IN sort1 %] |
65 |
<option value="[% s1 | html %]">[% s1 | html %]</option> |
66 |
[% END %] |
67 |
</select> |
68 |
</li> |
69 |
[% CASE 'sort2' %] |
70 |
<li> |
71 |
<label for="sort2_filter">Sort2:</label> |
72 |
<select class="select2" id="sort2_filter"> |
73 |
<option value="">Any</option> |
74 |
[% FOREACH s2 IN sort2 %] |
75 |
<option value="[% s2 | html %]">[% s2 | html %]</option> |
76 |
[% END %] |
77 |
</select> |
78 |
</li> |
59 |
[% CASE 'search_field' %] |
79 |
[% CASE 'search_field' %] |
60 |
<li> |
80 |
<li> |
61 |
<label for="searchfieldstype_filter">Search field:</label> |
81 |
<label for="searchfieldstype_filter">Search field:</label> |
Lines 209-214
Link Here
|
209 |
[% IF redirect_if_one_result && !redirect_url %] |
229 |
[% IF redirect_if_one_result && !redirect_url %] |
210 |
<script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script> |
230 |
<script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script> |
211 |
[% END %] |
231 |
[% END %] |
|
|
232 |
|
233 |
[% INCLUDE 'select2.inc' %] |
212 |
<script> |
234 |
<script> |
213 |
let categories = [% To.json(categories) | $raw %].map(e => { |
235 |
let categories = [% To.json(categories) | $raw %].map(e => { |
214 |
e['_id'] = e.categorycode; |
236 |
e['_id'] = e.categorycode; |
Lines 233-238
Link Here
|
233 |
let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; |
255 |
let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; |
234 |
[% END %] |
256 |
[% END %] |
235 |
|
257 |
|
|
|
258 |
$(document).ready(function() { |
259 |
$('sort1_filter').select2({allowClear:true}); |
260 |
$('sort2_filter').select2({allowClear:true}); |
261 |
}); |
236 |
</script> |
262 |
</script> |
237 |
|
263 |
|
238 |
[% INCLUDE 'datatables.inc' %] |
264 |
[% INCLUDE 'datatables.inc' %] |
Lines 308-318
Link Here
|
308 |
return { "like": start_with + "%" } |
334 |
return { "like": start_with + "%" } |
309 |
}, |
335 |
}, |
310 |
"-and": function(){ |
336 |
"-and": function(){ |
|
|
337 |
let filters = []; |
338 |
let f_sort1 = $("#sort1_filter").val(); |
339 |
if ( f_sort1 ) { |
340 |
filters.push({ |
341 |
"me.sort1": f_sort1 |
342 |
}); |
343 |
} |
344 |
let f_sort2 = $("#sort2_filter").val(); |
345 |
if ( f_sort2 ) { |
346 |
filters.push({ |
347 |
"me.sort2": f_sort2 |
348 |
}); |
349 |
} |
350 |
|
311 |
let pattern = $("#search_patron_filter").val(); |
351 |
let pattern = $("#search_patron_filter").val(); |
312 |
if (!pattern) return ""; |
352 |
if (!pattern) { |
|
|
353 |
if ( filters.length == 0 ) { |
354 |
return ""; |
355 |
} |
356 |
else { |
357 |
return filters; |
358 |
} |
359 |
} |
313 |
let patterns = pattern.split(' ').filter(function(s){ return s.length }); |
360 |
let patterns = pattern.split(' ').filter(function(s){ return s.length }); |
314 |
|
361 |
|
315 |
let filters = []; |
|
|
316 |
let search_type = $("#searchtype_filter").val() || "contain"; |
362 |
let search_type = $("#searchtype_filter").val() || "contain"; |
317 |
let search_fields = $("#searchfieldstype_filter").val(); |
363 |
let search_fields = $("#searchfieldstype_filter").val(); |
318 |
if ( !search_fields ) { |
364 |
if ( !search_fields ) { |
Lines 731-736
Link Here
|
731 |
if ( $("#branchcode_filter").val() ) { |
777 |
if ( $("#branchcode_filter").val() ) { |
732 |
searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); |
778 |
searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); |
733 |
} |
779 |
} |
|
|
780 |
if ( $("#sort1_filter").val() ) { |
781 |
searched += _(" with sort1 ") + $("#sort1_filter").find("option:selected").text(); |
782 |
} |
783 |
if ( $("#sort2_filter").val() ) { |
784 |
searched += _(" with sort2 ") + $("#sort2_filter").find("option:selected").text(); |
785 |
} |
734 |
$("#searchpattern").text(searched); |
786 |
$("#searchpattern").text(searched); |
735 |
$("#searchpattern").parent().show(); |
787 |
$("#searchpattern").parent().show(); |
736 |
} |
788 |
} |
Lines 788-793
Link Here
|
788 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
840 |
$("#searchtype_filter option[value='contain']").prop("selected", true); |
789 |
$("#categorycode_filter option:first").prop("selected", true); |
841 |
$("#categorycode_filter option:first").prop("selected", true); |
790 |
$("#branchcode_filter option:first").prop("selected", true); |
842 |
$("#branchcode_filter option:first").prop("selected", true); |
|
|
843 |
$("#sort1_filter option:first").prop("selected", true); |
844 |
$("#sort2_filter option:first").prop("selected", true); |
791 |
$("#firstletter_filter").val(''); |
845 |
$("#firstletter_filter").val(''); |
792 |
$("#search_patron_filter").val(''); |
846 |
$("#search_patron_filter").val(''); |
793 |
/* remove any search string added by firstletter search */ |
847 |
/* remove any search string added by firstletter search */ |