Bugzilla – Attachment 25450 Details for
Bug 10858
Browse selected biblios - OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10858: Browse selected biblios
Bug-10858-Browse-selected-biblios.patch (text/plain), 16.19 KB, created by
Jonathan Druart
on 2014-02-19 16:36:24 UTC
(
hide
)
Description:
Bug 10858: Browse selected biblios
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-02-19 16:36:24 UTC
Size:
16.19 KB
patch
obsolete
>From d9b24b84c841d9068d96598b35aa9fb3e86b8362 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 14 Nov 2012 17:05:45 +0100 >Subject: [PATCH] Bug 10858: Browse selected biblios > >After launching a search, some people would like to browse some results >from several pages. > >This patch adds, at the OPAC, a link "Browse selected biblios >>" when >at least one biblio is checked. You can choose biblios from several >page, not the current one. In this way, checkboxes already checked >become again checked when you come back on this results page. >After clicking the link, the "Browse results" block is filled with >selected biblios, not (like as the current behavior) with the classic >results. > >Test plan: >- Launch a search at the OPAC >- Check some biblios >- Go on another page >- Check some biblios >- Come back to the first page and check that already checked biblio is > automatically checked. >- Click on the "Browse selected biblios >>" link >- Check that you are able to browse results you had checked. > >Signed-off-by: Cedric Vita <cedric.vita@dracenie.com> > >Signed-off-by: Koha Team Amu <koha.aixmarseille@gmail.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > .../opac-tmpl/ccsr/en/includes/doc-head-close.inc | 2 + > .../opac-tmpl/prog/en/includes/doc-head-close.inc | 2 + > koha-tmpl/opac-tmpl/prog/en/js/commons.js | 71 ++++++++++++++++++++ > .../en/lib/jquery/plugins/jquery.cookie.min.js | 1 + > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 17 +++-- > .../opac-tmpl/prog/en/modules/opac-results.tt | 48 +++++++++++++ > opac/opac-detail.pl | 21 +++++- > 7 files changed, 154 insertions(+), 8 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/commons.js > create mode 100644 koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js > >diff --git a/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc >index af6e886..de1a724 100644 >--- a/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc >+++ b/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc >@@ -39,6 +39,8 @@ > <script type="text/javascript" src="[% yuipath %]/menu/menu-min.js"></script> > <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script> > <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.cookie.min.js"></script> >+<script type="text/javascript" src="[% themelang %]/js/commons.js"></script> > <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.hoverIntent.minified.js"></script> > <script type="text/javascript" src="[% themelang %]/js/script.js"></script> > [% IF ( OPACAmazonCoverImages ) %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc >index 66666f4..5adae58 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc >@@ -35,6 +35,8 @@ > <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery.js"></script> > <script type="text/javascript" src="[% themelang %]/lib/jquery/jquery-ui.js"></script> > <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.hoverIntent.minified.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.cookie.min.js"></script> >+<script type="text/javascript" src="[% themelang %]/js/commons.js"></script> > <script type="text/javascript" src="[% themelang %]/js/script.js"></script> > [% IF ( OPACAmazonCoverImages ) %] > <script type="text/javascript" language="javascript">//<![CDATA[ >diff --git a/koha-tmpl/opac-tmpl/prog/en/js/commons.js b/koha-tmpl/opac-tmpl/prog/en/js/commons.js >new file mode 100644 >index 0000000..6661a61 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/js/commons.js >@@ -0,0 +1,71 @@ >+// Extends jQuery API >+// http://www.wskidmore.com/downloads/jquery-uniqueArray.min.js >+jQuery.extend({uniqueArray:function(e){if($.isArray(e)){var c={};var a,b;for(b=0,a=e.length;b<a;b++){var d=e[b].toString();if(c[d]){e.splice(b,1);a--;b--}else{c[d]=true}}}return(e)}}); >+ >+function removeByValue(arr, val) { >+ for(var i=0; i<arr.length; i++) { >+ if(arr[i] == val) { >+ arr.splice(i, 1); >+ break; >+ } >+ } >+} >+ >+function paramOfUrl( url, param ) { >+ param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); >+ var regexS = "[\\?&]"+param+"=([^&#]*)"; >+ var regex = new RegExp( regexS ); >+ var results = regex.exec( url ); >+ if( results == null ) { >+ return ""; >+ } else { >+ return results[1]; >+ } >+} >+ >+function addBibToContext( bibnum ) { >+ var bibnums = getContextBiblioNumbers(); >+ bibnums.push(bibnum); >+ setContextBiblioNumbers( bibnums ); >+ //var store = sessionStorage.getItem( "bibs_selected" ); >+} >+ >+function delBibToContext( bibnum ) { >+ var bibnums = getContextBiblioNumbers(); >+ removeByValue( bibnums, bibnum ); >+ setContextBiblioNumbers( $.uniqueArray( bibnums ) ); >+} >+ >+function setContextBiblioNumbers( bibnums ) { >+ //sessionStorage.setItem("bibs_selected", JSON.stringify( bibnums ) ); >+ $.cookie('bibs_selected', JSON.stringify( bibnums )); >+} >+ >+function getContextBiblioNumbers() { >+ //var r = sessionStorage.getItem("bibs_selected"); >+ var r = $.cookie('bibs_selected'); >+ if ( r ) { >+ return JSON.parse(r); >+ } >+ r = new Array(); >+ return r; >+} >+ >+function resetSearchContext() { >+ setContextBiblioNumbers( new Array() ); >+} >+ >+$(document).ready(function(){ >+ // forms with action leading to search >+ $("form[action*='opac-search.pl']").submit(function(){ >+ resetSearchContext(); >+ }); >+ // any link to launch a search except navigation links >+ $("[href*='opac-search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >+ resetSearchContext(); >+ }); >+ // any link to a detail page from the results page. >+ $("#bookbag_form a[href*='opac-detail.pl?']").click(function(){ >+ resetSearchContext(); >+ }); >+}); >diff --git a/koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js b/koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js >new file mode 100644 >index 0000000..eb129db >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/lib/jquery/plugins/jquery.cookie.min.js >@@ -0,0 +1 @@ >+jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}}; >\ No newline at end of file >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index 3f3ade7..97fde01 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -154,6 +154,7 @@ > renderPagIndexList(pag_index_ini, $("#listResults")); > } > $("#a_listResults").click(function(e) { >+ $("#sidebar").toggle(); > if (arrPagination.length > 0) { > e.preventDefault(); > var navigation = $(".pagination"); >@@ -173,6 +174,7 @@ > e.preventDefault(); > var navigation = $(".pagination"); > navigation.hide(); >+ $("#sidebar").toggle(); > }); > [% END %] > >@@ -285,8 +287,9 @@ function parseIDBJSON( json ) { > var timeoutRFW; > var totalPagItemList = 10; > >-function rewindList() >+function rewindList(e) > { >+ e.preventDefault(); > var ul = $("#listResults"); > var li_ini = ul.children(':first').next(); > var index_ini = pag_index_ini; >@@ -304,8 +307,9 @@ function rewindList() > } > }//rewindList > >-function forwardList() >+function forwardList(e) > { >+ e.preventDefault(); > var ul = $("#listResults"); > var li_ini = ul.children(':first').next(); > var index_ini = pag_index_ini; >@@ -336,7 +340,7 @@ function renderPagIndexList(index, ul) > var ini = index - 1; > var end = ini + totalPagItemList - 1; > li = $("<li />"); >- html = (index > pag_index_ini)?"<a href='#' id='rew_list_index' onclick='rewindList()' title='" + _("Click to rewind the list to") + " " + ini + " - " + end + "'>«</a>":"«"; >+ html = (index > pag_index_ini)?"<a href='#' id='rew_list_index' onclick='rewindList(event)' title='" + _("Click to rewind the list to") + " " + ini + " - " + end + "'>«</a>":"«"; > li.html(html); > ul.append(li); > var title = ""; >@@ -358,7 +362,7 @@ function renderPagIndexList(index, ul) > li = $("<li />"); > ini = index + 1; > end = (arrPagination.length > index + totalPagItemList)?index + totalPagItemList:arrPagination.length - 1; >- html = (end <= arrPagination.length - 1 && (end - index) >= totalPagItemList)?"<a href='#' id='fw_list_index' onclick='forwardList()' title='" + _("Click to forward the list to") + " " + ini + " - " + end + "'>»</a>":"»"; >+ html = (end <= arrPagination.length - 1 && (end - index) >= totalPagItemList)?"<a href='#' id='fw_list_index' onclick='forwardList(event)' title='" + _("Click to forward the list to") + " " + ini + " - " + end + "'>»</a>":"»"; > li.html(html); > ul.append(li); > }//renderPagIndexList >@@ -1423,7 +1427,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <div class="l_Results">[% IF ( listResults ) %]<a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>[% ELSE %]<span>Browse results</span>[% END %]</div> > <ul class="pg_menu clearfix"> > <li class="left_results">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">« Previous</a>[% ELSE %]<span>Previous</span>[% END %]</li> >- <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list">Back to results</a></li> >+ <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list" class="searchwithcontext">Back to results</a></li> > <li class="right_results">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next »</a>[% ELSE %]<span>Next</span>[% END %]</li> > </ul> > [% IF ( listResults ) %] >@@ -1440,6 +1444,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > </div> > [% END %] > >+<div id="sidebar"> > [% INCLUDE 'opac-detail-sidebar.inc' %] > [% IF ( NovelistSelectProfile ) %] [% IF ( NovelistSelectView == 'right') %] > <div id="NovelistSelect"> >@@ -1468,6 +1473,8 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% END %] > > </div> >+ >+</div> > </div> > </div> > >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 9235b2b..4ccc009 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -109,6 +109,19 @@ function highlightOn() { > $(".highlight_toggle").toggle(); > } > [% END %] >+ >+// Hide or show details link >+// Update with first biblionumber in queue >+function updateDetailsLink() { >+ var bibnums = getContextBiblioNumbers(); >+ if ( bibnums.length > 0 ) { >+ $(".details_link a").attr("href", "/cgi-bin/koha/opac-detail.pl?biblionumber=" + bibnums[0]); >+ $(".details_link").show(); >+ } else { >+ $(".details_link").hide(); >+ } >+} >+ > $(document).ready(function(){ > [% IF ( OpacHighlightedWords ) %] > $('a.title').each(function() { >@@ -233,10 +246,17 @@ $(document).ready(function(){ > } > $("#CheckAll").click(function(){ > $("#bookbag_form").checkCheckboxes(); >+ $("#bookbag_form").find("input[type='checkbox'][name='biblionumber']").each(function(){ >+ $(this).change(); >+ } ); > return false; > }); > $("#CheckNone").click(function(){ > $("#bookbag_form").unCheckCheckboxes(); >+ >+ $("#bookbag_form").find("input[type='checkbox'][name='biblionumber']").each(function(){ >+ $(this).change(); >+ } ); > return false; > }); > [% IF ( RequestOnOpac ) %] >@@ -343,6 +363,33 @@ $(document).ready(function(){ > }); > [% END %] > >+ $("#bookbag_form").ready(function(){ >+ $("#bookbag_form").unCheckCheckboxes(); >+ var bibnums = getContextBiblioNumbers(); >+ if (bibnums) { >+ for (var i=0; i < bibnums.length; i++) { >+ var id = ('#bib' + bibnums[i]); >+ if ($(id)) { >+ $(id).attr('checked', true); >+ } >+ } >+ } >+ updateDetailsLink(); >+ }); >+ >+ $("#bookbag_form :checkbox").change(function(){ >+ if ( $(this).is(':checked') == true ) { >+ addBibToContext( $(this).val() ); >+ } else { >+ delBibToContext( $(this).val() ); >+ } >+ updateDetailsLink(); >+ }); >+ >+ $(".details_link a").click(function(){ >+ var bibnums = getContextBiblioNumbers(); >+ >+ }); > }); > > //]]> >@@ -482,6 +529,7 @@ $(document).ready(function(){ > Tag status here. > </span> > [% END %] >+ <span class="details_link" style="display:none" ><a href="#">Browse selected biblios >></a></span> > </div> > > </td></tr> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 0f6906b..089f087 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -24,6 +24,7 @@ use strict; > use warnings; > > use CGI; >+use JSON; > use C4::Auth qw(:DEFAULT get_session); > use C4::Branch; > use C4::Koha; >@@ -209,11 +210,22 @@ if ($session->param('busc')) { > push @{$arrParamsBusc{$key}}, $value; > } > } >+ > my $searchAgain = 0; >+ my ( $offset, $results_per_page ); >+ >+ my $bibnums = $query->cookie('bibs_selected'); >+ $bibnums = JSON::from_json($bibnums); >+ if ( scalar( @$bibnums ) ) { >+ $arrParamsBusc{count} = scalar( @$bibnums ); >+ $arrParamsBusc{listBiblios} = join ',', @$bibnums; >+ $results_per_page = $arrParamsBusc{count}; >+ $offset = 0; >+ } else { >+ $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0; > my $count = C4::Context->preference('OPACnumSearchResults') || 20; >- my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count; >+ $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count; > $arrParamsBusc{'count'} = $results_per_page; >- my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0; > # The value OPACnumSearchResults has changed and the search has to be rebuild > if ($count != $results_per_page) { > if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) { >@@ -273,6 +285,9 @@ if ($session->param('busc')) { > @arrBusc = split(/\&(?:amp;)?/, $newbusc); > } > } >+ >+ } # end if cookie bibs_selected exists >+ > my $buscParam = ''; > my $j = 0; > # Rebuild the query for the button "back to results" >@@ -339,7 +354,7 @@ if ($session->param('busc')) { > } > $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0); > } >- if ($searchAgain) { >+ if ($searchAgain and not scalar( @$bibnums )) { > my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page); > my @newresults = @$newresultsRef; > # build the new listBiblios >-- >1.7.10.4
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 10858
:
20947
|
21476
|
21483
|
21646
|
21647
|
21966
|
21967
|
23541
|
23542
|
23543
|
23633
|
23781
|
23782
|
25427
|
25428
|
25429
|
25430
|
25431
|
25432
|
25433
|
25434
|
25435
|
25436
|
25450
|
25451
|
25452
|
25453
|
25454
|
25455
|
25456
|
25457
|
25512
|
25513
|
25514
|
25643
|
25644
|
25645
|
25646
|
25647
|
25648
|
25649
|
25650
|
25651
|
25652
|
25653
|
36757
|
38033
|
38405
|
39502
|
39938
|
41838
|
41839
|
41840
|
41841
|
41842
|
44903
|
56479
|
56480
|
56481
|
56482
|
67073
|
67074
|
67075
|
67076
|
67086
|
67089
|
67090
|
67092
|
67093
|
67974
|
67975
|
67976
|
67977
|
67978
|
71218
|
71219
|
71220
|
71221
|
71222
|
71223
|
91584
|
91585
|
91586
|
91587
|
91588
|
91589
|
94833