RT26522: Don't treat non-available items as a special case
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Mon, 8 Dec 2014 18:36:35 +0000 (10:36 -0800)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 12 Dec 2014 23:03:10 +0000 (15:03 -0800)
Previously, when the 'available' element of a Library Availability API
response was undefined, we assumed that the title itself was no longer
part of the library's current Overdrive collection.  Thus, the Place
Hold link was removed and a "No longer available" message was displayed
in the Status column.  In fact, however, it may just be the case that
the item is currently in the collection, but all copies are checked out.
So it's preferable to retain the Place Hold link and show "0 of X
available" in the Status column -- in other words, don't treat undefined
availability as a special case.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
src/od_pages_opac.coffee

index e8d5105..ebd47cb 100644 (file)
@@ -101,19 +101,13 @@ define [
 
                        return @ unless avail
 
 
                        return @ unless avail
 
-                       $x =
-                               if avail.available is undefined
-                                       $('<span>')
-                                               .css 'color', 'red'
-                                               .text 'No longer available'
-                               else
-                                       tpl = _.template """
-                                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
-                                       """
-                                       $ tpl
-                                               n_avail: avail.copiesAvailable
-                                               n_owned: avail.copiesOwned
-                                               n_holds:  avail.numberOfHolds
+                       tpl = _.template """
+                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
+                       """
+                       $x = $ tpl
+                               n_avail: avail.copiesAvailable
+                               n_owned: avail.copiesOwned
+                               n_holds:  avail.numberOfHolds
 
                        @find('.result_holdings_table .status')
                                .append $x
 
                        @find('.result_holdings_table .status')
                                .append $x
@@ -162,19 +156,13 @@ define [
 
                        return @ unless avail
 
 
                        return @ unless avail
 
-                       $x =
-                               if avail.available is undefined
-                                       $('<span>')
-                                               .css 'color', 'red'
-                                               .text 'No longer available'
-                               else
-                                       tpl = _.template """
-                                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
-                                       """
-                                       $ tpl
-                                               n_avail: avail.copiesAvailable
-                                               n_owned: avail.copiesOwned
-                                               n_holds: avail.numberOfHolds
+                       tpl = _.template """
+                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
+                       """
+                       $x = $ tpl
+                               n_avail: avail.copiesAvailable
+                               n_owned: avail.copiesOwned
+                               n_holds:  avail.numberOfHolds
 
                        @find '.status'
                                .append $x
 
                        @find '.status'
                                .append $x
@@ -185,11 +173,6 @@ define [
                _replace_place_hold_link: (avail, type_of_interest) ->
                        return @ unless avail
                        
                _replace_place_hold_link: (avail, type_of_interest) ->
                        return @ unless avail
                        
-                       if avail.available is undefined
-                               @find '.place_hold'
-                                       .remove()
-                                       .end()
-
                        # Find the place hold link that we want to replace
                        $a = @find '.place_hold > a'
 
                        # Find the place hold link that we want to replace
                        $a = @find '.place_hold > a'