Bug 13307: Create a link to the last advanced search in search result page (OPAC)
http://bugs.koha-community.org/show_bug.cgi?id=13307 Followed test plan, works as expected (together with other patches) Signed-off-by: Marc Veron <veron@veron.ch> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> http://bugs.koha-community.org/show_bug.cgi?id=13364 Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
f5ef85a345
commit
f94d4526e5
|
|
@ -245,6 +245,21 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
|
|||
|
||||
</script>
|
||||
[% END # / IF persona %]
|
||||
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
if($('#searchsubmit').length) {
|
||||
$(document).on("click", '#searchsubmit', function(e) {
|
||||
jQuery.removeCookie("form_serialized", { path: '/'});
|
||||
jQuery.removeCookie("form_serialized_itype", { path: '/'});
|
||||
jQuery.removeCookie("form_serialized_limits", { path: '/'});
|
||||
jQuery.removeCookie("num_paragraph", { path: '/'});
|
||||
jQuery.removeCookie("search_path_code", { path: '/'});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
[% PROCESS jsinclude %]
|
||||
|
||||
[% IF ( opacuserjs ) %]
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@
|
|||
<div class="span3">
|
||||
<fieldset>
|
||||
<legend>Audience</legend>
|
||||
<select name="limit" class="subtype">
|
||||
<select id="subtype_audience" name="limit" class="subtype">
|
||||
<option value="" selected="selected" class="menuheader">Any audience</option>
|
||||
<option value="aud:a">Preschool</option>
|
||||
<option value="aud:b">Primary</option>
|
||||
|
|
@ -271,7 +271,7 @@
|
|||
<div class="span3">
|
||||
<fieldset>
|
||||
<legend>Content</legend>
|
||||
<select name="limit" class="subtype">
|
||||
<select id="subtype_content" name="limit" class="subtype">
|
||||
<option value="" selected="selected" class="menuheader">Any content</option>
|
||||
<option value="fic:1">Fiction</option>
|
||||
<option value="fic:0">Non fiction</option>
|
||||
|
|
@ -285,7 +285,7 @@
|
|||
<div class="span3">
|
||||
<fieldset>
|
||||
<legend>Format</legend>
|
||||
<select name="limit" class="subtype">
|
||||
<select id="subtype_format" name="limit" class="subtype">
|
||||
<option value="" selected="selected" class="menuheader">Any format</option>
|
||||
<option value="l-format:ta">Regular print</option>
|
||||
<option value="l-format:tb">Large print</option>
|
||||
|
|
@ -304,7 +304,7 @@
|
|||
<div class="span3">
|
||||
<fieldset>
|
||||
<legend>Additional content types for books/printed materials</legend>
|
||||
<select name="limit" class="subtype">
|
||||
<select id="subtype_additional" name="limit" class="subtype">
|
||||
<option value="">Any</option>
|
||||
<option value="ctype:a">Abstracts/summaries</option>
|
||||
<option value="ctype:b">Bibliographies</option>
|
||||
|
|
@ -379,10 +379,60 @@
|
|||
[% END %]
|
||||
|
||||
[% BLOCK jsinclude %]
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.deserialize.min.js"></script>
|
||||
<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
$(document).ready(function() {
|
||||
$('#advsearches').tabs();
|
||||
$(document).ready(function() {
|
||||
$('#advsearches').tabs();
|
||||
jQuery.cookie.json = true;
|
||||
//$('#advsearches > ul').tabs();
|
||||
|
||||
[% IF ( ReturnToSearch ) %]
|
||||
if (form_serialized = jQuery.cookie("form_serialized")) {
|
||||
$('#advsearch form').deserialize(form_serialized);
|
||||
}
|
||||
if (form_serialized_limits = jQuery.cookie("form_serialized_limits")) {
|
||||
$('#language-limit') .val(form_serialized_limits[0]);
|
||||
$('#branchloop') .val(form_serialized_limits[1]);
|
||||
$('#subtype_audience') .val(form_serialized_limits[2]);
|
||||
$('#subtype_content') .val(form_serialized_limits[3]);
|
||||
$('#subtype_format') .val(form_serialized_limits[4]);
|
||||
$('#subtype_additional') .val(form_serialized_limits[5]);
|
||||
$('#locloop') .val(form_serialized_limits[6]);
|
||||
}
|
||||
[% ELSE %]
|
||||
//Clear all form cookies
|
||||
jQuery.removeCookie("form_serialized", { path: '/'});
|
||||
jQuery.removeCookie("form_serialized_itype", { path: '/'});
|
||||
jQuery.removeCookie("form_serialized_limits", { path: '/'});
|
||||
jQuery.removeCookie("num_paragraph", { path: '/'});
|
||||
jQuery.removeCookie("search_path_code", { path: '/'});
|
||||
[% END %]
|
||||
$('#advsearch form').submit(function() {
|
||||
form_serialized = $(this).serialize();
|
||||
jQuery.cookie("form_serialized", form_serialized,{ path: '/'});
|
||||
form_serialized_limits = [
|
||||
$('#language-limit').val(), $('#branchloop').val(),
|
||||
$('#subtype_audience').val(), $('#subtype_content').val(),
|
||||
$('#subtype_format').val(), $('#subtype_additional').val(),
|
||||
$('#locloop').val()
|
||||
];
|
||||
jQuery.cookie("form_serialized_limits", form_serialized_limits,{ path: '/'});
|
||||
[% IF ( expanded_options ) %]
|
||||
var numPar = $("#booleansearch fieldset p").size();
|
||||
if (numPar > [% search_boxes_count %]){
|
||||
jQuery.cookie("num_paragraph", numPar,{ path: '/'});
|
||||
}else{
|
||||
jQuery.cookie("num_paragraph", null,{ path: '/'});
|
||||
}
|
||||
jQuery.cookie("search_path_code", 'exs',{ path: '/'});
|
||||
[% ELSE %]
|
||||
jQuery.cookie("search_path_code", 'ads',{ path: '/'});
|
||||
jQuery.cookie("num_paragraph", null,{ path: '/'});
|
||||
[% END %]
|
||||
});
|
||||
|
||||
});
|
||||
/* This function allows to display a new field to search.
|
||||
*/
|
||||
$(document).on("click", '.ButtonPlus', function(e) {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@
|
|||
You did not specify any search criteria.
|
||||
[% END %]
|
||||
</p>
|
||||
[% IF ( ReturnPath ) %]
|
||||
<div class="returntosearch">
|
||||
<p><a href="[% ReturnPath %]">Return to the last advanced search</a></p>
|
||||
</div>
|
||||
[% END %]
|
||||
[% IF ( OPACNoResultsFound ) %]
|
||||
<div id="noresultsfound">
|
||||
[% OPACNoResultsFound %]
|
||||
|
|
@ -102,7 +107,13 @@
|
|||
[% END %]
|
||||
</ul>
|
||||
[% END # / IF koha_spsuggest%]
|
||||
|
||||
[% IF ( total ) %]
|
||||
[% IF ( ReturnPath ) %]
|
||||
<div class="returntosearch">
|
||||
<p><a href="[% ReturnPath %]">Return to the last advanced search</a></p>
|
||||
</div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF ( query_error ) %]
|
||||
<div class="dialog alert">
|
||||
<h4>Error:</h4>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
/*! jquery.cookie v1.4.1 | MIT */
|
||||
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a){function b(a){return h.raw?a:encodeURIComponent(a)}function c(a){return h.raw?a:decodeURIComponent(a)}function d(a){return b(h.json?JSON.stringify(a):String(a))}function e(a){0===a.indexOf('"')&&(a=a.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return a=decodeURIComponent(a.replace(g," ")),h.json?JSON.parse(a):a}catch(b){}}function f(b,c){var d=h.raw?b:e(b);return a.isFunction(c)?c(d):d}var g=/\+/g,h=a.cookie=function(e,g,i){if(void 0!==g&&!a.isFunction(g)){if(i=a.extend({},h.defaults,i),"number"==typeof i.expires){var j=i.expires,k=i.expires=new Date;k.setTime(+k+864e5*j)}return document.cookie=[b(e),"=",d(g),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}for(var l=e?void 0:{},m=document.cookie?document.cookie.split("; "):[],n=0,o=m.length;o>n;n++){var p=m[n].split("="),q=c(p.shift()),r=p.join("=");if(e&&e===q){l=f(r,g);break}e||void 0===(r=f(r))||(l[q]=r)}return l};h.defaults={},a.removeCookie=function(b,c){return void 0===a.cookie(b)?!1:(a.cookie(b,"",a.extend({},c,{expires:-1})),!a.cookie(b))}});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* @author Kyle Florence <kyle[dot]florence[at]gmail[dot]com>
|
||||
* @website https://github.com/kflorence/jquery-deserialize/
|
||||
* @version 1.2.1
|
||||
*
|
||||
* Dual licensed under the MIT and GPLv2 licenses.
|
||||
*/
|
||||
(function(i,b){var f=Array.prototype.push,a=/^(?:radio|checkbox)$/i,e=/\+/g,d=/^(?:option|select-one|select-multiple)$/i,g=/^(?:button|color|date|datetime|datetime-local|email|hidden|month|number|password|range|reset|search|submit|tel|text|textarea|time|url|week)$/i;function c(j){return j.map(function(){return this.elements?i.makeArray(this.elements):this}).filter(":input").get()}function h(j){var k,l={};i.each(j,function(n,m){k=l[m.name];l[m.name]=k===b?m:(i.isArray(k)?k.concat(m):[k,m])});return l}i.fn.deserialize=function(A,l){var y,n,q=c(this),t=[];if(!A||!q.length){return this}if(i.isArray(A)){t=A}else{if(i.isPlainObject(A)){var B,w;for(B in A){i.isArray(w=A[B])?f.apply(t,i.map(w,function(j){return{name:B,value:j}})):f.call(t,{name:B,value:w})}}else{if(typeof A==="string"){var v;A=A.split("&");for(y=0,n=A.length;y<n;y++){v=A[y].split("=");f.call(t,{name:decodeURIComponent(v[0]),value:decodeURIComponent(v[1].replace(e,"%20"))})}}}}if(!(n=t.length)){return this}var u,k,x,z,C,o,m,w,p=i.noop,s=i.noop,r={};l=l||{};q=h(q);if(i.isFunction(l)){s=l}else{p=i.isFunction(l.change)?l.change:p;s=i.isFunction(l.complete)?l.complete:s}for(y=0;y<n;y++){u=t[y];C=u.name;w=u.value;if(!(k=q[C])){continue}m=(z=k.length)?k[0]:k;m=(m.type||m.nodeName).toLowerCase();o=null;if(g.test(m)){if(z){x=r[C];k=k[r[C]=(x==b)?0:++x]}p.call(k,(k.value=w))}else{if(a.test(m)){o="checked"}else{if(d.test(m)){o="selected"}}}if(o){if(!z){k=[k];z=1}for(x=0;x<z;x++){u=k[x];if(u.value==w){p.call(u,(u[o]=true)&&w)}}}}s.call(this);return this}})(jQuery);
|
||||
|
|
@ -184,6 +184,21 @@ if (C4::Context->preference('TagsEnabled')) {
|
|||
|
||||
# load the branches
|
||||
|
||||
if ($cgi->param("returntosearch")) {
|
||||
$template->param('ReturnToSearch' => 1);
|
||||
}
|
||||
if ($cgi->cookie("search_path_code")) {
|
||||
my $pathcode = $cgi->cookie("search_path_code");
|
||||
given ($pathcode)
|
||||
{
|
||||
when ('"ads"') { $template->param('ReturnPath' => '/cgi-bin/koha/opac-search.pl?returntosearch=1'); }
|
||||
when ('"exs"') {
|
||||
$template->param('ReturnPath' => '/cgi-bin/koha/opac-search.pl?expanded_options=1&returntosearch=1');
|
||||
}
|
||||
default {warn "ReturnPath swith error";}
|
||||
}
|
||||
}
|
||||
|
||||
my $branches = GetBranches(); # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
|
||||
$template->param(
|
||||
searchdomainloop => GetBranchCategories('searchdomain'),
|
||||
|
|
@ -281,6 +296,12 @@ if ( $template_type && $template_type eq 'advsearch' ) {
|
|||
# box should only appear on the last, etc.
|
||||
my @search_boxes_array;
|
||||
my $search_boxes_count = 3; # begin whith 3 boxes
|
||||
$template->param( search_boxes_count => $search_boxes_count );
|
||||
|
||||
if ($cgi->cookie("num_paragraph")){
|
||||
$search_boxes_count = $cgi->cookie("num_paragraph");
|
||||
}
|
||||
|
||||
for (my $i=1;$i<=$search_boxes_count;$i++) {
|
||||
# if it's the first one, don't display boolean option, but show scan indexes
|
||||
if ($i==1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue