=== 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 2013-09-23 09:18:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/oust.js 2013-11-06 10:41:43 +0000
@@ -160,25 +160,25 @@
this.buildSelectionTree = function()
{
- selectedOrganisationUnit = new Array();
- selectedOrganisationUnitUid = new Array();
-
- var treeTag = document.getElementById( 'selectionTree' );
-
- setLoadingMessage( treeTag );
-
- var children = $(treeTag).find( 'ul' );
- if ( children.length > 0 )
- {
- treeTag.removeChild( children[0] );
+ selectedOrganisationUnit = [];
+ selectedOrganisationUnitUid = [];
+
+ var treeTag = document.getElementById('selectionTree');
+
+ setLoadingMessage(treeTag);
+
+ var children = $(treeTag).find('ul');
+
+ if( children.length > 0 ) {
+ treeTag.removeChild(children[0]);
}
-
- $.ajax({
- url: selectionTreePath + 'getExpandedTree.action',
- cache: false,
- dataType: "xml",
- success: treeReceived
- });
+
+ $.ajax({
+ url: selectionTreePath + 'getExpandedTree.action',
+ cache: false,
+ dataType: "xml",
+ success: treeReceived
+ });
};
function processExpand( rootElement )
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm 2011-06-22 06:16:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeMultipleSelect.vm 2013-11-06 10:41:43 +0000
@@ -16,15 +16,17 @@
});
function selectedOrganisationUnitXML__( xml )
-{
- #if( $required )
- selectedOrganisationUnitList__.empty();
+{
+ #if( $required )
+ selectedOrganisationUnitList__.empty();
jQuery.each( jQuery( xml ).find( 'unitId' ), function( i, item ) {
- id = item.firstChild.nodeValue;
+ var id = item.firstChild.nodeValue;
selectedOrganisationUnitList__.append( '' );
});
+
#end
+
selectionTree.buildSelectionTree();
}
@@ -32,8 +34,8 @@
- $i18n.getString( "organisation_unit_selection_tree" )
-
+ | $i18n.getString( "organisation_unit_selection_tree" )
+
|
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js 2011-06-22 06:16:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js 2013-11-06 10:41:43 +0000
@@ -2,18 +2,25 @@
function addSelectedOrganisationUnit__( id )
{
- selectedOrganisationUnitList__.append('');
+ selectedOrganisationUnitList__.empty();
+ selectedOrganisationUnitList__.append('');
}
function selectOrganisationUnit__( ids )
{
selectedOrganisationUnitList__.empty();
+ if( ids && ids.length > 0 ) {
+ selectedOrganisationUnitList__.append('');
+ }
+
+ /*
jQuery.each(ids, function( i, item )
{
selectedOrganisationUnitList__.append('');
});
-
+ */
+
byId('treeSelectedId').selectedIndex = 0;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java 2013-09-09 08:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java 2013-11-06 10:41:43 +0000
@@ -32,9 +32,12 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashSet;
+import java.util.Set;
/**
* @author Kristian
@@ -63,6 +66,14 @@
this.dataSetService = dataSetService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ @Autowired
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -83,7 +94,19 @@
{
DataSet dataSet = dataSetService.getDataSet( dataSetId );
- dataSet.updateOrganisationUnits( new HashSet( selectionTreeManager.getReloadedSelectedOrganisationUnits() ) );
+ Set organisationUnits = new HashSet( dataSet.getSources() );
+
+ Set userOrganisationUnits = new HashSet();
+
+ for ( OrganisationUnit organisationUnit : selectionTreeManager.getRootOrganisationUnits() )
+ {
+ userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
+ }
+
+ organisationUnits.removeAll( userOrganisationUnits );
+ organisationUnits.addAll( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
+
+ dataSet.updateOrganisationUnits( organisationUnits );
dataSetService.updateDataSet( dataSet );