Bug 21257: (bug 13618 follow-up) Handle undef values in JS before escapeHtml call
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 24 Aug 2018 19:22:20 +0000 (16:22 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Sun, 16 Sep 2018 04:21:32 +0000 (04:21 +0000)
To test:
1 - Find an item with no collection or location defined
2 - Check it out to a patron
3 - Note you cannot view the checkouts table
4 - Check the console: TypeError: oObj.collection is null
5 - Apply patch
6 - Restart all the things
7 - Checkouts table should load

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
koha-tmpl/intranet-tmpl/prog/js/checkouts.js

index 2525f56..b964a9c 100644 (file)
@@ -297,12 +297,12 @@ $(document).ready(function() {
                 },
                 {
                     "mDataProp": function ( oObj ) {
-                        return oObj.collection.escapeHtml();
+                        return ( oObj.collection ? oObj.collection.escapeHtml() : '' );
                     }
                 },
                 {
                     "mDataProp": function ( oObj ) {
-                        return oObj.location.escapeHtml();
+                        return ( oObj.location ? oObj.location.escapeHtml() : '' );
                     }
                 },
                 {
@@ -318,7 +318,7 @@ $(document).ready(function() {
                 },
                 {
                     "mDataProp": function ( oObj ) {
-                        return oObj.itemcallnumber.escapeHtml();
+                        return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' );
                     }
                 },
                 {
@@ -638,12 +638,12 @@ $(document).ready(function() {
                     },
                     {
                         "mDataProp": function ( oObj ) {
-                            return oObj.collection.escapeHtml();
+                            return ( oObj.collection ? oObj.collection.escapeHtml() : '' );
                         }
                     },
                     {
                         "mDataProp": function ( oObj ) {
-                            return oObj.location.escapeHtml();
+                            return ( oObj.location ? oObj.location.escapeHtml() : '' );
                         }
                     },
                     { "mDataProp": "issuedate_formatted" },
@@ -654,7 +654,7 @@ $(document).ready(function() {
                     },
                     {
                         "mDataProp": function ( oObj ) {
-                            return oObj.itemcallnumber.escapeHtml();
+                            return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' );
                         }
                     },
                     {