From: Bill Erickson Date: Tue, 4 Sep 2012 18:43:27 +0000 (-0400) Subject: Gracefully handle reporter class with no labels X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=37b7f30ea722a68890593590f995bf80143492ec;p=evergreen%2Fpines.git 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 --- diff --git a/Open-ILS/web/reports/xul/source-setup.js b/Open-ILS/web/reports/xul/source-setup.js index 245657bc53..d3b919c515 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; }