← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2237: Improved find orgunit in tree function

 

------------------------------------------------------------
revno: 2237
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-30 09:54:17 +0100
message:
  Improved find orgunit in tree function
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/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitByCodeAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/menuWithTree.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	2010-11-29 13:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittreesearch.vm	2010-11-30 08:54:17 +0000
@@ -1,6 +1,6 @@
 
 <img id="searchIcon" src="../images/search.png" style="cursor: pointer" title="$i18n.getString( 'locate_organisation_unit_by_code_or_name' )">
-<span id="searchSpan" style="display:none"><input type="text" id="searchField" name="key" style="width:130px" onchange="getOrgunitByCode()"><input type="button" value="Find" onclick="getOrgunitByCode()"></span>
+<span id="searchSpan" style="display:none"><input type="text" id="searchField" name="key" style="width:130px"><input type="button" value="Find" onclick="selection.findByCode()"></span>
 
 <script>
 	

=== 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	2010-11-29 13:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2010-11-30 08:54:17 +0000
@@ -115,6 +115,25 @@
     {
         return 'orgUnit' + unitId;
     }
+    
+	this.findByCode = function()
+	{
+		$.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code=' + $.URLEncode( $( '#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' );
+			}
+		} );
+	}
 }
 
 // -----------------------------------------------------------------------------
@@ -344,14 +363,3 @@
         return imgTag;
     }
 }
-
-function getOrgunitByCode(code)
-{
-	$.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code=' + $.URLEncode( $( '#searchField' ).val() ), function ( data ) {	
-		if ( data.response == "success" ) {
-			$( '#orgUnitTreeContainer' ).load( organisationUnitTreePath + 'loadOrganisationUnitTree.action' );
-		} else {
-			$( '#searchField' ).css( 'background-color', '#ffc5c5' );
-		}
-	} );
-}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitByCodeAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitByCodeAction.java	2010-11-29 13:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetOrganisationUnitByCodeAction.java	2010-11-30 08:54:17 +0000
@@ -72,9 +72,9 @@
         this.code = code;
     }
 
-    private Integer message;
+    private String message;
 
-    public Integer getMessage()
+    public String getMessage()
     {
         return message;
     }
@@ -98,9 +98,11 @@
         
         if ( unit != null )
         {
+            log.debug( "Found organisation unit: " + unit );
+            
             selectionManager.setSelectedOrganisationUnit( unit );
             
-            message = unit.getId();
+            message = String.valueOf( unit.getId() );
             
             return SUCCESS;
         }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm	2010-11-29 13:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm	2010-11-30 08:54:17 +0000
@@ -1,2 +1,6 @@
 <br>
-#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
\ No newline at end of file
+#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
+
+<script>
+selection.setListenerFunction( organisationUnitSelected );
+</script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/menuWithTree.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/menuWithTree.vm	2010-11-29 13:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/menuWithTree.vm	2010-11-30 08:54:17 +0000
@@ -4,7 +4,5 @@
 #parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
 
 <script>
-
 selection.setListenerFunction( organisationUnitSelected );
-
 </script>