LP#1673870: ebook checkout fails on error message, not on empty due date
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Mon, 14 Aug 2017 21:08:39 +0000 (14:08 -0700)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Mon, 14 Aug 2017 21:08:39 +0000 (14:08 -0700)
Previously, a successful ebook checkout would appear to fail if the
checkout response from the vendor API did not include a due date.  With
this commit, the checkout failure message is displayed only if Evergreen
returns an error message to the browser (i.e. the response object
contains an "error_msg" attribute).

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Open-ILS/web/js/ui/default/opac/ebook_api/loggedin.js

index 1eacdcd..f003b66 100644 (file)
@@ -257,7 +257,10 @@ function cleanupAfterAction() {
 // check out our active ebook
 function doCheckout() {
     active_ebook.checkout(authtoken, patron_id, function(resp) {
-        if (resp.due_date) {
+        if (resp.error_msg) {
+            console.log('Checkout failed: ' + resp.error_msg);
+            dojo.removeClass('ebook_checkout_failed', "hidden");
+        } else {
             console.log('Checkout succeeded!');
             dojo.destroy('checkout-button');
             dojo.destroy('checkout-format'); // remove optional format selector
@@ -283,9 +286,6 @@ function doCheckout() {
             }
             xacts.checkouts.unshift(new_xact);
             cleanupAfterAction();
-        } else {
-            console.log('Checkout failed: ' + resp.error_msg);
-            dojo.removeClass('ebook_checkout_failed', "hidden");
         }
         // When we switch to jQuery, we can use .one() instead of .on(),
         // obviating the need for an explicit disconnect here.