Bugzilla – Attachment 23185 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), 17.33 KB, created by
Jonathan Druart
on 2013-11-27 13:38:45 UTC
(
hide
)
Description:
Bug 11311: Browse selected authorities
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-11-27 13:38:45 UTC
Size:
17.33 KB
patch
obsolete
>From 769f934e01f71e60461e49784b2d5825cc267556 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 ++ > koha-tmpl/opac-tmpl/prog/en/js/commons.js | 47 ++++++++++++++++-- > .../opac-tmpl/prog/en/modules/opac-auth-detail.tt | 32 +++++++++++- > .../en/modules/opac-authoritiessearchresultlist.tt | 52 +++++++++++++++++--- > opac/opac-authorities-home.pl | 22 +++++++-- > opac/opac-authoritiesdetail.pl | 19 ++++++- > 6 files changed, 161 insertions(+), 15 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 8b0bebe..d1f1ae2 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -380,6 +380,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. > my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'}; >diff --git a/koha-tmpl/opac-tmpl/prog/en/js/commons.js b/koha-tmpl/opac-tmpl/prog/en/js/commons.js >index 490bfdf..3dbd6d0 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/js/commons.js >+++ b/koha-tmpl/opac-tmpl/prog/en/js/commons.js >@@ -30,17 +30,33 @@ function addBibToContext( bibnum ) { > //var store = sessionStorage.getItem( "bibs_selected" ); > } > >+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 ) { > //sessionStorage.setItem("bibs_selected", JSON.stringify( bibnums ) ); > $.cookie('bibs_selected', JSON.stringify( bibnums )); > } > >+function setContextAuthIds( authids ) { >+ $.cookie('auths_selected', JSON.stringify( authids )); >+} >+ > function getContextBiblioNumbers() { > //var r = sessionStorage.getItem("bibs_selected"); > var r = $.cookie('bibs_selected'); >@@ -51,22 +67,45 @@ 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/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt >index 78bc5b9..6714b0d 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt >@@ -31,8 +31,10 @@ $(document).ready(function() { > <div id="bd"> > [% INCLUDE 'masthead.inc' %] > <div id="yui-main"> >- <div class="yui-b"><div class="yui-g"> >+ <div class="yui-b"> >+ <div id="opac-auth-detail-yui-ge" class="yui-ge"> > >+ <div class="yui-u first"> > <div id="views"><span class="view"><span id="Normalview">Normal view</span></span> <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% authid %]&marc=1">MARC view</a></span></div> > > <div id="userauthdetails" class="container"> >@@ -105,6 +107,34 @@ $(document).ready(function() { > </div> > </div> > >+[% IF Koha.Preference('OpacBrowseResults') && ( previous || next ) %] >+<div class="yui-u"> >+<div id="ulactioncontainer" class="container"> >+ <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> >+</div> >+[% END %] >+ >+</div> >+</div> > </div> > </div> > </div> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt >index 71ad40e..5936ace 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt >@@ -3,6 +3,43 @@ > [% PROCESS 'authorities-search-results.inc' %] > [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › [% IF ( total ) %]Authority search result[% ELSE %]No results found[% END %] > [% INCLUDE 'doc-head-close.inc' %] >+<script type="text/javascript" src="[% themelang %]/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> > </head> > <body id="opac-authoritiesresultlist"> > [% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %] >@@ -13,9 +50,10 @@ > <div class="yui-b"><div class="yui-g"> > <div id="userauthsearchresults" class="container"> > <h1>Authority search results</h1> >+ <span class="details_link"><a href="#">Browse selected records</a></span> > <div id="pages"> > [% IF ( displayprev ) %] >- <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]"> >+ <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]" class="nav"> > << > </a> > [% END %] >@@ -23,11 +61,11 @@ > [% IF ( number.highlight ) %] > <span class="current">[% number.number %]</span> > [% ELSE %] >- <a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]">[% number.number %]</a> >+ <a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]" class="nav">[% number.number %]</a> > [% END %] > [% END %] > [% IF ( displaynext ) %] >- <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]&resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]">>></a> >+ <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]&resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]" class="nav">>></a> > [% END %] > </div> > <div id="results"> >@@ -46,6 +84,7 @@ > <div class="searchresults"> > <table> > <tr> >+ <th></th> > <th>Authorized headings</th> > <th>Type of heading</th> > [% UNLESS ( isEDITORS ) %] >@@ -59,6 +98,7 @@ > [% ELSE %] > <tr> > [% END %] >+ <td><input type="checkbox" id="auth[% resul.authid %]" name="authid" value="[% resul.authid %]" /></td> > <td>[% PROCESS authresult summary=resul.summary link="/cgi-bin/koha/opac-authorities-home.pl?op=do_search&type=opac&operatorc=contains&marclistc=mainentry&and_orc=and&orderby=HeadingAsc&valuec=" %]</td> > <td>[% resul.authtype %]</td> > [% UNLESS ( resul.isEDITORS ) %] >@@ -75,15 +115,15 @@ > </div> > <div id="resultnumber"> > [% IF ( displayprev ) %] >- <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]"><<</a> >+ <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]" class="nav"><<</a> > [% END %] > [% FOREACH number IN numbers %] > [% IF ( number.highlight ) %]<span class="current">[% number.number %]</span>[% ELSE %] >- <a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]">[% number.number %]</a> >+ <a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]" class="nav">[% number.number %]</a> > [% END %] > [% END %] > [% IF ( displaynext ) %] >- <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]&resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]">>></a> >+ <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&[% END %]&resultsperpage=[% resultsperpage %]&type=opac&op=do_search&authtypecode=[% authtypecode %]&orderby=[% orderby %]" class="nav">>></a> > [% END %] > </div> > [% END %] >diff --git a/opac/opac-authorities-home.pl b/opac/opac-authorities-home.pl >index 115012e..daff9b0 100755 >--- a/opac/opac-authorities-home.pl >+++ b/opac/opac-authorities-home.pl >@@ -22,7 +22,8 @@ use strict; > use warnings; > > use CGI; >-use C4::Auth; >+use C4::Auth qw( get_session ); >+ > > use C4::Context; > use C4::Auth; >@@ -65,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, >@@ -129,6 +130,21 @@ if ( $op eq "do_search" ) { > my @usedauths = grep { $_->{used} > 0 } @$results; > $results = \@usedauths; > } >+ >+ 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 3e17cf1..7c0e189 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; > 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.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 11311
:
23185
|
42481