From 3bd7c7e41404585b925915afbd2abd67bf4300bf Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Fri, 27 May 2011 13:51:59 -0400 Subject: [PATCH] Fix rendering of MFHD records when ownership is out of scope Dojo would die with a null reference error when an MFHD record was retrieved that was outside of the current OU search scope. For example, if a given bib record had one linked MFHD record for BR1, and one linked MFHD record for BR4, the details page would choke trying to draw the MFHD holdings in a scope that only included BR1 and end up drawing nothing. Ungood. Moving the ownership check and invoking _holdingsDrawMFHD() only after ensuring that the record is within our scope resolves the problem. Signed-off-by: Dan Scott --- Open-ILS/web/opac/skin/default/js/rdetail.js | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index c74c385456..2e92d0e4f6 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -351,28 +351,28 @@ function loadMarcEditor(recId) { * Limited brain power means that I'm brute-forcing it for now */ function _holdingsDraw(h) { - holdings = h.getResultObject(); - if (!holdings) { return null; } - - dojo.forEach(holdings, _holdingsDrawMFHD); - - // Populate XUL menus - if (isXUL()) { - runEvt('rdetail','MFHDDrawn'); - } -} - -function _holdingsDrawMFHD(holdings, entryNum) { + holdings = h.getResultObject(); + if (!holdings) { return null; } + // Only draw holdings within our OU scope + dojo.forEach(holdings, function (item) { var here = findOrgUnit(getLocation()); if (getDepth() > 0 || getDepth === 0 ) { - while (getDepth() < findOrgDepth(here)) - here = findOrgUnit( here.parent_ou() ); - if (!orgIsMine(findOrgUnit(here), findOrgUnit(holdings.owning_lib()))) { - return null; - } + while (getDepth() < findOrgDepth(here)) + here = findOrgUnit( here.parent_ou() ); + if (orgIsMine(findOrgUnit(here), findOrgUnit(item.owning_lib()))) { + _holdingsDrawMFHD(item); + } } + }); + // Populate XUL menus + if (isXUL()) { + runEvt('rdetail','MFHDDrawn'); + } +} + +function _holdingsDrawMFHD(holdings, entryNum) { var hb = holdings.basic_holdings(); var hba = holdings.basic_holdings_add(); var hs = holdings.supplement_holdings(); -- 2.43.2