Bug 17602: fix RecordedBooks results pagination
authorSrdjan <srdjan@catalyst.net.nz>
Mon, 27 Nov 2017 04:38:02 +0000 (17:38 +1300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 1 Oct 2018 13:56:57 +0000 (13:56 +0000)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recordedbooks-search.tt
koha-tmpl/opac-tmpl/bootstrap/js/recordedbooks.js

index d34c5db..12188f8 100644 (file)
@@ -121,6 +121,29 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
     var MSG_CONFIRM_AGAIN = _("Warning: Cannot be undone. Please confirm once again")
     var MSG_DELETE_SEARCH_HISTORY = _("Are you sure you want to delete your search history?");
     var MSG_NO_SUGGESTION_SELECTED = _("No suggestion was selected");
+    var MSG_SEARCHING = _("Searching %s...");
+    var MSG_ERROR_SEARCHING_COLLECTION = _("Error searching %s collection");
+    var MSG_NO_RESULTS_FOUND_IN_COLLECTION = _("No results found in the library's %s collection");
+    var MSG_RESULTS_FOUND_IN_COLLECTION = _("Found %s results in the library's %s collection");
+    var MSG_BY = _("by");
+    var MSG_TYPE = _("Type");
+    var MSG_NEXT = _("Next");
+    var MSG_PREVIOUS = _("Previous");
+    var MSG_CHECKOUTS = _("Checkouts");
+    var MSG_NO_CHECKOUTS = _("No checkouts");
+    var MSG_CHECK_OUT = _("Check out");
+    var MSG_CHECK_OUT_CONFIRM = _("Are you sure you want to checkout this item?");
+    var MSG_CHECKED_OUT_UNTIL = _("Checked out until %s");
+    var MSG_CHECK_IN = _("Check in");
+    var MSG_CHECK_IN_CONFIRM = _("Are you sure you want to return this item?");
+    var MSG_NO_CHECKOUTS = _("No checkouts");
+    var MSG_DOWNLOAD = _("Download");
+    var MSG_HOLDS = _("Holds");
+    var MSG_NO_HOLDS = _("No holds");
+    var MSG_PLACE_HOLD = _("Place hold");
+    var MSG_CANCEL_HOLD = _("Cancel");
+    var MSG_CANCEL_HOLD_CONFIRM = _("Are you sure you want to cancel this hold?");
+    var MSG_ON_HOLD = _("On hold");
     [% IF Koha.Preference( 'opacbookbag' ) == 1 or Koha.Preference( 'virtualshelves' ) == 1 %]
         var MSG_BASKET_EMPTY = _("Your cart is currently empty");
         var MSG_RECORD_IN_BASKET = _("The item is already in your cart");
index b90f6ac..07c9f05 100644 (file)
@@ -66,22 +66,22 @@ var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace(
 var results_per_page = [% OPACnumSearchResults || 20 %];
 
 function search( page ) {
-    $( '#recordedbooks-status' ).html( _("Searching RecordedBooks...") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
+    $( '#recordedbooks-status' ).html( MSG_SEARCHING.format("RecordedBooks") + ' <img class="throbber" src="[% interface %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
 
     KOHA.RecordedBooks.search( querystring, results_per_page, page, function( data ) {
         if ( data.error ) {
-            $( '#recordedbooks-status' ).html( '<strong class="unavailable">' + _("Error searching RecordedBooks collection") + ': ' + data.error + '</strong>' );
+            $( '#recordedbooks-status' ).html( '<strong class="unavailable">' + MSG_ERROR_SEARCHING_COLLECTION.format("RecordedBooks") + ': ' + data.error + '</strong>' );
             return;
         }
 
         if ( !data.total ) {
-            $( '#recordedbooks-status' ).html( '<strong>' + _("No results found in the library's RecordedBooks collection.") + '</strong>' );
+            $( '#recordedbooks-status' ).html( '<strong>' + MSG_NO_RESULTS_FOUND_IN_COLLECTION.format("RecordedBooks") + '</strong>' );
             return;
         }
 
         $( '#recordedbooks-results-list tbody' ).empty();
 
-        $( '#recordedbooks-status' ).html( '<strong>' + _("Found") + ' ' + data.total + ' ' + _("results in the library's RecordedBooks collection.") + '</strong>' );
+        $( '#recordedbooks-status' ).html( '<strong>' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, "RecordedBooks") + '</strong>' );
 
         for ( var i = 0; data.items[i]; i++ ) {
             var prod = data.items[i];
@@ -94,9 +94,9 @@ function search( page ) {
             results.push( prod.title );
             if (prod.url) results.push( '</a>' );
             results.push( '</span>' );
-            results.push( '<p>' + _("by") + ' ', prod.author, '</p>' );
+            results.push( '<p>' + MSG_BY + ' ', prod.author, '</p>' );
             if (prod.description) results.push( '<p>' + prod.description, '</p>' );
-            results.push( '<span class="results_summary mediatype"><span class="label">' + _("Type:") + ' </span>', prod.media, '</span>' );
+            results.push( '<span class="results_summary mediatype"><span class="label">' + MSG_TYPE + ': </span>', prod.media, '</span>' );
 
             results.push( '</td>' );
 
@@ -125,7 +125,7 @@ function search( page ) {
         if (data.total == page*results_per_page) max_page++;
 
         if ( page != 1 ) {
-            pages.push( '<li><a class="od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + _("Previous") + '</a></li>' );
+            pages.push( '<li><a class="od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + MSG_PREVIOUS + '</a></li>' );
         }
 
         for ( var p = Math.max( 0, page - 9 ); p <= Math.min( max_page, p + 9 ); p++ ) {
@@ -137,7 +137,7 @@ function search( page ) {
         }
 
         if ( page < max_page ) {
-            pages.push( ' <li><a class="od-nav" href="#" data-page="' + (page + 1) + '">' + _("Next") + ' &raquo;</a></li>' );
+            pages.push( ' <li><a class="od-nav" href="#" data-page="' + (page + 1) + '">' + MSG_NEXT + ' &raquo;</a></li>' );
         }
 
         if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>');
index 5df3f3a..b0aeccb 100644 (file)
@@ -27,11 +27,11 @@ KOHA.RecordedBooks = new function() {
         }
 
         if (data.checkouts) {
-            var checkouts_div = $('<div class="recordedbooks-div">').html('<h3>' + _("Checkouts") + '</h3>');
+            var checkouts_div = $('<div class="recordedbooks-div">').html('<h3>' + MSG_CHECKOUTS + '</h3>');
             var items = data.checkouts.items;
             var checkouts_list;
             if (items.length == 0) {
-                checkouts_list = _("No checkouts");
+                checkouts_list = MSG_NO_CHECKOUTS;
             } else {
                 checkouts_list = $('<ul class="recordedbooks-list">');
                 data.checkouts.items.forEach(function(item) {
@@ -43,11 +43,11 @@ KOHA.RecordedBooks = new function() {
         }
 
         if (data.holds) {
-            var holds_div = $('<div class="recordedbooks-div">').html('<h3>' + _("Holds") + '</h3>');
+            var holds_div = $('<div class="recordedbooks-div">').html('<h3>' + MSG_HOLDS + '</h3>');
             var items = data.holds.items;
             var holds_list;
             if (items.length == 0) {
-                holds_list = _("No holds");
+                holds_list = MSG_NO_HOLDS;
             } else {
                 holds_list = $('<ul class="recordedbooks-list">');
                 data.holds.items.forEach(function(item) {
@@ -203,18 +203,18 @@ KOHA.RecordedBooks = new function() {
             if (item) {
                 var expires = new Date(item.expires);
                 $('<span class="recordedbooks-item-status">')
-                    .text(_("Checked out until") + " " + expires.toLocaleString())
+                    .text(MSG_CHECKED_OUT_UNTIL.format(expires.toLocaleString()))
                     .appendTo(el);
                 $(el).append(" ");
 
                 if (item.url) {
                     var download = $('<a href="'+item.url+'">').appendTo(el);
-                    decorate_button(download, _("Download"));
+                    decorate_button(download, MSG_DOWNLOAD);
                     $(el).append(" ");
                 }
 
-                $(el).append( ajax_button(_("Check in"), function() {
-                    if( confirm(_("Are you sure you want to return this item?")) ) {
+                $(el).append( ajax_button(MSG_CHECK_IN, function() {
+                    if( confirm(MSG_CHECK_IN_CONFIRM) ) {
                         item_action({action: "return", isbn: isbn}, el);
                     }
                 }) );
@@ -225,14 +225,14 @@ KOHA.RecordedBooks = new function() {
             item = item_is_on_hold(isbn);
             if (item) {
                 $('<span class="recordedbooks-status">')
-                    .text(_("On hold"))
+                    .text(MSG_ON_HOLD)
                     .appendTo(el);
                 $(el).append(" ");
             }
 
             if(checkout_popup) {
-                $(el).append( ajax_button(_("Check out"), function() {
-                    if( confirm(_("Are you sure you want to checkout this item?")) ) {
+                $(el).append( ajax_button(MSG_CHECK_OUT, function() {
+                    if( confirm(MSG_CHECK_OUT_CONFIRM) ) {
                         svc_ajax('post', {action: "checkout", isbn: isbn}, function(data) {
                             if (data.checkouts) {
                                 details.checkouts = data.checkouts;
@@ -246,14 +246,14 @@ KOHA.RecordedBooks = new function() {
                 }) );
             }
             if (!item) {
-                $(el).append( ajax_button(_("Place hold"), function() {
+                $(el).append( ajax_button(MSG_PLACE_HOLD, function() {
                     item_action({action: "place_hold", isbn: isbn}, el);
                 }) );
             }
 
             if (item) {
-                $(el).append( ajax_button(_("Cancel"), function() {
-                    if( confirm(_("Are you sure you want to cancel this hold?")) ) {
+                $(el).append( ajax_button(MSG_CANCEL_HOLD, function() {
+                    if( confirm(MSG_CANCEL_HOLD_CONFIRM) ) {
                         item_action({action: "remove_hold", isbn: isbn}, el);
                     }
                 }) );