From 37f72c53386253b77f5f7d25ad5a3e521cf4817d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 24 Aug 2018 16:22:20 -0300 Subject: [PATCH] Bug 21257: (bug 13618 follow-up) Handle undef values in JS before escapeHtml call 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 --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index b5edf4843f..b964a9cd8f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -297,7 +297,12 @@ $(document).ready(function() { }, { "mDataProp": function ( oObj ) { - return oObj.location.escapeHtml(); + return ( oObj.collection ? oObj.collection.escapeHtml() : '' ); + } + }, + { + "mDataProp": function ( oObj ) { + return ( oObj.location ? oObj.location.escapeHtml() : '' ); } }, { @@ -313,7 +318,7 @@ $(document).ready(function() { }, { "mDataProp": function ( oObj ) { - return oObj.itemcallnumber.escapeHtml(); + return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' ); } }, { @@ -633,7 +638,12 @@ $(document).ready(function() { }, { "mDataProp": function ( oObj ) { - return oObj.location.escapeHtml(); + return ( oObj.collection ? oObj.collection.escapeHtml() : '' ); + } + }, + { + "mDataProp": function ( oObj ) { + return ( oObj.location ? oObj.location.escapeHtml() : '' ); } }, { "mDataProp": "issuedate_formatted" }, @@ -644,7 +654,7 @@ $(document).ready(function() { }, { "mDataProp": function ( oObj ) { - return oObj.itemcallnumber.escapeHtml(); + return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' ); } }, { -- 2.11.0