dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25972
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12889: bugfixes for dataset assignment, allow partial updates to associations (if a user if lower in the...
------------------------------------------------------------
revno: 12889
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-11-06 11:41:43 +0100
message:
bugfixes for dataset assignment, allow partial updates to associations (if a user if lower in the tree, and assign new OUs to a dataset). Also make sure that OUST uses mostly server-state (instead of both as it was before), only uses client-state to make required-validation work.
modified:
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/selectionTreeMultipleSelect.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java
--
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/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( '<option value="' + id + '" selected="selected">' + id + '</option>' );
});
+
#end
+
selectionTree.buildSelectionTree();
}
</script>
@@ -32,8 +34,8 @@
<table cellspacing=0 width="535px">
<thead>
<tr>
- <th colspan="2">$i18n.getString( "organisation_unit_selection_tree" )
- <select id="treeSelectedId" name="treeSelectedId" #if( $required ) class="{validate:{required:true}}" #end multiple="multiple" style="display:none"/>
+ <th colspan="2">$i18n.getString( "organisation_unit_selection_tree" )
+ <select id="treeSelectedId" name="treeSelectedId" #if( $required ) class="{validate:{required:true}}" #end multiple="multiple" style="display:none"/>
</th>
</tr>
</thead>
=== 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('<option value="' + id + '" selected="selected">' + id + '</option>');
+ selectedOrganisationUnitList__.empty();
+ selectedOrganisationUnitList__.append('<option value="' + id + '" selected="selected">' + id + '</option>');
}
function selectOrganisationUnit__( ids )
{
selectedOrganisationUnitList__.empty();
+ if( ids && ids.length > 0 ) {
+ selectedOrganisationUnitList__.append('<option value="' + ids[0] + '" selected="selected">' + ids[0] + '</option>');
+ }
+
+ /*
jQuery.each(ids, function( i, item )
{
selectedOrganisationUnitList__.append('<option value="' + item + '" selected="selected">' + item + '</option>');
});
-
+ */
+
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<OrganisationUnit>( selectionTreeManager.getReloadedSelectedOrganisationUnits() ) );
+ Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>( dataSet.getSources() );
+
+ Set<OrganisationUnit> userOrganisationUnits = new HashSet<OrganisationUnit>();
+
+ for ( OrganisationUnit organisationUnit : selectionTreeManager.getRootOrganisationUnits() )
+ {
+ userOrganisationUnits.addAll( organisationUnitService.getOrganisationUnitsWithChildren( organisationUnit.getUid() ) );
+ }
+
+ organisationUnits.removeAll( userOrganisationUnits );
+ organisationUnits.addAll( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
+
+ dataSet.updateOrganisationUnits( organisationUnits );
dataSetService.updateDataSet( dataSet );