Bug 17170: Add admin page for filters and ability to edit/save existing filters
This patchset adds a new ability to save searches on the staff client, and display them in the results page on staff or opac as a new filter. New filters can be added from the resuilts page after a search, and there is an admin page for updating deleting and renaming filters There is a new permission to control management of these filters New filters can be added that are not displayed along with facets, this allows for building custom links using these filters to keep URLs shorter Due to bug 30528 testing in ES is recommended To test: 1 - Apply patches and update database and restart all 2 - Enable new system preference 'SavedSearchFilters' 3 - As superlibrarian perform a search in staff client, something broad like 'a' 4 - Note new 'Save search as filter' link on results page 5 - Click it, save search as new filter, check 'Staff client' visibility 6 - Perform another search 7 - Note the filter now appears above facets 8 - Click to it filter results 9 - Note results are limited by the new filter, and it is checked in the facets 10 - Confirm click the [x] removes the filter 11 - Go to administration->search filters 12 - Confirm the filter appears 13 - Edit and mark as OPAC visible 14 - Test OPAC to ensure it shows and can be applied/removed 15 - Copy URL with filter applied 16 - In adminsitration mark filter as not visible on staff or opac 17 - Confirm link above still works 18 - Create a new staff with catalogue and search filters permission 19 - Ensure they can access/save filters 20 - Remove filter permission and ensure they cannot 21 - Disable system preference 22 - Confirm links to search filters page are removed from admin home and admin sidebar 23 - Confirm filters do not appear on results and cannot be created 24 - Enable pref 25 - Create a filter 26 - From search filters page, click 'Edit search' 27 - Confirm you are taken to advanced search page letting you know which filter you are editing 28 - Confirm you can change searhc options and save 29 - Confirm you can perform the search from this page Sponsored-by: Sponsored by: Round Rock Public Library [https://www.roundrocktexas.gov/departments/library/] Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
a97a6b28d2
commit
fe508be07a
7 changed files with 496 additions and 108 deletions
60
admin/search_filters.pl
Executable file
60
admin/search_filters.pl
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/perl
|
||||
# Copyright 2013 BibLibre
|
||||
#
|
||||
# This file is part of Koha
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use CGI;
|
||||
|
||||
use C4::Auth qw( get_template_and_user );
|
||||
use C4::Output qw( output_html_with_http_headers );
|
||||
|
||||
use Koha::SearchFilters;
|
||||
|
||||
use Try::Tiny qw( catch try);
|
||||
|
||||
my $cgi = CGI->new;
|
||||
|
||||
my ($template, $borrowernumber, $cookie) = get_template_and_user({
|
||||
template_name => 'admin/search_filters.tt',
|
||||
query => $cgi,
|
||||
type => 'intranet',
|
||||
flagsrequired => { parameters => 'manage_search_filters' },
|
||||
});
|
||||
|
||||
my $op = $cgi->param('op') || '';
|
||||
|
||||
if ($op eq 'del') {
|
||||
my $id = $cgi->param('id');
|
||||
my $sf = Koha::SearchFilters->find($id);
|
||||
$template->param(filter_not_found => 1) unless $sf;
|
||||
if ($sf) {
|
||||
try{
|
||||
$sf->delete();
|
||||
$template->param( filter_deleted => $sf->name );
|
||||
} catch {
|
||||
$template->param( error => $_ );
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
my $filters = Koha::SearchFilters->search();
|
||||
|
||||
$template->param(
|
||||
filters_count => $filters->count,
|
||||
);
|
||||
|
||||
output_html_with_http_headers $cgi, $cookie, $template->output;
|
|
@ -177,7 +177,7 @@ my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit');
|
|||
my %is_nolimit = map { $_ => 1 } @nolimits;
|
||||
@limits = grep { not $is_nolimit{$_} } @limits;
|
||||
if (
|
||||
!$cgi->param('edit_search') &&
|
||||
!$cgi->param('edit_search') && !$cgi->param('edit_filter') &&
|
||||
( (@limits>=1) || (defined $cgi->param("q") && $cgi->param("q") ne "" ) || ($cgi->param('limit-yr')) )
|
||||
) {
|
||||
$template_name = 'catalogue/results.tt';
|
||||
|
@ -262,32 +262,58 @@ $template->param( searchid => scalar $cgi->param('searchid'), );
|
|||
# The following should only be loaded if we're bringing up the advanced search template
|
||||
if ( $template_type eq 'advsearch' ) {
|
||||
|
||||
my @operands;
|
||||
my @operators;
|
||||
my @indexes;
|
||||
my $expanded = $cgi->param('expanded_options');
|
||||
if( $cgi->param('edit_search') ){
|
||||
my @operators = $cgi->multi_param('op');
|
||||
my @indexes = $cgi->multi_param('idx');
|
||||
my %limit_hash;
|
||||
foreach my $limit (@limits){
|
||||
if ( $limit eq 'available' ){
|
||||
$template->param( limit_available => 1 );
|
||||
} else {
|
||||
my ($index,$value) = split(':',$limit);
|
||||
$value =~ s/"//g;
|
||||
if ( $index =~ /mc-/ ){
|
||||
$limit_hash{$index . "_" . $value} = 1;
|
||||
} else {
|
||||
push @{$limit_hash{$index}}, $value;
|
||||
}
|
||||
}
|
||||
};
|
||||
$expanded = 1 if scalar @operators || scalar @limits;
|
||||
$template->param( operators => \@operators );
|
||||
$template->param( limits => \%limit_hash );
|
||||
@operands = $cgi->multi_param('q');
|
||||
@operators = $cgi->multi_param('op');
|
||||
@indexes = $cgi->multi_param('idx');
|
||||
$template->param(
|
||||
indexes => \@indexes,
|
||||
sort => $cgi->param('sort_by'),
|
||||
);
|
||||
# determine what to display next to the search boxes
|
||||
} elsif ( $cgi->param('edit_filter') ){
|
||||
my $search_filter = Koha::SearchFilters->find( $cgi->param('edit_filter') );
|
||||
if( $search_filter ){
|
||||
my $query = decode_json( $search_filter->query );
|
||||
my $limits = decode_json( $search_filter->limits );
|
||||
@operands = @{ $query->{operands} };
|
||||
@indexes = @{ $query->{indexes} };
|
||||
@operators = @{ $query->{operators} };
|
||||
@limits = @{ $limits->{limits} };
|
||||
$template->param( edit_filter => $search_filter );
|
||||
} else {
|
||||
$template->param( unknown_filter => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
while( scalar @operands < 3 ){
|
||||
push @operands, "";
|
||||
}
|
||||
$template->param( operands => \@operands );
|
||||
$template->param( operators => \@operators );
|
||||
$template->param( indexes => \@indexes );
|
||||
|
||||
my %limit_hash;
|
||||
foreach my $limit (@limits){
|
||||
if ( $limit eq 'available' ){
|
||||
$template->param( limit_available => 1 );
|
||||
} else {
|
||||
my ($index,$value) = split(':',$limit);
|
||||
$value =~ s/"//g;
|
||||
if ( $index =~ /mc-/ ){
|
||||
$limit_hash{$index . "_" . $value} = 1;
|
||||
} else {
|
||||
push @{$limit_hash{$index}}, $value;
|
||||
}
|
||||
}
|
||||
};
|
||||
$template->param( limits => \%limit_hash );
|
||||
|
||||
$expanded = 1 if scalar @operators || scalar @limits;
|
||||
|
||||
# load the servers (used for searching -- to do federated searching, etc.)
|
||||
my $primary_servers_loop;# = displayPrimaryServers();
|
||||
$template->param(outer_servers_loop => $primary_servers_loop,);
|
||||
|
@ -304,17 +330,11 @@ if ( $template_type eq 'advsearch' ) {
|
|||
$template->param( sort_by => $default_sort_by );
|
||||
}
|
||||
|
||||
# determine what to display next to the search boxes
|
||||
my @queries = $cgi->multi_param('q');
|
||||
while( scalar @queries < 3 ){
|
||||
push @queries, "";
|
||||
}
|
||||
$template->param(uc(C4::Context->preference("marcflavour")) =>1 );
|
||||
|
||||
# load the language limits (for search)
|
||||
my $languages_limit_loop = getLanguages($lang, 1);
|
||||
$template->param(search_languages_loop => $languages_limit_loop,);
|
||||
$template->param( queries => \@queries );
|
||||
|
||||
# Expanded search options in advanced search:
|
||||
# use the global setting by default, but let the user override it
|
||||
|
|
|
@ -113,6 +113,9 @@
|
|||
[% IF ( CAN_user_parameters_manage_item_search_fields ) %]
|
||||
<li><a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a></li>
|
||||
[% END %]
|
||||
[% IF ( Koha.Preference('SavedSearchFilters') && CAN_user_parameters_manage_search_filters ) %]
|
||||
<li><a href="/cgi-bin/koha/admin/search_filters.pl">Search filters</a></li>
|
||||
[% END %]
|
||||
[% IF ( CAN_user_parameters_manage_search_engine_config ) %]
|
||||
<li><a href="/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl">Search engine configuration (Elasticsearch)</a></li>
|
||||
[% END %]
|
||||
|
|
|
@ -203,6 +203,10 @@
|
|||
<dt><a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a></dt>
|
||||
<dd>Manage custom fields for item search</dd>
|
||||
[% END %]
|
||||
[% IF Koha.Preference('SavedSearchFilters') && ( CAN_user_parameters_manage_search_filters ) %]
|
||||
<dt><a href="/cgi-bin/koha/admin/search_filters.pl">Search filters</a></dt>
|
||||
<dd>Manage custom search filters</dd>
|
||||
[% END %]
|
||||
[% IF ( CAN_user_parameters_manage_search_engine_config ) %]
|
||||
<dt><a href="/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl">Search engine configuration (Elasticsearch)</a></dt>
|
||||
<dd>Manage indexes, facets, and their mappings to MARC fields and subfields</dd>
|
||||
|
|
226
koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt
Normal file
226
koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt
Normal file
|
@ -0,0 +1,226 @@
|
|||
[% USE raw %]
|
||||
[% USE Asset %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% USE AuthorisedValues %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>Search filters › Administration › Koha</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
</head>
|
||||
|
||||
<body id="admin_searchfilters" class="admin">
|
||||
[% INCLUDE 'header.inc' %]
|
||||
[% INCLUDE 'prefs-admin-search.inc' %]
|
||||
|
||||
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
|
||||
<ol>
|
||||
<li>
|
||||
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" aria-current="page">
|
||||
Search filters
|
||||
</a>
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="main container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-10 col-sm-push-2">
|
||||
<main>
|
||||
|
||||
[% IF filters_count %]
|
||||
<div id="search_filters_list">
|
||||
<h2>Search filters</h2>
|
||||
|
||||
<table id="search_filters_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Query</th>
|
||||
<th>Limits</th>
|
||||
<th>OPAC</th>
|
||||
<th>Staff client</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<div class="dialog message">
|
||||
There are no search filters defined.
|
||||
</div>
|
||||
[% END %]
|
||||
|
||||
</main>
|
||||
</div> <!-- /.col-sm-10.col-sm-push-2 -->
|
||||
|
||||
<div class="col-sm-2 col-sm-pull-10">
|
||||
<aside>
|
||||
[% INCLUDE 'admin-menu.inc' %]
|
||||
</aside>
|
||||
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
|
||||
</div> <!-- /.row -->
|
||||
|
||||
<div id="edit_search_filter_modal" class="modal" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="search_filters_label">Edit filter: <span id="filter_edit_modal_name"></span</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="filter_edit_id" name="filter_edit_id">
|
||||
<label for="filter_edit_name">Name:</label>
|
||||
<input id="filter_edit_name" name="filter_edit_name" type="text">
|
||||
<hr>
|
||||
<h6>Visibility:<h6>
|
||||
<label for="filter_edit_opac">Show in OPAC?</label>
|
||||
<input type="checkbox" id="filter_edit_opac" name="filter_edit_opac">
|
||||
<label for="filter_edit_staff_client">Show in Staff client?</label>
|
||||
<input type="checkbox" id="filter_edit_staff_client" name="filter_edit_staff_client">
|
||||
<hr>
|
||||
<a id="replace_existing_filter" class="btn btn-default btn-xs" href="#">Update</a>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" data-dismiss="modal" aria-hidden="true" class="cancel">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
[% MACRO jsinclude BLOCK %]
|
||||
[% Asset.js("js/admin-menu.js") | $raw %]
|
||||
[% Asset.css("css/humanmsg.css") | $raw %]
|
||||
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
|
||||
[% INCLUDE 'datatables.inc' %]
|
||||
|
||||
<script>
|
||||
let filters_table;
|
||||
$(document).ready(function(){
|
||||
filters_table = $("#search_filters_table").kohaTable({
|
||||
"ajax": {
|
||||
"url": "/api/v1/search_filters"
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"data": "search_filter_id",
|
||||
"searchable": true,
|
||||
"orderable": true
|
||||
},
|
||||
{
|
||||
"data": "name",
|
||||
"searchable": true,
|
||||
"orderable": true
|
||||
},
|
||||
{
|
||||
"data": "filter_query",
|
||||
"searchable": true,
|
||||
"orderable": true
|
||||
},
|
||||
{
|
||||
"data": "filter_limits",
|
||||
"searchable": true,
|
||||
"orderable": true
|
||||
},
|
||||
{
|
||||
"data": "opac",
|
||||
"searchable": true,
|
||||
"orderable": true
|
||||
},
|
||||
{
|
||||
"data": "staff_client",
|
||||
"searchable": true,
|
||||
"orderable": true
|
||||
},
|
||||
{
|
||||
"data": function( row, meta, val, type ) {
|
||||
let filter = row;
|
||||
let filter_buttons = '<a class="btn btn-default btn-xs edit_filter" onclick="edit_filter(this)"';
|
||||
filter_buttons += ' data-filter_id="'+ filter.search_filter_id;
|
||||
filter_buttons += '" data-filter_name="'+ filter.name;
|
||||
filter_buttons += '" data-filter_opac="'+ filter.opac;
|
||||
filter_buttons += '" data-filter_staff_client="'+ filter.staff_client;
|
||||
filter_buttons += '" ><i class="fa fa-pencil"></i> Edit filter</a>';
|
||||
filter_buttons += '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/catalogue/search.pl?edit_filter='+filter.search_filter_id+'"><i class="fa fa-search"></i> Edit search</a>';
|
||||
filter_buttons += '<a class="btn btn-default btn-xs delete_filter" onclick="delete_filter(this)"';
|
||||
filter_buttons += ' data-filter_id="'+ filter.search_filter_id;
|
||||
filter_buttons += '"><i class="fa fa-trash"></i> Delete</a>';
|
||||
return filter_buttons;
|
||||
},
|
||||
"searchable": false,
|
||||
"orderable": false
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
$("#replace_existing_filter").click(function(){
|
||||
let name = $("#filter_edit_name").val();
|
||||
let id = $("#filter_edit_id").val();
|
||||
let opac = $("#filter_edit_opac").prop('checked');
|
||||
let staff_client = $("#filter_edit_staff_client").prop('checked');
|
||||
save_search_filter(name,id,opac,staff_client);
|
||||
});
|
||||
|
||||
function edit_filter(element){
|
||||
let filter_id = $(element).data('filter_id');
|
||||
let filter_name = $(element).data('filter_name');
|
||||
let filter_opac = $(element).data('filter_opac');
|
||||
let filter_staff_client = $(element).data('filter_staff_client');
|
||||
$("#filter_edit_name").val(filter_name);
|
||||
$("#filter_edit_id").val(filter_id);
|
||||
$("#filter_edit_opac").prop('checked',filter_opac);
|
||||
$("#filter_edit_staff_client").prop('checked',filter_staff_client);
|
||||
$("#edit_search_filter_modal").modal('show');
|
||||
};
|
||||
|
||||
function delete_filter(element){
|
||||
let filter_id = $(element).data('filter_id');
|
||||
let options = {
|
||||
url: '/api/v1/search_filters/' + filter_id,
|
||||
method: "DELETE",
|
||||
contentType: "application/json",
|
||||
};
|
||||
$.ajax(options)
|
||||
.then(function(result) {
|
||||
humanMsg.displayAlert( _("Filter successfully deleted."), { className: 'human Success' } );
|
||||
filters_table.DataTable().ajax.reload();
|
||||
})
|
||||
.fail(function(err) {
|
||||
humanMsg.displayAlert( _("There was an error during saving:") + err.responseText, { className: 'humanError' } );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function save_search_filter(name,id,opac,staff){
|
||||
let options = {
|
||||
url: '/api/v1/search_filters/' + id,
|
||||
method: "PUT",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
name: name,
|
||||
opac: opac,
|
||||
staff_client: staff,
|
||||
})
|
||||
};
|
||||
$.ajax(options)
|
||||
.then(function(result) {
|
||||
$("#edit_search_filter_modal").modal('hide');
|
||||
humanMsg.displayAlert( _("Saved filter: ") + name , { className: 'human Success' } );
|
||||
filters_table.DataTable().ajax.reload();
|
||||
})
|
||||
.fail(function(err) {
|
||||
humanMsg.displayAlert( _("There was an error during saving:") + err.responseText, { className: 'humanError' } );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
[% INCLUDE 'intranet-bottom.inc' %]
|
|
@ -51,33 +51,58 @@
|
|||
|
||||
<form action="search.pl" method="get">
|
||||
<div id="advanced-search">
|
||||
<input type="hidden" name="advsearch" value="1"/>
|
||||
<h1>Advanced search</h1>
|
||||
[% IF searchid %]
|
||||
<div id="previous_search_link"></div>
|
||||
[% END %]
|
||||
|
||||
<!-- SEARCH BUTTONS -->
|
||||
[% IF edit_filter %]
|
||||
<div id="toolbar" class="btn-toolbar">
|
||||
<legend>Editing filter: [% edit_filter.name | html %]</legend>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-primary" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button>
|
||||
<label for="filter_edit_opac">Show in OPAC?</label>
|
||||
[% IF edit_filter.opac %]
|
||||
<input type="checkbox" id="show_filter_opac" name="show_filter_opac" checked="checked">
|
||||
[% ELSE %]
|
||||
<input type="checkbox" id="show_filter_opac" name="show_filter_opac">
|
||||
[% END %]
|
||||
<label for="filter_edit_staff_client">Show in Staff client?</label>
|
||||
[% IF edit_filter.staff_client %]
|
||||
<input type="checkbox" id="filter_edit_staff_client" name="filter_edit_staff_client" checked="checked">
|
||||
[% ELSE %]
|
||||
<input type="checkbox" id="filter_edit_staff_client" name="filter_edit_staff_client">
|
||||
[% END %]
|
||||
</div>
|
||||
<hr>
|
||||
<div class="btn-group">
|
||||
<button id="save_filter" class="btn btn-default"><i class="fa fa-save"></i> Save filter</button>
|
||||
<button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search using filter</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
[% IF ( expanded_options ) %]
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<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>
|
||||
</div>
|
||||
[% END %]
|
||||
<div class="btn-group">
|
||||
<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>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a href="/cgi-bin/koha/catalogue/itemsearch.pl" class="btn btn-link"><i class="fa fa-search"></i> Go to item search</a>
|
||||
</div>
|
||||
</div> <!-- /#toolbar -->
|
||||
<!-- /SEARCH BUTTONS -->
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<input type="hidden" name="advsearch" value="1"/>
|
||||
<h1>Advanced search</h1>
|
||||
|
||||
<!-- SEARCH BUTTONS -->
|
||||
<div id="toolbar" class="btn-toolbar">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-default" type="submit" accesskey="s"><i class="fa fa-search"></i> Search</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
[% IF ( expanded_options ) %]
|
||||
<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>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
<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>
|
||||
</div>
|
||||
[% END %]
|
||||
<div class="btn-group">
|
||||
<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>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a href="/cgi-bin/koha/catalogue/itemsearch.pl" class="btn btn-link"><i class="fa fa-search"></i> Go to item search</a>
|
||||
</div>
|
||||
</div> <!-- /#toolbar -->
|
||||
<!-- /SEARCH BUTTONS -->
|
||||
[% END %]
|
||||
|
||||
[% IF ( outer_servers_loop ) %]
|
||||
<!-- DATABASES -->
|
||||
|
@ -115,66 +140,64 @@
|
|||
<!-- /REMOTE DATABASES -->
|
||||
[% END %]
|
||||
|
||||
<!-- BOOLEAN SEARCH OPTIONS -->
|
||||
<!-- BOOLEAN SEARCH OPTIONS -->
|
||||
<fieldset id="searchterms">
|
||||
<legend>Search for </legend>
|
||||
[% FOREACH query IN queries %]
|
||||
[% IF ( expanded_options ) %]
|
||||
[% IF loop.first %]
|
||||
<div class="search-term-row" style="text-indent: 4.25em;">
|
||||
[% ELSE %]
|
||||
<div class="search-term-row">
|
||||
[% SET opindex = loop.index - 1 %]
|
||||
<select name="op">
|
||||
[% IF operators.$opindex == 'OR' %]
|
||||
<option value="AND">and</option>
|
||||
<option value="OR" selected="selected">or</option>
|
||||
<option value="NOT">not</option>
|
||||
[% ELSIF operators.$opindex == 'NOT' %]
|
||||
<option value="AND">and</option>
|
||||
<option value="OR">or</option>
|
||||
<option value="NOT" selected="selected">not</option>
|
||||
[% ELSE %]
|
||||
<option value="AND" selected="selected">and</option>
|
||||
<option value="OR">or</option>
|
||||
<option value="NOT">not</option>
|
||||
[% END %]
|
||||
</select>
|
||||
[% END # /IF loop.first %]
|
||||
<legend>Search for </legend>
|
||||
[% FOREACH query IN operands %]
|
||||
[% IF ( expanded_options ) %]
|
||||
[% IF loop.first %]
|
||||
<div class="search-term-row" style="text-indent: 4.25em;">
|
||||
[% ELSE %]
|
||||
<div class="search-term-row">
|
||||
[% SET opindex = loop.index - 1 %]
|
||||
<select name="op">
|
||||
[% IF operators.$opindex == 'OR' %]
|
||||
<option value="AND">and</option>
|
||||
<option value="OR" selected="selected">or</option>
|
||||
<option value="NOT">not</option>
|
||||
[% ELSIF operators.$opindex == 'NOT' %]
|
||||
<option value="AND">and</option>
|
||||
<option value="OR">or</option>
|
||||
<option value="NOT" selected="selected">not</option>
|
||||
[% ELSE %]
|
||||
<div>
|
||||
[% END # /IF ( expanded_options ) %]
|
||||
|
||||
[% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %]
|
||||
[% INCLUDE 'search_indexes.inc' %]
|
||||
<input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" />
|
||||
[% IF ( expanded_options ) %]
|
||||
[% IF ( loop.last ) %]
|
||||
<a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a>
|
||||
<option value="AND" selected="selected">and</option>
|
||||
<option value="OR">or</option>
|
||||
<option value="NOT">not</option>
|
||||
[% END %]
|
||||
</select>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<div>
|
||||
[% END %]
|
||||
[% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %]
|
||||
[% INCLUDE 'search_indexes.inc' %]
|
||||
<input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" />
|
||||
[% IF ( expanded_options ) %]
|
||||
[% IF ( loop.last ) %]
|
||||
<a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a>
|
||||
[% END %]
|
||||
[% IF ( loop.first ) %]
|
||||
<label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" />
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div>
|
||||
[% END %]
|
||||
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
|
||||
[% IF ( expanded_options ) %]
|
||||
<p>
|
||||
[% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
|
||||
<label><input type="checkbox" name="whole_record" /> Search entire MARC record</label>
|
||||
[% END %]
|
||||
[% IF ( loop.first ) %]
|
||||
<label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" />
|
||||
[% END %]
|
||||
[% END # /IF ( expanded_options ) %]
|
||||
</div> <!-- /.search-term-row -->
|
||||
[% END # /FOREACH query IN queries %]
|
||||
|
||||
[% IF Koha.Preference('SearchEngine') == 'Elasticsearch' %]
|
||||
[% IF ( expanded_options ) %]
|
||||
<p>
|
||||
[% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %]
|
||||
<label><input type="checkbox" name="whole_record" /> Search entire MARC record</label>
|
||||
[% END %]
|
||||
<span id="weight_search">
|
||||
<label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label>
|
||||
</span>
|
||||
<p>
|
||||
[% ELSE %]
|
||||
<input type="hidden" name="weight_search" value="1" />
|
||||
[% END # /IF ( expanded_options ) %]
|
||||
[% END #/IF Koha.Preference('SearchEngine') %]
|
||||
</fieldset> <!-- /#searchterms -->
|
||||
<!-- /BOOLEAN SEARCH OPTIONS -->
|
||||
<span id="weight_search">
|
||||
<label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label>
|
||||
</span>
|
||||
<p>
|
||||
[% ELSE %]
|
||||
<input type="hidden" name="weight_search" value="1" />
|
||||
[% END %]
|
||||
[% END %]
|
||||
</fieldset>
|
||||
<!-- /BOOLEAN SEARCH OPTIONS -->
|
||||
</div> <!-- /#advanced-search -->
|
||||
|
||||
<!-- MC-TYPE LIMITS -->
|
||||
|
@ -372,6 +395,8 @@
|
|||
[% MACRO jsinclude BLOCK %]
|
||||
[% Asset.js("lib/hc-sticky.js") | $raw %]
|
||||
[% Asset.js("js/browser.js") | $raw %]
|
||||
[% Asset.css("css/humanmsg.css") | $raw %]
|
||||
[% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
|
||||
<script>
|
||||
/**
|
||||
* Function add_field();
|
||||
|
@ -427,6 +452,58 @@
|
|||
browser.show_back_link();
|
||||
[% END %]
|
||||
|
||||
[% IF edit_filter %]
|
||||
$("#save_filter").click(function(e){
|
||||
e.preventDefault();
|
||||
let operators = [];
|
||||
let indexes = [];
|
||||
let operands = [];
|
||||
let limits =[];
|
||||
let opac = $("#show_filter_opac").prop('checked');
|
||||
let staff_client = $("#show_filter_staff_client").prop('checked');
|
||||
$("select[name='op']").each(function(){
|
||||
operators.push( $(this).val() );
|
||||
});
|
||||
$("select[name='idx']").each(function(){
|
||||
indexes.push( $(this).val() );
|
||||
});
|
||||
$("input[name='q']").each(function(){
|
||||
operands.push( $(this).val() );
|
||||
});
|
||||
$("select[name='limit'],input[name='limit']:checked").each(function(){
|
||||
if( $(this).val() != ""){
|
||||
limits.push( $(this).val() );
|
||||
}
|
||||
});
|
||||
let year_limit = $("#limit-yr").val();
|
||||
if( year_limit ){
|
||||
limits.push( "yr,st-numeric:"+year_limit );
|
||||
}
|
||||
let options = {
|
||||
url: '/api/v1/search_filters/'+ [% edit_filter.id | html %],
|
||||
method: "PUT",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
name: "[% edit_filter.name | html %]",
|
||||
filter_query: JSON.stringify({ operands: operands, indexes: indexes, operators:operators }),
|
||||
filter_limits: JSON.stringify({ limits: limits }),
|
||||
opac: opac,
|
||||
staff_client: staff_client,
|
||||
})
|
||||
};
|
||||
$.ajax(options)
|
||||
.then(function(result) {
|
||||
humanMsg.displayAlert( _("Saved filter: ") + result.name , { className: 'human Success' } );
|
||||
})
|
||||
.fail( function(err){
|
||||
humanMsg.displayAlert( _("There was an error during saving:") + err.responseText, { className: 'humanError' } );
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
[% END %]
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
|
@ -872,7 +872,6 @@
|
|||
$("#replace_existing_filter").click(function(){
|
||||
let id = $("#existing_filters").val();
|
||||
let name = $("#existing_filters option[value="+id+"]").text();
|
||||
console.log(id,name);
|
||||
save_search_filter(name,id);
|
||||
});
|
||||
function save_search_filter(name,id,opac,staff){
|
||||
|
@ -900,7 +899,6 @@
|
|||
getFilters();
|
||||
})
|
||||
.fail(function(err) {
|
||||
console.log(err);
|
||||
humanMsg.displayAlert( _("There was an error during saving:") + err.responseText, { className: 'humanError' } );
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue