Bugzilla – Attachment 42481 Details for
Bug 11311
Browse selected authorities
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11311: Browse selected authorities
Bug-11311-Browse-selected-authorities.patch (text/plain), 16.31 KB, created by
Julian Maurice
on 2015-09-11 12:57:12 UTC
(
hide
)
Description:
Bug 11311: Browse selected authorities
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2015-09-11 12:57:12 UTC
Size:
16.31 KB
patch
obsolete
>From 8e33b3af111b889548ea4e7b5a6d603f436674e6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 27 Nov 2013 14:36:09 +0100 >Subject: [PATCH] Bug 11311: Browse selected authorities > >In the same way as the feature "Browse selected biblios", this one adds >the same browse feature for authorities. > >After launching an authority search, some people would like to browse >some results from several pages. > >This patch adds, at the OPAC, a link "Browse selected authorities >>" when >at least one authority is checked. You can choose authorities from several >page, not only 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 authotiries. > >Test plan: >- Launch an authority search at the OPAC >- Check some authorities >- Go on another page >- Check some authorities >- Come back to the first page and check that already checked authorities is > automatically checked. >- Click on the "Browse selected authorities >>" link >- Check that you are able to browse results you had checked. >--- > C4/Auth.pm | 4 ++ > .../bootstrap/en/modules/opac-auth-detail.tt | 38 ++++++++++++++-- > .../en/modules/opac-authoritiessearchresultlist.tt | 51 +++++++++++++++++++--- > koha-tmpl/opac-tmpl/bootstrap/js/commons.js | 47 ++++++++++++++++++-- > opac/opac-authorities-home.pl | 20 +++++++-- > opac/opac-authoritiesdetail.pl | 19 +++++++- > 6 files changed, 163 insertions(+), 16 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index ef0c585..1455aa0 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -447,6 +447,10 @@ sub get_template_and_user { > my $sessionSearch = get_session( $sessionID || $in->{'query'}->cookie("CGISESSID") ); > $sessionSearch->clear( ["busc"] ) if ( $sessionSearch->param("busc") ); > } >+ unless ( $pagename =~ /^auth-detail$/ ) { >+ my $sessionSearch = get_session($sessionID || $in->{'query'}->cookie("CGISESSID")); >+ $sessionSearch->clear(["busc_auth"]) if ($sessionSearch->param("busc_auth")); >+ } > } > > # variables passed from CGI: opac_css_override and opac_search_limits. >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt >index 1032eee..3e0004d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt >@@ -23,10 +23,17 @@ > [% INCLUDE 'navigation.inc' %] > </div> > </div> >- <div class="span10"> >- [% ELSE %] >- <div class="span12"> > [% END %] >+ >+ [% content_width = 12 %] >+ [% IF (OpacNav || OpacNavBottom) %] >+ [% content_width = content_width - 2 %] >+ [% END %] >+ [% IF Koha.Preference('OpacBrowseResults') && (previous || next) %] >+ [% content_width = content_width - 3 %] >+ [% END %] >+ >+ <div class="span[% content_width %]"> > <div id="userauthdetails" class="maincontent"> > <div id="views"> > <span class="view"> >@@ -121,6 +128,31 @@ > </div> > </div> <!-- / .#userauthdetails --> > </div> <!-- / .span10/12 --> >+ >+ [% IF Koha.Preference('OpacBrowseResults') && ( previous || next ) %] >+ <div class="span3"> >+ <div class="nav_results"> >+ <ul class="pg_menu clearfix"> >+ <li class="left_results"> >+ [% IF previous %] >+ <a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% previous %]" title="previous authority">« Previous</a> >+ [% ELSE %] >+ <span>Previous</span> >+ [% END %] >+ </li> >+ <li class="back_results"><a href="opac-authorities-home.pl?[% busc_auth %]" title="Back to the results search list" class="searchwithcontext">Back to results</a></li> >+ <li class="right_results"> >+ [% IF next %] >+ <a href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% next %]" title="next authority">Next »</a> >+ [% ELSE %] >+ <span>Next</span> >+ [% END %] >+ </li> >+ </ul> >+ </div> >+ </div> >+ [% END %] >+ > </div> <!-- / .row-fluid --> > </div> <!-- / .container-fluid --> > </div> <!-- / .main --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt >index 4ebaac6..e443070 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt >@@ -6,7 +6,7 @@ > <ul> > [% IF ( displayprev ) %] > <li> >- <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage |html %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby|html %]"> >+ <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage |html %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby|html %]" class="nav"> > « > </a> > </li> >@@ -15,12 +15,12 @@ > [% IF ( number.highlight ) %] > <li class="active"><a href="#">[% number.number %]</a></li> > [% ELSE %] >- <li><a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage |html %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby|html %]">[% number.number %]</a></li> >+ <li><a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage |html %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby|html %]" class="nav">[% number.number %]</a></li> > [% END %] > [% END %] > [% IF ( displaynext ) %] > <li> >- <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]&resultsperpage=[% resultsperpage |html %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby|html %]">»</a> >+ <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]&resultsperpage=[% resultsperpage |html %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby|html %]" class="nav">»</a> > </li> > [% END %] > </ul> >@@ -55,6 +55,7 @@ > [% END %] > <div id="userauthsearchresults" class="maincontent"> > <h1>Authority search results</h1> >+ <span class="details_link"><a href="#">Browse selected records</a></span> > > [% pagination %] > >@@ -75,6 +76,7 @@ > <table class="table table-bordered table-striped"> > <thead> > <tr> >+ <th></th> > <th>Authorized headings</th> > <th>Type of heading</th> > [% UNLESS ( isEDITORS ) %] >@@ -86,7 +88,8 @@ > <tbody> > [% FOREACH resul IN result %] > <tr> >- <td>[% PROCESS authresult summary=resul.summary %]</td> >+ <td><input type="checkbox" id="auth[% resul.authid %]" name="authid" value="[% resul.authid %]" /></td> >+ <td>[% PROCESS authresult summary=resul.summary %]</td> > <td>[% resul.authtype %]</td> > [% UNLESS ( resul.isEDITORS ) %] > <td> >@@ -112,4 +115,42 @@ > </div> <!-- / .main --> > > [% INCLUDE 'opac-bottom.inc' %] >-[% BLOCK jsinclude %][% END %] >+[% BLOCK jsinclude %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+ <script type="text/javascript"> >+ //<![CDATA[ >+ function updateDetailsLink() { >+ var authids = getContextAuthIds(); >+ if ( authids.length > 0 ) { >+ $(".details_link a").attr("href", "/cgi-bin/koha/opac-authoritiesdetail.pl?authid=" + authids[0]); >+ $(".details_link").show(); >+ } else { >+ $(".details_link").hide(); >+ } >+ } >+ >+ $(document).ready(function(){ >+ $("div.searchresults").unCheckCheckboxes(); >+ var authids = getContextAuthIds(); >+ if ( authids ) { >+ for (var i = 0 ; i < authids.length ; i++ ) { >+ var id = ('#auth' + authids[i]); >+ if ( $(id) ) { >+ $(id).attr('checked', true); >+ } >+ } >+ updateDetailsLink(); >+ } >+ $("input[name='authid']").change(function(){ >+ if ( $(this).is(':checked') == true ) { >+ addAuthToContext( $(this).val() ); >+ } else { >+ delAuthToContext( $(this).val() ); >+ } >+ updateDetailsLink(); >+ }); >+ }); >+ >+ //]]> >+ </script> >+[% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/commons.js b/koha-tmpl/opac-tmpl/bootstrap/js/commons.js >index c9c724a..c561f9f 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/commons.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/commons.js >@@ -33,16 +33,32 @@ function addBibToContext( bibnum ) { > setContextBiblioNumbers( $.uniqueArray( bibnums ) ); > } > >+function addAuthToContext( authid ) { >+ var authids = getContextAuthIds(); >+ authids.push( authid ); >+ setContextAuthIds( authids ); >+} >+ > function delBibToContext( bibnum ) { > var bibnums = getContextBiblioNumbers(); > removeByValue( bibnums, bibnum ); > setContextBiblioNumbers( $.uniqueArray( bibnums ) ); > } > >+function delAuthToContext( authid ) { >+ var authids = getContextAuthIds(); >+ removeByValue( authids, authid ); >+ setContextAuthIds( $.uniqueArray( authids ) ); >+} >+ > function setContextBiblioNumbers( bibnums ) { > $.cookie('bibs_selected', JSON.stringify( bibnums )); > } > >+function setContextAuthIds( authids ) { >+ $.cookie('auths_selected', JSON.stringify( authids )); >+} >+ > function getContextBiblioNumbers() { > var r = $.cookie('bibs_selected'); > if ( r ) { >@@ -52,21 +68,44 @@ function getContextBiblioNumbers() { > return r; > } > >-function resetSearchContext() { >+function getContextAuthIds() { >+ var r = $.cookie('auths_selected'); >+ if ( r ) { >+ return JSON.parse(r); >+ } >+ r = new Array(); >+ return r; >+} >+ >+function resetBiblioSearchContext() { > setContextBiblioNumbers( new Array() ); > } > >+function resetAuthSearchContext() { >+ setContextAuthIds( new Array() ); >+} >+ > $(document).ready(function(){ > // forms with action leading to search > $("form[action*='opac-search.pl']").submit(function(){ >- resetSearchContext(); >+ resetBiblioSearchContext(); > }); > // any link to launch a search except navigation links > $("[href*='opac-search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >- resetSearchContext(); >+ resetBiblioSearchContext(); > }); > // any link to a detail page from the results page. > $("#bookbag_form a[href*='opac-detail.pl?']").click(function(){ >- resetSearchContext(); >+ resetBiblioSearchContext(); >+ }); >+ >+ $("form[action*='opac-authorities-home.pl']").submit(function(){ >+ resetAuthSearchContext(); >+ }); >+ $("[href*='opac-authorities-home.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >+ resetBiblioSearchContext(); >+ }); >+ $("#opac-authorities-home.pl a[href*='opac-authorities-home.pl?']").click(function(){ >+ resetAuthSearchContext(); > }); > }); >diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl >index 54c1444..1f1cbca 100755 >--- a/opac/opac-authorities-home.pl >+++ b/opac/opac-authorities-home.pl >@@ -22,7 +22,7 @@ use strict; > use warnings; > > use CGI qw ( -utf8 ); >-use C4::Auth; >+use C4::Auth qw( get_session ); > > use C4::Context; > use C4::Auth; >@@ -66,8 +66,8 @@ if ( $op eq "do_search" ) { > my $orderby = $query->param('orderby'); > my @value = ($query->param('value') || "",); > >- $resultsperpage = $query->param('resultsperpage'); >- $resultsperpage = 20 if ( !defined $resultsperpage ); >+ $resultsperpage = $query->param('resultsperpage') // 20; >+ > my @tags; > my ( $results, $total, @fields ) = > SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, >@@ -161,6 +161,20 @@ if ( $op eq "do_search" ) { > } > } > >+ if ( C4::Context->preference("OpacBrowseResults") ) { >+ my $busc_params; >+ $busc_params .= 'op=do_search&authtypecode='.$authtypecode; >+ $busc_params .= '&marclist=' . $_ for @marclist; >+ $busc_params .= '&and_or=' . $_ for @and_or; >+ $busc_params .= '&excluding=' . $_ for @excluding; >+ $busc_params .= '&operator=' . $_ for @operator; >+ $busc_params .= '&orderby=' . $orderby; >+ $busc_params .= '&value=' . $_ for @value; >+ $busc_params .= '&resultsperpage=' . $resultsperpage; >+ my $session = get_session( $query->cookie("CGISESSID") ); >+ $session->param( busc_auth => $busc_params ); >+ } >+ > $template->param( result => $results ) if $results; > $template->param( FIELDS => \@fields ); > $template->param( orderby => $orderby ); >diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl >index 79c70db..d097558 100755 >--- a/opac/opac-authoritiesdetail.pl >+++ b/opac/opac-authoritiesdetail.pl >@@ -40,13 +40,16 @@ use strict; > use warnings; > > use C4::AuthoritiesMarc; >-use C4::Auth; >+use C4::Auth qw( :DEFAULT get_session ); > use C4::Context; > use C4::Output; > use CGI qw ( -utf8 ); > use MARC::Record; > use C4::Koha; > >+use JSON; >+use List::MoreUtils qw( first_index ); >+ > > my $query = new CGI; > >@@ -169,6 +172,20 @@ if ($show_marc) { > } > $template->param( "Tab0XX" => \@loop_data ); > } else { >+ my $authids = $query->cookie('auths_selected'); >+ $authids = $authids ? JSON::from_json($authids) : []; >+ if ( scalar( @$authids ) ) { >+ my $idx = first_index { $_ == $authid } @$authids; >+ my $previous = $idx ? $authids->[$idx - 1] : undef; >+ my $next = ( $idx + 1 < @$authids ) ? $authids->[$idx + 1] : undef; >+ my $session = get_session($query->cookie("CGISESSID")); >+ >+ $template->param( >+ previous => $previous, >+ next => $next, >+ busc_auth => $session->param("busc_auth"), >+ ); >+ } > my $summary = BuildSummary($record, $authid, $authtypecode); > $template->{VARS}->{'summary'} = $summary; > } >-- >1.9.1
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 11311
:
23185
| 42481