From ad51dc50b0fc2829db25dd604fc8241a6bfd10ff Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 4 Sep 2012 14:43:27 -0400 Subject: [PATCH] Gracefully handle reporter class with no labels LP 1045964 -- unable to clone report template The template interface was failing while rendering the reporter sources drop-down when a reporter source (IDL class) had no label. This adds a sanity check around that. Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- Open-ILS/web/reports/xul/source-setup.js | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Open-ILS/web/reports/xul/source-setup.js b/Open-ILS/web/reports/xul/source-setup.js index 245657b..d3b919c 100644 --- a/Open-ILS/web/reports/xul/source-setup.js +++ b/Open-ILS/web/reports/xul/source-setup.js @@ -25,13 +25,21 @@ function sortNames (a,b) { } function sortLabels (a,b) { - var aname = a.getAttributeNS(rptNS, 'label').toLowerCase(); - if (!aname) aname = a.getAttribute('name'); - if (!aname) aname = a.getAttribute('id'); + var aname = a.getAttributeNS(rptNS, 'label'); - var bname = b.getAttributeNS(rptNS, 'label').toLowerCase(); - if (!bname) bname = b.getAttribute('name'); - if (!bname) bname = b.getAttribute('id'); + if (aname) { + aname = aname.toLowerCase(); + } else { + aname = a.getAttribute('name') || a.getAttribute('id'); + } + + var bname = b.getAttributeNS(rptNS, 'label'); + + if (bname) { + bname = bname.toLowerCase(); + } else { + bname = b.getAttribute('name') || b.getAttribute('id'); + } return aname < bname ? -1 : 1; } -- 1.7.2.5