=== 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-08-10 10:56:58 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-08-10 13:35:47 +0000 @@ -329,29 +329,41 @@ { var name = $( '#searchField' ).val() - $.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code=' + encodeURI( name ), function( - data ) - { - if ( data.response == "success" ) - { - var unitId = data.message; - - $( '#orgUnitTreeContainer' ).load( organisationUnitTreePath + 'loadOrganisationUnitTree.action', - function() - { - if ( !listenerFunction ) - { - return false; - } - - listenerFunction( [ unitId ] ); - } ); + var match; + + for ( var ou in localStorage ) + { + if ( ou.indexOf( "orgUnit" ) != -1 ) + { + var value = localStorage[ou]; + + if ( value.indexOf( "\"" + name + "\"" ) != -1 ) + { + match = JSON.parse( value ); + } + } + } + + if ( match !== undefined ) + { + $( '#searchField' ).css( 'background-color', '#ffffff' ); + + if ( multipleSelectionAllowed ) + { + sessionStorage[getTagId( "Selected" )] = [ match.id ]; } else { - $( '#searchField' ).css( 'background-color', '#ffc5c5' ); + sessionStorage[getTagId( "Selected" )] = match.id; } - } ); + + selection.sync(); + subtree.reloadTree(); + } + else + { + $( '#searchField' ).css( 'background-color', '#ffc5c5' ); + } } }