=== 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 2014-09-11 12:33:22 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2014-09-17 10:16:52 +0000 @@ -151,14 +151,14 @@ }; this.isSelected = function() { - var ou = selection.getSelected(); + var ou = selection.getSelected(); return ou && ou.length > 0; }; - + this.setSelected = function( selected ) { sessionStorage[ OU_SELECTED_KEY ] = JSON.stringify( selected ); }; - + this.selectedExists = function() { return sessionStorage[ OU_SELECTED_KEY ] != null; }; @@ -415,19 +415,21 @@ var selected = selection.getSelected(); if( multipleSelectionAllowed ) { - var def = $.Deferred(); - var p = def.promise(); + var q = ''; $.each( selected, function( i, item ) { - p = p.then(function() { - return $.post(organisationUnitTreePath + "addorgunit.action", { - id: item - }); - }); - } ); - - p.done(fn); - def.resolve(); + q += "id=" + item; + + if( i < (selected.length - 1) ) { + q += '&'; + } + }); + + $.ajax({ + url: organisationUnitTreePath + "addorgunit.action", + data: q, + type: 'POST' + }); } else { selected = $.isArray( selected ) ? selected[0] : selected; @@ -571,7 +573,7 @@ this.scrollToSelected = function() { var ou = selection.getSelected(); - + if ( ou && ou.length ) { $( "#orgUnitTree" ).scrollTop( 0 ); var tagId = "#" + getTagId( ou[0] ); @@ -581,7 +583,7 @@ $( "#orgUnitTree" ).animate( { scrollTop: offset }, 300 ); } }; - + this.findByName = function() { var name = $( '#searchField' ).val(); var match; @@ -625,7 +627,7 @@ } ); } }; - + this.enable = function() { $( "#orgUnitTree" ).show(); }; === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/AddSelectedOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/AddSelectedOrganisationUnitAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/AddSelectedOrganisationUnitAction.java 2014-09-17 10:16:52 +0000 @@ -28,13 +28,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; - +import com.opensymphony.xwork2.Action; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; -import com.opensymphony.xwork2.Action; +import java.util.Collection; +import java.util.List; /** * @author Torgeir Lorange Ostby @@ -65,11 +65,11 @@ // Input/output // ------------------------------------------------------------------------- - private String id; + private List id; - public void setId( String organisationUnitId ) + public void setId( List id ) { - this.id = organisationUnitId; + this.id = id; } private Collection selectedUnits; @@ -86,15 +86,20 @@ public String execute() throws Exception { - OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); + selectedUnits = selectionManager.getSelectedOrganisationUnits(); - if ( unit == null ) + for ( String currentId : id ) { - throw new RuntimeException( "OrganisationUnit with id " + id + " doesn't exist" ); + OrganisationUnit unit = organisationUnitService.getOrganisationUnit( currentId ); + + if ( unit == null ) + { + throw new RuntimeException( "OrganisationUnit with id " + id + " doesn't exist" ); + } + + selectedUnits.add( unit ); } - selectedUnits = selectionManager.getSelectedOrganisationUnits(); - selectedUnits.add( unit ); selectionManager.setSelectedOrganisationUnits( selectedUnits ); return SUCCESS;