|
Lines 48-82
Link Here
|
| 48 |
|
48 |
|
| 49 |
<form action="search.pl" method="get"> |
49 |
<form action="search.pl" method="get"> |
| 50 |
<div id="advanced-search"> |
50 |
<div id="advanced-search"> |
| 51 |
<input type="hidden" name="advsearch" value="1"/> |
51 |
[% IF edit_filter %] |
| 52 |
<h1>Advanced search</h1> |
|
|
| 53 |
<p> |
| 54 |
<a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a> |
| 55 |
[% IF searchid %] |
| 56 |
<div id="previous_search_link"></div> |
| 57 |
[% END %] |
| 58 |
</p> |
| 59 |
|
| 60 |
<!-- SEARCH BUTTONS --> |
| 61 |
<div id="toolbar" class="btn-toolbar"> |
52 |
<div id="toolbar" class="btn-toolbar"> |
| 62 |
<fieldset class="action" id="submit1"> |
53 |
<fieldset class="action" id="submit1"> |
|
|
54 |
<legend>Editing filter: [% edit_filter.name | html %]</legend> |
| 63 |
<div class="btn-group"> |
55 |
<div class="btn-group"> |
| 64 |
<button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button> |
56 |
<label for="filter_edit_opac">Show in OPAC?</label> |
|
|
57 |
[% IF edit_filter.opac %] |
| 58 |
<input type="checkbox" id="show_filter_opac" name="show_filter_opac" checked="checked"> |
| 59 |
[% ELSE %] |
| 60 |
<input type="checkbox" id="show_filter_opac" name="show_filter_opac"> |
| 61 |
[% END %] |
| 62 |
<label for="filter_edit_staff_client">Show in Staff client?</label> |
| 63 |
[% IF edit_filter.staff_client %] |
| 64 |
<input type="checkbox" id="filter_edit_staff_client" name="filter_edit_staff_client" checked="checked"> |
| 65 |
[% ELSE %] |
| 66 |
<input type="checkbox" id="filter_edit_staff_client" name="filter_edit_staff_client"> |
| 67 |
[% END %] |
| 65 |
</div> |
68 |
</div> |
|
|
69 |
<hr> |
| 66 |
<div class="btn-group"> |
70 |
<div class="btn-group"> |
| 67 |
[% IF ( expanded_options ) %] |
71 |
<button id="save_filter" class="btn btn-default"><i class="fa fa-save"></i> Save filter</button> |
| 68 |
<a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=0" class="btn btn-link"><i class="fa fa-search-minus"></i> Fewer options</a> |
72 |
<button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search using filter</button> |
| 69 |
</div> |
|
|
| 70 |
[% ELSE %] |
| 71 |
<a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=1" class="btn btn-link"><i class="fa fa-search-plus"></i> More options</a> |
| 72 |
</div> |
73 |
</div> |
| 73 |
[% END %] |
|
|
| 74 |
<div class="btn-group"> |
74 |
<div class="btn-group"> |
| 75 |
<a href="/cgi-bin/koha/catalogue/search.pl?do=Clear&expanded_options=[% expanded_options | uri %]" class="btn btn-link"><i class="fa fa-trash"></i> Clear fields</a> |
75 |
<a href="/cgi-bin/koha/catalogue/search.pl?do=Clear&expanded_options=[% expanded_options | uri %]" class="btn btn-link"><i class="fa fa-trash"></i> Cancel</a> |
| 76 |
</div> |
76 |
</div> |
| 77 |
</fieldset> <!-- /.action --> |
77 |
</fieldset> |
| 78 |
</div> <!-- /#toolbar --> |
78 |
</div> |
| 79 |
<!-- /SEARCH BUTTONS --> |
79 |
[% ELSE %] |
|
|
80 |
<input type="hidden" name="advsearch" value="1"/> |
| 81 |
<h1>Advanced search</h1> |
| 82 |
<p> |
| 83 |
<a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a> |
| 84 |
[% IF searchid %] |
| 85 |
<div id="previous_search_link"></div> |
| 86 |
[% END %] |
| 87 |
</p> |
| 88 |
|
| 89 |
<!-- SEARCH BUTTONS --> |
| 90 |
<div id="toolbar" class="btn-toolbar"> |
| 91 |
<fieldset class="action" id="submit1"> |
| 92 |
<div class="btn-group"> |
| 93 |
<button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button> |
| 94 |
</div> |
| 95 |
<div class="btn-group"> |
| 96 |
[% IF ( expanded_options ) %] |
| 97 |
<a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=0" class="btn btn-link"><i class="fa fa-search-minus"></i> Fewer options</a> |
| 98 |
</div> |
| 99 |
[% ELSE %] |
| 100 |
<a href="/cgi-bin/koha/catalogue/search.pl?expanded_options=1" class="btn btn-link"><i class="fa fa-search-plus"></i> More options</a> |
| 101 |
</div> |
| 102 |
[% END %] |
| 103 |
<div class="btn-group"> |
| 104 |
<a href="/cgi-bin/koha/catalogue/search.pl?do=Clear&expanded_options=[% expanded_options | uri %]" class="btn btn-link"><i class="fa fa-trash"></i> Clear fields</a> |
| 105 |
</div> |
| 106 |
</fieldset> <!-- /.action --> |
| 107 |
</div> <!-- /#toolbar --> |
| 108 |
<!-- /SEARCH BUTTONS --> |
| 109 |
[% END %] |
| 80 |
|
110 |
|
| 81 |
[% IF ( outer_servers_loop ) %] |
111 |
[% IF ( outer_servers_loop ) %] |
| 82 |
<!-- DATABASES --> |
112 |
<!-- DATABASES --> |
|
Lines 144-149
Link Here
|
| 144 |
<div> |
174 |
<div> |
| 145 |
[% END # /IF ( expanded_options ) %] |
175 |
[% END # /IF ( expanded_options ) %] |
| 146 |
|
176 |
|
|
|
177 |
<<<<<<< HEAD |
| 147 |
[% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %] |
178 |
[% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %] |
| 148 |
[% INCLUDE 'search_indexes.inc' %] |
179 |
[% INCLUDE 'search_indexes.inc' %] |
| 149 |
<input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" /> |
180 |
<input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" /> |
|
Lines 157-162
Link Here
|
| 157 |
[% END # /IF ( expanded_options ) %] |
188 |
[% END # /IF ( expanded_options ) %] |
| 158 |
</div> <!-- /.search-term-row --> |
189 |
</div> <!-- /.search-term-row --> |
| 159 |
[% END # /FOREACH query IN queries %] |
190 |
[% END # /FOREACH query IN queries %] |
|
|
191 |
======= |
| 192 |
<!-- BOOLEAN SEARCH OPTIONS --> |
| 193 |
<fieldset id="searchterms"> |
| 194 |
<legend>Search for </legend> |
| 195 |
[% FOREACH query IN operands %] |
| 196 |
[% IF ( expanded_options ) %] |
| 197 |
[% IF loop.first %] |
| 198 |
<div class="search-term-row" style="text-indent: 4.25em;"> |
| 199 |
[% ELSE %] |
| 200 |
<div class="search-term-row"> |
| 201 |
[% SET opindex = loop.index - 1 %] |
| 202 |
<select name="op"> |
| 203 |
[% IF operators.$opindex == 'OR' %] |
| 204 |
<option value="AND">and</option> |
| 205 |
<option value="OR" selected="selected">or</option> |
| 206 |
<option value="NOT">not</option> |
| 207 |
[% ELSIF operators.$opindex == 'NOT' %] |
| 208 |
<option value="AND">and</option> |
| 209 |
<option value="OR">or</option> |
| 210 |
<option value="NOT" selected="selected">not</option> |
| 211 |
[% ELSE %] |
| 212 |
<option value="AND" selected="selected">and</option> |
| 213 |
<option value="OR">or</option> |
| 214 |
<option value="NOT">not</option> |
| 215 |
[% END %] |
| 216 |
</select> |
| 217 |
[% END %] |
| 218 |
[% ELSE %] |
| 219 |
<div> |
| 220 |
[% END %] |
| 221 |
[% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %] |
| 222 |
[% INCLUDE 'search_indexes.inc' %] |
| 223 |
<input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" /> |
| 224 |
[% IF ( expanded_options ) %] |
| 225 |
[% IF ( loop.last ) %] |
| 226 |
<a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a> |
| 227 |
[% END %] |
| 228 |
[% IF ( loop.first ) %] |
| 229 |
<label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" /> |
| 230 |
[% END %] |
| 231 |
[% END %] |
| 232 |
</div> |
| 233 |
[% END %] |
| 234 |
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %] |
| 235 |
[% IF ( expanded_options ) %] |
| 236 |
<p> |
| 237 |
[% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %] |
| 238 |
<label><input type="checkbox" name="whole_record" /> Search entire MARC record</label> |
| 239 |
[% END %] |
| 240 |
<span id="weight_search"> |
| 241 |
<label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label> |
| 242 |
</span> |
| 243 |
<p> |
| 244 |
[% ELSE %] |
| 245 |
<input type="hidden" name="weight_search" value="1" /> |
| 246 |
[% END %] |
| 247 |
[% END %] |
| 248 |
</fieldset> |
| 249 |
<!-- /BOOLEAN SEARCH OPTIONS --> |
| 250 |
>>>>>>> Bug 17170: Add admin page for filters and ability to edit/save existing filters |
| 160 |
|
251 |
|
| 161 |
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %] |
252 |
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %] |
| 162 |
[% IF ( expanded_options ) %] |
253 |
[% IF ( expanded_options ) %] |
|
Lines 334-339
Link Here
|
| 334 |
</fieldset> <!-- /#availability --> |
425 |
</fieldset> <!-- /#availability --> |
| 335 |
<!-- /AVAILABILITY LIMITS --> |
426 |
<!-- /AVAILABILITY LIMITS --> |
| 336 |
|
427 |
|
|
|
428 |
<<<<<<< HEAD |
| 337 |
<!-- OTHER LIMITS (facets, etc.) --> |
429 |
<!-- OTHER LIMITS (facets, etc.) --> |
| 338 |
[% IF limits.size %] |
430 |
[% IF limits.size %] |
| 339 |
<fieldset id=""> |
431 |
<fieldset id=""> |
|
Lines 367-376
Link Here
|
| 367 |
</form> |
459 |
</form> |
| 368 |
</div> |
460 |
</div> |
| 369 |
</div> |
461 |
</div> |
|
|
462 |
======= |
| 463 |
[% UNLESS edit_filter %] |
| 464 |
<!-- RANK LIMITS --> |
| 465 |
<fieldset id="sortby"><legend>Sorting</legend> |
| 466 |
<p> |
| 467 |
<label for="sort_by">Sort by: </label><select id="sort_by" name="sort_by"> |
| 468 |
[% INCLUDE 'resort_form.inc' sort_by = sort %] |
| 469 |
</select> |
| 470 |
</p> |
| 471 |
</fieldset> |
| 472 |
[% END %] |
| 473 |
</div> |
| 474 |
<!-- /RANK LIMITS --> |
| 475 |
</form> |
| 476 |
</div> |
| 477 |
</div> |
| 478 |
>>>>>>> Bug 17170: Add admin page for filters and ability to edit/save existing filters |
| 370 |
|
479 |
|
| 371 |
[% MACRO jsinclude BLOCK %] |
480 |
[% MACRO jsinclude BLOCK %] |
| 372 |
[% Asset.js("lib/hc-sticky.js") | $raw %] |
481 |
[% Asset.js("lib/hc-sticky.js") | $raw %] |
| 373 |
[% Asset.js("js/browser.js") | $raw %] |
482 |
[% Asset.js("js/browser.js") | $raw %] |
|
|
483 |
[% Asset.css("css/humanmsg.css") | $raw %] |
| 484 |
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] |
| 374 |
<script> |
485 |
<script> |
| 375 |
/** |
486 |
/** |
| 376 |
* Function add_field(); |
487 |
* Function add_field(); |
|
Lines 426-431
Link Here
|
| 426 |
browser.show_back_link(); |
537 |
browser.show_back_link(); |
| 427 |
[% END %] |
538 |
[% END %] |
| 428 |
|
539 |
|
|
|
540 |
[% IF edit_filter %] |
| 541 |
$("#save_filter").click(function(e){ |
| 542 |
e.preventDefault(); |
| 543 |
let operators = []; |
| 544 |
let indexes = []; |
| 545 |
let operands = []; |
| 546 |
let limits =[]; |
| 547 |
let opac = $("#show_filter_opac").prop('checked'); |
| 548 |
let staff_client = $("#show_filter_staff_client").prop('checked'); |
| 549 |
$("select[name='op']").each(function(){ |
| 550 |
operators.push( $(this).val() ); |
| 551 |
}); |
| 552 |
$("select[name='idx']").each(function(){ |
| 553 |
indexes.push( $(this).val() ); |
| 554 |
}); |
| 555 |
$("input[name='q']").each(function(){ |
| 556 |
operands.push( $(this).val() ); |
| 557 |
}); |
| 558 |
$("select[name='limit'],input[name='limit']:checked").each(function(){ |
| 559 |
if( $(this).val() != ""){ |
| 560 |
limits.push( $(this).val() ); |
| 561 |
} |
| 562 |
}); |
| 563 |
let year_limit = $("#limit-yr").val(); |
| 564 |
if( year_limit ){ |
| 565 |
limits.push( "yr,st-numeric:"+year_limit ); |
| 566 |
} |
| 567 |
let options = { |
| 568 |
url: '/api/v1/search_filters/'+ [% edit_filter.id | html %], |
| 569 |
method: "PUT", |
| 570 |
contentType: "application/json", |
| 571 |
data: JSON.stringify({ |
| 572 |
name: "[% edit_filter.name | html %]", |
| 573 |
filter_query: JSON.stringify({ operands: operands, indexes: indexes, operators:operators }), |
| 574 |
filter_limits: JSON.stringify({ limits: limits }), |
| 575 |
opac: opac, |
| 576 |
staff_client: staff_client, |
| 577 |
}) |
| 578 |
}; |
| 579 |
$.ajax(options) |
| 580 |
.then(function(result) { |
| 581 |
humanMsg.displayAlert( _("Saved filter: ") + result.name , { className: 'human Success' } ); |
| 582 |
}) |
| 583 |
.fail( function(err){ |
| 584 |
humanMsg.displayAlert( _("There was an error during saving:") + err.responseText, { className: 'humanError' } ); |
| 585 |
}); |
| 586 |
|
| 587 |
|
| 588 |
}); |
| 589 |
[% END %] |
| 590 |
|
| 591 |
|
| 429 |
}); |
592 |
}); |
| 430 |
</script> |
593 |
</script> |
| 431 |
[% END %] |
594 |
[% END %] |