← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4157: minor changes to ouwt

 

------------------------------------------------------------
revno: 4157
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-07-18 12:46:40 +0200
message:
  minor changes to ouwt
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseCollapse.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseExpand.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseTree.vm


--
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/ouwt/orgunittreesearch.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm	2011-03-24 14:01:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm	2011-07-18 10:46:40 +0000
@@ -18,4 +18,4 @@
 
 <div id="orgUnitTreeContainer">
 #parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
-</div>
\ No newline at end of file
+</div>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-01-25 09:45:14 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2011-07-18 10:46:40 +0000
@@ -1,8 +1,5 @@
-
 // -----------------------------------------------------------------------------
 // Author:   Torgeir Lorange Ostby
-// Version:  $Id: ouwt.js 3457 2007-07-11 12:34:24Z torgeilo $
-// Version:  $Id: ouwt.js 3457 2007-07-11 12:34:24Z torgeilo $
 // -----------------------------------------------------------------------------
 
 /*
@@ -40,48 +37,49 @@
     {
         multipleSelectionAllowed = allowed;
     };
-    
+
     this.setUnselectAllowed = function( allowed )
     {
-    	unselectAllowed = allowed;
+        unselectAllowed = allowed;
     }
 
     this.select = function( unitId )
     {
-        var unitTag = document.getElementById( getTagId( unitId ));
-		
-		var linkTags = unitTag.getElementsByTagName( 'a' );
+        var unitTag = document.getElementById( getTagId( unitId ) );
+
+        var linkTags = unitTag.getElementsByTagName( 'a' );
 
         if ( linkTags[0].className == 'selected' && unselectAllowed )
         {
-			$.post(organisationUnitTreePath + "removeorgunit.action",{
-				id:unitId
-			}, function (data){
-				responseReceived(data.firstChild);
-			},'xml');
-			
+            $.post( organisationUnitTreePath + "removeorgunit.action", {
+                id : unitId
+            }, function( data )
+            {
+                responseReceived( data.firstChild );
+            }, 'xml' );
+
             linkTags[0].className = '';
-        }
-        else
+        } else
         {
             if ( multipleSelectionAllowed )
             {
-				$.post(organisationUnitTreePath + "addorgunit.action",{
-					id:unitId
-				}, function (data){
-					responseReceived(data.firstChild);
-				},'xml');
-				
+                $.post( organisationUnitTreePath + "addorgunit.action", {
+                    id : unitId
+                }, function( data )
+                {
+                    responseReceived( data.firstChild );
+                }, 'xml' );
+
                 linkTags[0].className = 'selected';
-            }
-            else
+            } else
             {
-				$.post(organisationUnitTreePath + "setorgunit.action",{
-					id:unitId
-				}, function (data){
-					responseReceived(data.firstChild);
-				},'xml');	
-				
+                $.post( organisationUnitTreePath + "setorgunit.action", {
+                    id : unitId
+                }, function( data )
+                {
+                    responseReceived( data.firstChild );
+                }, 'xml' );
+
                 // Remove all select marks
                 var treeTag = document.getElementById( 'orgUnitTree' );
                 var linkTags = treeTag.getElementsByTagName( 'a' );
@@ -92,7 +90,7 @@
                 }
 
                 // Set new select mark
-                var unitTag = document.getElementById( getTagId( unitId ));
+                var unitTag = document.getElementById( getTagId( unitId ) );
                 linkTags = unitTag.getElementsByTagName( 'a' );
                 linkTags[0].className = 'selected';
             }
@@ -107,13 +105,13 @@
         }
 
         var unitIds = new Array();
-        
+
         var unitIdElements = rootElement.getElementsByTagName( 'unitId' );
         for ( var i = 0, unitIdElement; ( unitIdElement = unitIdElements[i] ); ++i )
         {
             unitIds[i] = unitIdElement.firstChild.nodeValue;
         }
-        
+
         listenerFunction( unitIds );
     }
 
@@ -121,25 +119,32 @@
     {
         return 'orgUnit' + unitId;
     }
-    
-	this.findByCode = function()
-	{
-		$.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code=' + encodeURI( $( '#searchField' ).val() ), function ( data ) {
-			var unitId = data.message;
-			if ( data.response == "success" ) {
-				$( '#orgUnitTreeContainer' ).load( organisationUnitTreePath + 'loadOrganisationUnitTree.action', function() {					
-					
-					if ( !listenerFunction ) {
-						return false;
-					}					
-					var unitIds = [unitId];					
-					listenerFunction( unitIds ); 
-				} );			
-			} else {
-				$( '#searchField' ).css( 'background-color', '#ffc5c5' );
-			}
-		} );
-	}
+
+    this.findByCode = function()
+    {
+        $.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code='
+                + encodeURI( $( '#searchField' ).val() ), function( data )
+        {
+            var unitId = data.message;
+            if ( data.response == "success" )
+            {
+                $( '#orgUnitTreeContainer' ).load( organisationUnitTreePath + 'loadOrganisationUnitTree.action',
+                        function()
+                        {
+
+                            if ( !listenerFunction )
+                            {
+                                return false;
+                            }
+                            var unitIds = [ unitId ];
+                            listenerFunction( unitIds );
+                        } );
+            } else
+            {
+                $( '#searchField' ).css( 'background-color', '#ffc5c5' );
+            }
+        } );
+    }
 }
 
 // -----------------------------------------------------------------------------
@@ -150,18 +155,17 @@
 {
     this.toggle = function( unitId )
     {
-        var parentTag = document.getElementById( getTagId( unitId ));
+        var parentTag = document.getElementById( getTagId( unitId ) );
         var children = parentTag.getElementsByTagName( 'ul' );
 
         var request = new Request();
         request.setResponseTypeXML( 'units' );
 
-        if ( children.length < 1 || !isVisible( children[0] ))
+        if ( children.length < 1 || !isVisible( children[0] ) )
         {
             request.setCallbackSuccess( processExpand );
             request.send( organisationUnitTreePath + 'expandSubtree.action?parentId=' + unitId );
-        }
-        else
+        } else
         {
             request.setCallbackSuccess( processCollapse );
             request.send( organisationUnitTreePath + 'collapseSubtree.action?parentId=' + unitId );
@@ -184,18 +188,18 @@
     function processCollapse( rootElement )
     {
         var unitElements = rootElement.getElementsByTagName( 'unit' );
-        
+
         for ( var i = 0, unitElement; ( unitElement = unitElements[i] ); ++i )
         {
             var parentId = unitElement.firstChild.nodeValue;
-            var parentTag = document.getElementById( getTagId( parentId ));
+            var parentTag = document.getElementById( getTagId( parentId ) );
             var children = parentTag.getElementsByTagName( 'ul' );
-            
+
             setVisible( children[0], false );
             setToggle( parentTag, false );
         }
     }
-    
+
     function processExpand( rootElement )
     {
         var parentElements = rootElement.getElementsByTagName( 'parent' );
@@ -203,14 +207,13 @@
         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 ) );
             var children = parentTag.getElementsByTagName( 'ul' );
 
             if ( children.length < 1 )
             {
                 createChildren( parentTag, parentElement );
-            }
-            else
+            } else
             {
                 setVisible( children[0], true );
                 setToggle( parentTag, true );
@@ -222,14 +225,14 @@
     {
         var rootsElement = rootElement.getElementsByTagName( 'roots' )[0];
         var unitElements = rootsElement.getElementsByTagName( 'unit' );
-        
+
         var treeTag = document.getElementById( 'orgUnitTree' );
         var rootsTag = document.createElement( 'ul' );
 
         for ( var i = 0; i < unitElements.length; ++i )
         {
             var unitTag = createTreeElementTag( unitElements[i] );
-            
+
             rootsTag.appendChild( unitTag );
         }
 
@@ -241,7 +244,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 );
         }
@@ -277,15 +280,14 @@
         {
             toggleTag.onclick = new Function( 'subtree.toggle( ' + childId + ' )' );
             toggleTag.appendChild( getToggleExpand() );
-        }
-        else
+        } else
         {
             toggleTag.appendChild( getToggleBlank() );
         }
 
         var linkTag = document.createElement( 'a' );
         linkTag.href = 'javascript:void selection.select( ' + childId + ' )';
-        linkTag.appendChild( document.createTextNode( child.firstChild.nodeValue ));
+        linkTag.appendChild( document.createTextNode( child.firstChild.nodeValue ) );
 
         if ( child.getAttribute( 'selected' ) == 'true' )
         {
@@ -294,11 +296,11 @@
 
         var childTag = document.createElement( 'li' );
         childTag.id = getTagId( childId );
-        childTag.appendChild( document.createTextNode( ' ' ));
+        childTag.appendChild( document.createTextNode( ' ' ) );
         childTag.appendChild( toggleTag );
-        childTag.appendChild( document.createTextNode( ' ' ));
+        childTag.appendChild( document.createTextNode( ' ' ) );
         childTag.appendChild( linkTag );
-        
+
         return childTag;
     }
 
@@ -310,12 +312,11 @@
 
         if ( toggleTag.firstChild )
         {
-        	toggleTag.replaceChild( toggleImg, toggleTag.firstChild );
-		}
-		else
-		{
-			toggleTag.appendChild( toggleImg );
-		}
+            toggleTag.replaceChild( toggleImg, toggleTag.firstChild );
+        } else
+        {
+            toggleTag.appendChild( toggleImg );
+        }
     }
 
     function setVisible( tag, visible )
@@ -332,7 +333,7 @@
     {
         return 'orgUnit' + unitId;
     }
-    
+
     function getToggleExpand()
     {
         var imgTag = getToggleImage();
@@ -340,27 +341,27 @@
         imgTag.alt = '[+]';
         return imgTag;
     }
-    
+
     function getToggleCollapse()
     {
         var imgTag = getToggleImage();
         imgTag.src = '../images/expand.png';
-		imgTag.width = '9';
+        imgTag.width = '9';
         imgTag.height = '9';
         imgTag.alt = '[-]';
         return imgTag;
     }
 
-	function getToggleBlank()
-	{
-		var imgTag = getToggleImage();
-		imgTag.src = '../images/transparent.gif';
-		imgTag.width = '9';
+    function getToggleBlank()
+    {
+        var imgTag = getToggleImage();
+        imgTag.src = '../images/transparent.gif';
+        imgTag.width = '9';
         imgTag.height = '9';
-		imgTag.alt = '';
-		return imgTag;
-	}
-    
+        imgTag.alt = '';
+        return imgTag;
+    }
+
     function getToggleImage()
     {
         var imgTag = document.createElement( 'img' );

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseCollapse.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseCollapse.vm	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseCollapse.vm	2011-07-18 10:46:40 +0000
@@ -1,5 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <units>
 #foreach( $unit in $collapsedUnits )
 	<unit>$unit.id</unit>
 #end
-</units>
\ No newline at end of file
+</units>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseExpand.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseExpand.vm	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseExpand.vm	2011-07-18 10:46:40 +0000
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <units>
 #foreach( $parent in $parents )
 	<parent parentId="$parent.id">
@@ -6,4 +7,4 @@
   	#end
   	</parent>
 #end
-</units>
\ No newline at end of file
+</units>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseSelect.vm	2011-07-18 10:46:40 +0000
@@ -1,5 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <selected>
 #foreach( $unit in $selectedUnits )
 	<unitId>$unit.id</unitId>
 #end
-</selected>
\ No newline at end of file
+</selected>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseTree.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseTree.vm	2009-09-28 22:49:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/responseTree.vm	2011-07-18 10:46:40 +0000
@@ -1,10 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <units>
 	<roots>
 	#foreach( $root in $roots )
 		<unit id="$root.id" #if( $selected.contains( $root )) selected="true" #end>$encoder.xmlEncode( $root.name )</unit>
 	#end
-	
 	</roots>
+
 	<children>
 	#foreach( $parent in $parents )
 		<parent parentId="$parent.id">
@@ -14,4 +15,4 @@
   		</parent>
 	#end
 	</children>
-</units>
\ No newline at end of file
+</units>