Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-overdrive-search.tt
Nick Clemens e762bdb9b2 Bug 21082: Update OverDrive authentication method
Testing will require an OverDrive account, you should be able to obtain a
developer account here:
https://developer.overdrive.com/

You will need to register a SIP connection for patron authentication

To test authentication:
 1 - Set authname default in OD prefs
 2 - Sign in as a patron whose branch matches authname
 3 - Verify the patron can sign into OverDrive
 4 - Set the patrons branch authname to be incorrect
 5 - Verify branch specific authname is used and patron cannot sign in
 6 - Set the default authname to be incorrect and patron's branch
 authname to be correct
 7 - Verofy patron can sign in

To test circulation:
 1 - Fill out all OD prefs and enable circulation
 2 - Sign in to opac
 3 - Verify you have an OverDrive tab
 4 - Click 'Login to Overdrive'
 5 - If password required you shoudl be prompted, otherwise you should be
signed in and see account info
 6 - Test logging out and in
 7 - Log-in, perform a search on the opac - you should see hold/checkout
buttons
 8 - Test the buttons
 9 - After holding/checking out items, check your account page
10 - Verify info is correct
11 - Log out of overdrive
12 - Search catalog click overdrive results
13 - Test "Login to Overdrive" link on OD results
14 - Verify page is reloaded, buttons show and work

Signed-off-by: Sandy Allgood <sandy.allgood@citruslibraries.org>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-09 11:04:23 +00:00

201 lines
8.1 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; OverDrive search for '[% q | html %]'</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]
[% Asset.css("css/jquery.rating.css") | $raw %]
<style>
.actions a.addtocart {
display: inline;
}
</style>
[% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='overdrive-results-page' bodyclass='scrollto' %]
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li><a href="#">OverDrive search for '[% q | html %]'</a></li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
[% IF ( OpacNav || OpacNavBottom ) %]
[% INCLUDE 'navigation.inc' %]
[% END %]
</div>
<div class="span10">
<div id="overdrive-results-content" class="maincontent searchresults">
<h1>OverDrive search for '[% q | html %]'</h1>
<div id="breadcrumbs">
<p></p>
</div>
<div id="top-pages">
<div class="pagination pagination-small">
</div>
</div>
<table id="overdrive-results-list" class="table table-striped">
<tbody>
</tbody>
</table>
<div id="bottom-pages">
<div class="pagination pagination-small">
</div>
</div>
</div> <!-- / #overdrive-results-content -->
</div> <!-- / .span10 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
</div> <!-- / .main -->
[% INCLUDE 'overdrive-checkout.inc' %]
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% Asset.js("js/overdrive.js") | $raw %]
[% Asset.js("lib/jquery/plugins/jquery.rating.js") | $raw %]
<script>
var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %]0[% END %];
var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) | html %]";
var results_per_page = [% OPACnumSearchResults | html %];
function fetch_availability( prod, $tr ) {
var $availability_summary = $( '<span class="results_summary availability"></span>' );
$tr.find( '.mediatype' ).after( $availability_summary );
$availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
KOHA.OverDrive.Get(
prod.links.availability.href,
{},
function ( data ) {
if ( data.error ) return;
$availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + '<span class="available"><b>' + _("Items available:") + ' </b>' + data.copiesAvailable + " " + _("out of") + ' ' + data.copiesOwned + '</span>' );
if ( data.numberOfHolds ) {
$availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
}
$tr.find( '.info' ).each(function() {
KOHA.OverDriveCirculation.add_actions(this, data.id, data.copiesAvailable);
});
}
);
}
function search( offset ) {
$( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
KOHA.OverDrive.Search( "[% OverDriveLibraryID | html %]", querystring, results_per_page, offset, function( data ) {
if ( data.error ) {
$( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
return;
}
if ( !data.totalItems ) {
$( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
return;
}
$( '#overdrive-results-list tbody' ).empty();
$( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
for ( var i = 0; data.products[i]; i++ ) {
var prod = data.products[i];
var results = [];
results.push( '<tr>' );
results.push( '<td class="info"><a class="title" href="', prod.contentDetails[0].href, '">' );
results.push( prod.title );
if ( prod.subtitle ) results.push( ', ', prod.subtitle );
results.push( '</a>' );
results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
if ( prod.starRating ) {
results.push( '<div class="results_summary ratings">' );
for ( var rating = 1; rating <= 5; rating++ ) {
results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' );
}
results.push( '</div>' );
}
results.push( '</td>' );
results.push( '<td>' );
if ( prod.images.thumbnail ) {
results.push( '<a href="', prod.contentDetails[0].href, '">' );
results.push( '<img class="thumbnail" src="', prod.images.thumbnail.href, '" />' );
results.push( '</a>' );
}
results.push( '</td>' );
results.push( '</tr>' );
var $tr = $( results.join( '' ));
$( '#overdrive-results-list tbody' ).append( $tr );
fetch_availability( prod, $tr );
}
$( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
var pages = [];
var cur_page = offset / results_per_page;
var max_page = Math.floor( data.totalItems / results_per_page );
if ( cur_page != 0 ) {
pages.push( '<li><a class="od-nav" href="#" data-offset="' + (offset - results_per_page) + '">&laquo; ' + _("Previous") + '</a></li>' );
}
for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
if ( page == cur_page ) {
pages.push( ' <li class="active"><a href="#">' + ( page + 1 ) + '</a></li>' );
} else {
pages.push( ' <li><a class="od-nav" href="#" data-offset="' + ( page * results_per_page ) + '">' + ( page + 1 ) + '</a></li>' );
}
}
if ( cur_page < max_page ) {
pages.push( ' <li><a class="od-nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' &raquo;</a></li>' );
}
if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
$( '#overdrive-results-list input.star' ).rating();
} );
}
$( document ).ready( function() {
$( '#breadcrumbs p' )
.append( ' ' )
.append( '<span id="overdrive-status"></span>' );
$( document ).on( 'click', 'a.od-nav', function() {
search( $( this ).data( 'offset' ) );
return false;
});
[% IF ( overdrive_error ) %]
KOHA.OverDriveCirculation.display_error("#breadcrumbs", "[% overdrive_error.dquote | html %]");
[% END %]
[% IF ( loggedinusername and Koha.Preference('OverDriveCirculation') ) %]
KOHA.OverDriveCirculation.with_account_details("#breadcrumbs", function() {
search( 0 );
});
[% ELSE %]
search( 0 );
[% END %]
} );
</script>
[% END %]