Bugzilla – Attachment 138511 Details for
Bug 17170
Add the ability to create 'saved searches' for use as filters when searching the catalog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17170: Add admin page for filters and ability to edit/save existing filters
Bug-17170-Add-admin-page-for-filters-and-ability-t.patch (text/plain), 37.68 KB, created by
Nick Clemens (kidclamp)
on 2022-08-02 13:46:21 UTC
(
hide
)
Description:
Bug 17170: Add admin page for filters and ability to edit/save existing filters
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-08-02 13:46:21 UTC
Size:
37.68 KB
patch
obsolete
>From 6a7a6adbed9f04204237133c7d64d2b02828c9d6 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 12 Apr 2022 18:28:00 +0000 >Subject: [PATCH] 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 >--- > admin/search_filters.pl | 60 +++++ > catalogue/search.pl | 74 ++++-- > .../prog/en/includes/admin-menu.inc | 3 + > .../prog/en/modules/admin/admin-home.tt | 4 + > .../prog/en/modules/admin/search_filters.tt | 226 +++++++++++++++++ > .../prog/en/modules/catalogue/advsearch.tt | 238 ++++++++++++------ > .../prog/en/modules/catalogue/results.tt | 2 - > 7 files changed, 500 insertions(+), 107 deletions(-) > create mode 100755 admin/search_filters.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt > >diff --git a/admin/search_filters.pl b/admin/search_filters.pl >new file mode 100755 >index 0000000000..21645bd6c4 >--- /dev/null >+++ b/admin/search_filters.pl >@@ -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; >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 9b7a8ee0ee..f8f4963399 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -176,7 +176,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'; >@@ -254,32 +254,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,); >@@ -296,17 +322,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 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 244f5acf5c..baed6e6675 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -101,6 +101,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 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 0a77a06495..1422a9cf63 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -196,6 +196,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> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt >new file mode 100644 >index 0000000000..37f830489a >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt >@@ -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' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >index 29808258d1..c84cbcc57f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >@@ -48,35 +48,65 @@ > > <form action="search.pl" method="get"> > <div id="advanced-search"> >- <input type="hidden" name="advsearch" value="1"/> >- <h1>Advanced search</h1> >- <p> >- <a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a> >- [% IF searchid %] >- <div id="previous_search_link"></div> >- [% END %] >- </p> >- >- <!-- SEARCH BUTTONS --> >+ [% IF edit_filter %] > <div id="toolbar" class="btn-toolbar"> > <fieldset class="action" id="submit1"> >+ <legend>Editing filter: [% edit_filter.name | html %]</legend> > <div class="btn-group"> >- <button class="btn btn-default" 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"> >- [% 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> >+ <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> >- [% 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> >+ <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> >- </fieldset> <!-- /.action --> >- </div> <!-- /#toolbar --> >- <!-- /SEARCH BUTTONS --> >+ </fieldset> >+ </div> >+ [% ELSE %] >+ <input type="hidden" name="advsearch" value="1"/> >+ <h1>Advanced search</h1> >+ <p> >+ <a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a> >+ [% IF searchid %] >+ <div id="previous_search_link"></div> >+ [% END %] >+ </p> >+ >+ <!-- SEARCH BUTTONS --> >+ <div id="toolbar" class="btn-toolbar"> >+ <fieldset class="action" id="submit1"> >+ <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> >+ </fieldset> <!-- /.action --> >+ </div> <!-- /#toolbar --> >+ <!-- /SEARCH BUTTONS --> >+ [% END %] > > [% IF ( outer_servers_loop ) %] > <!-- DATABASES --> >@@ -114,66 +144,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> >- [% END %] >- [% IF ( loop.first ) %] >- <label for="scan">Scan indexes:</label> <input type="checkbox" name="scan" id="scan" value="1" /> >+ <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 %] >- [% 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 --> >@@ -371,6 +399,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(); >@@ -426,6 +456,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 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 2542aa43ee..6f65715972 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -865,7 +865,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){ >@@ -893,7 +892,6 @@ > getFilters(); > }) > .fail(function(err) { >- console.log(err); > humanMsg.displayAlert( _("There was an error during saving:") + err.responseText, { className: 'humanError' } ); > }); > } >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17170
:
133263
|
133264
|
133265
|
133266
|
133267
|
133268
|
133269
|
133270
|
133361
|
133376
|
137027
|
137028
|
137029
|
137030
|
137031
|
137032
|
137033
|
137034
|
137035
|
137036
|
137186
|
137187
|
137188
|
137189
|
137190
|
137191
|
137192
|
137193
|
137194
|
137195
|
137808
|
137809
|
137810
|
137811
|
137812
|
137813
|
137814
|
137815
|
137816
|
137817
|
138505
|
138506
|
138507
|
138508
|
138509
|
138510
|
138511
|
138512
|
138513
|
138514
|
139948
|
139949
|
139950
|
139951
|
139952
|
139953
|
139954
|
139955
|
139956
|
139957
|
141228
|
141229
|
141230
|
141231
|
141232
|
141233
|
141234
|
141235
|
141236
|
141237
|
141316
|
141317
|
141318
|
141319
|
141320
|
141321
|
141322
|
141323
|
141324
|
141325
|
141326
|
141327
|
141328
|
141348
|
141349
|
141350
|
141351
|
141352
|
141353
|
141354
|
141355
|
141356
|
141357
|
141358
|
141359
|
141360
|
141422
|
141423
|
141424
|
141425
|
141426
|
141427
|
141428
|
141429
|
141430
|
141431
|
141432
|
141433
|
141434
|
141435
|
141436
|
141437
|
141438
|
141461
|
141462
|
142365
|
142367
|
142368
|
142369
|
142370
|
142371
|
142372
|
142373
|
142374
|
142375
|
142376
|
142377
|
142378
|
142379
|
142380
|
142381
|
142382
|
142383
|
142384
|
142385
|
142494
|
142498