dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22370
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10732: Made orgunit webtree loading a bit more robust against funny org unit names
------------------------------------------------------------
revno: 10732
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-05-02 10:49:27 +0200
message:
Made orgunit webtree loading a bit more robust against funny org unit names
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2012-09-03 19:48:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2013-05-02 08:49:27 +0000
@@ -212,9 +212,12 @@
for ( var i = 0; i < unitElements.length; ++i )
{
- var unitTag = createTreeElementTag( unitElements[i] );
+ if ( unitIsValid( unitElements[i] ) )
+ {
+ var unitTag = createTreeElementTag( unitElements[i] );
- rootsTag.appendChild( unitTag );
+ rootsTag.appendChild( unitTag );
+ }
}
treeTag.appendChild( rootsTag );
@@ -225,7 +228,7 @@
for ( var i = 0, parentElement; ( parentElement = parentElements[i] ); ++i )
{
var parentId = parentElement.getAttribute( 'parentId' );
- var parentTag = document.getElementById( getTagId( parentId ));
+ var parentTag = document.getElementById( getTagId( parentId ) );
createChildren( parentTag, parentElement );
}
@@ -242,9 +245,12 @@
for ( var i = 0, child; ( child = children[i] ); ++i )
{
- var childTag = createTreeElementTag( child );
+ if ( unitIsValid( child ) )
+ {
+ var childTag = createTreeElementTag( child );
- childrenTag.appendChild( childTag );
+ childrenTag.appendChild( childTag );
+ }
}
setVisible( childrenTag, true );
@@ -374,4 +380,17 @@
{
treeTag.style.backgroundImage = 'none';
}
+
+ function unitIsValid( unit )
+ {
+ if ( isDefined( unit ) && unit && unit.firstChild )
+ {
+ return true;
+ }
+
+ log( 'Illegal organisation unit' );
+ log( unit );
+
+ return false;
+ }
}