From eb4be268d8d66ae0b7ca803ecf270a688fc6aea1 Mon Sep 17 00:00:00 2001 From: Srdjan Date: Fri, 23 Sep 2016 18:13:10 +1200 Subject: [PATCH] Bug 17602: OPAC integration of RecordedBooks Add RecordedBooks to the users page in the public interface To Test: 1/ Apply all 3 patches 2/ Set the sysprefs to valid values (you will need a test account with RecordedBooks) 3/ Try a search 4/ Login to the OPAC, try to place a hold, or check an item out 5/ Check the opac-user page, see if your items are showing on the oneclickdigital tab Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- .../opac-tmpl/bootstrap/css/src/opac.scss | 1 + .../en/includes/recordedbooks-checkout.inc | 15 + .../en/modules/opac-recordedbooks-search.tt | 168 +++++++++ .../bootstrap/en/modules/opac-results.tt | 18 + .../bootstrap/en/modules/opac-user.tt | 24 ++ .../opac-tmpl/bootstrap/js/recordedbooks.js | 325 ++++++++++++++++++ opac/opac-recordedbooks-search.pl | 42 +++ opac/opac-search.pl | 9 +- opac/opac-user.pl | 1 + opac/svc/recordedbooks | 148 ++++++++ 10 files changed, 748 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/recordedbooks-checkout.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js create mode 100755 opac/opac-recordedbooks-search.pl create mode 100755 opac/svc/recordedbooks diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 30e1ca413a..c5075d5ba9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -2677,6 +2677,7 @@ button.closebtn { #overdrive-results, +#recordedbooks-results, #openlibrary-results { font-weight: bold; padding-left: 1em; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/recordedbooks-checkout.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/recordedbooks-checkout.inc new file mode 100644 index 0000000000..bebf3d48fa --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/recordedbooks-checkout.inc @@ -0,0 +1,15 @@ + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt new file mode 100644 index 0000000000..b90f6ac180 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt @@ -0,0 +1,168 @@ +[% USE Koha %] +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › RecordedBooks search for '[% q | html %]' +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %] + + +[% END %] + +[% INCLUDE 'bodytag.inc' bodyid='recordedbooks-results-page' bodyclass='scrollto' %] +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+
+ [% IF ( OpacNav || OpacNavBottom ) %] + [% INCLUDE 'navigation.inc' %] + [% END %] +
+
+
+

RecordedBooks search for '[% q | html %]'

+ + +
+ +
+ + + + +
+ +
+ +
+ +
+
+
+
+
+ +[% INCLUDE 'recordedbooks-checkout.inc' %] + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] + + + +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index b4a417fa0e..40fd499520 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -590,6 +590,7 @@ [% END %] [% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") | $raw %][% END %] [% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") | $raw %][% END %] +[% IF ( RecordedBooksEnabled ) %][% Asset.js("js/recordedbooks.js") | $raw %][% END %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] [% Asset.js("js/authtoresults.js") | $raw %] [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %] @@ -902,6 +903,23 @@ $(document).ready(function(){ } } ); [% END %] + [% IF ( RecordedBooksEnabled ) %] + var $recordedbooks_results = $( '
' + _( 'Searching RecordedBooks...' ) + '
' ); + $( '#numresults' ) .append( ' ' ) + .append( $recordedbooks_results ); + KOHA.RecordedBooks.search( querystring, [% OPACnumSearchResults || "null" %], null, function( data ) { + if ( data.error ) { + $recordedbooks_results.html( _( 'Error searching RecordedBooks collection' ) + ': ' + data.error); + return; + } + + if ( data.total > 0 ) { + $recordedbooks_results.html( _( 'Found' ) + ' ' + data.total + ' ' + _( 'results' ) + ' ' + _( 'in RecordedBooks collection' ) ); + } else { + $recordedbooks_results.remove(); + } + } ); + [% END %] [% IF ( OpenLibrarySearch ) %] var $openlibrary_results = $( '
' + _( 'Searching Open Library...' ) + '
' ); $( '#numresults' ) .append( ' ' ) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 17e950fb89..b69fb7599a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -163,10 +163,15 @@ [% IF ( OverDriveCirculation ) %]
  • OverDrive Account
  • [% END %] + [% IF ( RecordedBooksCirculation ) %] +
  • RecordedBooks Account
  • + [% END %]
    +
    +
    [% IF ( issues_count ) %]
    @@ -893,6 +898,9 @@ [% IF ( OverDriveCirculation ) %] [% INCLUDE 'overdrive-checkout.inc' %] [% END %] +[% IF ( RecordedBooksCirculation ) %] +[% INCLUDE 'recordedbooks-checkout.inc' %] +[% END %] [% INCLUDE 'opac-bottom.inc' %] @@ -1065,4 +1073,20 @@ }); [% END %] + [% IF RecordedBooksCirculation %] + + [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js b/koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js new file mode 100644 index 0000000000..5df3f3a2e9 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js @@ -0,0 +1,325 @@ +if ( typeof KOHA == "undefined" || !KOHA ) { + var KOHA = {}; +} + +KOHA.RecordedBooks = new function() { + var svc_url = '/cgi-bin/koha/svc/recordedbooks'; + + var error_div = $('
    '); + function display_error ( error ) { + error_div.text(error); + } + + var details = null; + + function is_identified() { + return details ? details.is_identified : false; + } + + var checkout_popup = null; + $( document ).ready(function() { + checkout_popup = $("#recordedbooks-checkout"); + }); + + function display_account (container, data) { + if (!data.is_identified) { + return; + } + + if (data.checkouts) { + var checkouts_div = $('
    ').html('

    ' + _("Checkouts") + '

    '); + var items = data.checkouts.items; + var checkouts_list; + if (items.length == 0) { + checkouts_list = _("No checkouts"); + } else { + checkouts_list = $('