← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6523: Report table, using org unit selection tree instead of list of org units for fixed org units

 

------------------------------------------------------------
revno: 6523
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-04-07 16:06:33 +0200
message:
  Report table, using org unit selection tree instead of list of org units for fixed org units
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js


--
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-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java	2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java	2012-04-07 14:06:33 +0000
@@ -48,11 +48,9 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -120,13 +118,6 @@
         this.periodService = periodService;
     }
     
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-    
     private OrganisationUnitGroupService organisationUnitGroupService;
     
     public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
@@ -140,6 +131,13 @@
     {
         this.dataSetService = dataSetService;
     }
+
+    private SelectionTreeManager selectionTreeManager;
+
+    public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+    {
+        this.selectionTreeManager = selectionTreeManager;
+    }
     
     private I18nFormat format;
 
@@ -230,21 +228,7 @@
     {
         return periods;
     }
-    
-    private List<OrganisationUnitLevel> levels = new ArrayList<OrganisationUnitLevel>();
-
-    public List<OrganisationUnitLevel> getLevels()
-    {
-        return levels;
-    }
-    
-    private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
-
-    public List<OrganisationUnit> getOrganisationUnits()
-    {
-        return organisationUnits;
-    }
-    
+            
     private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
 
     public List<OrganisationUnitGroup> getOrganisationUnitGroups()
@@ -286,14 +270,7 @@
     {
         return selectedPeriods;
     }
-    
-    private List<OrganisationUnit> selectedOrganisationUnits = new ArrayList<OrganisationUnit>();
-
-    public List<OrganisationUnit> getSelectedOrganisationUnits()
-    {
-        return selectedOrganisationUnits;
-    }
-    
+        
     private List<OrganisationUnitGroup> selectedOrganisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
 
     public List<OrganisationUnitGroup> getSelectedOrganisationUnitGroups()
@@ -355,11 +332,6 @@
         Collections.reverse( periods );
         FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
         
-        levels = organisationUnitService.getOrganisationUnitLevels();
-        
-        organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
-        Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() );
-        
         organisationUnitGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getOrganisationUnitGroupsWithGroupSets() );
         Collections.sort( organisationUnitGroups, new IdentifiableObjectNameComparator() );
         
@@ -381,6 +353,8 @@
             reportingPeriods.put( month, periodName );
         }
         
+        selectionTreeManager.clearSelectedOrganisationUnits();
+        
         // ---------------------------------------------------------------------
         // Report table
         // ---------------------------------------------------------------------
@@ -397,8 +371,6 @@
             
             periods.removeAll( reportTable.getPeriods() );
             
-            organisationUnits.removeAll( reportTable.getUnits() );
-
             selectedDataElements = reportTable.getDataElements();
             
             selectedIndicators = reportTable.getIndicators();
@@ -407,9 +379,9 @@
             
             selectedPeriods = reportTable.getPeriods();
             
-            selectedOrganisationUnits = reportTable.getUnits();
-            
             selectedOrganisationUnitGroups = reportTable.getOrganisationUnitGroups();
+
+            selectionTreeManager.setSelectedOrganisationUnits( reportTable.getUnits() );
         }
         
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2012-03-30 13:32:44 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2012-04-07 14:06:33 +0000
@@ -44,7 +44,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.RelativePeriods;
@@ -100,13 +100,6 @@
         this.periodService = periodService;
     }
     
-    private OrganisationUnitService organisationUnitService;
-
-    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-    {
-        this.organisationUnitService = organisationUnitService;
-    }
-    
     private OrganisationUnitGroupService organisationUnitGroupService;
     
     public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
@@ -121,6 +114,13 @@
         this.dataSetService = dataSetService;
     }
 
+    private SelectionTreeManager selectionTreeManager;
+
+    public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+    {
+        this.selectionTreeManager = selectionTreeManager;
+    }
+    
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -222,13 +222,6 @@
     {
         this.selectedPeriods = selectedPeriods;
     }
-
-    private List<String> selectedOrganisationUnits = new ArrayList<String>();
-
-    public void setSelectedOrganisationUnits( List<String> selectedOrganisationUnits )
-    {
-        this.selectedOrganisationUnits = selectedOrganisationUnits;
-    }
     
     private List<String> selectedOrganisationUnitGroups = new ArrayList<String>();
 
@@ -396,7 +389,7 @@
         List<DataElement> dataElements = new ArrayList<DataElement>();        
         List<Indicator> indicators = new ArrayList<Indicator>();
         List<DataSet> dataSets = new ArrayList<DataSet>();
-        List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();
+        List<OrganisationUnit> units = new ArrayList<OrganisationUnit>( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
         List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>(); 
 
         for ( Integer id : getIntegerCollection( selectedDataElements ) )
@@ -413,12 +406,7 @@
         {
             dataSets.add( dataSetService.getDataSet( id ) );
         }
-        
-        for ( Integer id : getIntegerCollection( selectedOrganisationUnits ) )
-        {
-            units.add( organisationUnitService.getOrganisationUnit( id ) );
-        }
-        
+                
         for ( Integer id : getIntegerCollection( selectedOrganisationUnitGroups ) )
         {
             organisationUnitGroups.add( organisationUnitGroupService.getOrganisationUnitGroup( id ) );

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2012-04-05 13:13:13 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2012-04-07 14:06:33 +0000
@@ -66,9 +66,9 @@
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+    <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
   </bean>
 
   <bean id="org.hisp.dhis.reporting.tablecreator.action.SaveTableAction" class="org.hisp.dhis.reporting.tablecreator.action.SaveTableAction"
@@ -78,9 +78,9 @@
     <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+    <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
   </bean>
 
   <bean id="org.hisp.dhis.reporting.tablecreator.action.GetReportParamsAction" class="org.hisp.dhis.reporting.tablecreator.action.GetReportParamsAction"

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2012-03-05 12:23:01 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2012-04-07 14:06:33 +0000
@@ -160,7 +160,7 @@
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-reporting/addTableForm.vm</param>
       <param name="menu">/dhis-web-reporting/menu.vm</param>
-      <param name="javascripts">javascript/table.js,javascript/lists.js</param>
+      <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/table.js,javascript/lists.js</param>
       <param name="requiredAuthorities">F_REPORTTABLE_ADD</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2012-03-30 13:32:44 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2012-04-07 14:06:33 +0000
@@ -330,64 +330,11 @@
 
 <span><a href="javascript:toggleFixedOrganisationUnits()">$i18n.getString( "toggle_fixed_organisation_units" )</a>&nbsp;</span>
 
-<div id="fixedOrganisationUnits" style="display:none">
-
-<table>
-	
-	<!-- OrganisationUnits -->
-	
-	<tr>
-		<th>$i18n.getString( "available_organisationunits" )</th>
-	</tr>
-	<tr>
-		<td>
-			<select id="organisationUnitLevel" name="organisationUnitLevel" style="min-width:640px" onchange="getOrganisationUnits()">
-				<option value="$ALL">[ $i18n.getString( "select_organisationunit_level_all" ) ]</option>
-				#foreach ( $level in $levels )
-					#if( $velocityCount == 1)
-					<option value="$level.level" selected="selected">$encoder.htmlEncode( $level.name )</option>
-					#else
-					<option value="$level.level">$encoder.htmlEncode( $level.name )</option>
-					#end
-				#end
-			</select>
-		</td>
-	</tr>
-	<tr>
-		<td>
-			<select multiple size="6" id="availableOrganisationUnits" name="availableOrganisationUnits" style="min-width:640px" ondblclick="moveSelectedById( 'availableOrganisationUnits', 'selectedOrganisationUnits' )">
-				#foreach ( $unit in $organisationUnits )
-					<option value="$unit.id">$encoder.htmlEncode( $unit.name )</option>
-				#end
-			</select>
-		</td>
-	</tr>
-	<tr>
-		<td>
-			<input type="button" value="$i18n.getString( 'add_selected' )" title="$i18n.getString( 'add_selected' )" style="width:120px" onclick="moveSelectedById( 'availableOrganisationUnits', 'selectedOrganisationUnits' )"><input 
-				type="button" value="$i18n.getString( 'add_all' )" title="$i18n.getString( 'add_all' )" style="width:120px" onclick="moveAllById( 'availableOrganisationUnits', 'selectedOrganisationUnits' )"><input 
-                type="button" value="$i18n.getString( 'add_children' )" title="$i18n.getString( 'add_children' )" style="width:120px" onclick="getOrganisationUnitChildren()"><input 
-				type="button" value="$i18n.getString( 'remove_selected' )" title="$i18n.getString( 'remove_selected' )" style="width:120px" onclick="moveSelectedById( 'selectedOrganisationUnits', 'availableOrganisationUnits' )"><input 
-				type="button" value="$i18n.getString( 'remove_all' )" title="$i18n.getString( 'remove_all' )" style="width:120px" onclick="moveAllById( 'selectedOrganisationUnits', 'availableOrganisationUnits' )">
-		</td>
-	</tr>
-	<tr>
-		<th>$i18n.getString( "selected_organisationunits" )</th>
-	</tr>
-	<tr>
-		<td>
-			<select multiple size="6" id="selectedOrganisationUnits" name="selectedOrganisationUnits" style="min-width:640px" ondblclick="moveSelectedById( 'selectedOrganisationUnits', 'availableOrganisationUnits' )">				
-				#foreach ( $unit in $selectedOrganisationUnits )
-					<option value="$unit.id">$encoder.htmlEncode( $unit.name )</option>
-				#end
-			</select>
-		</td>
-	</tr>
-	<tr>
-		<td style="height:15px"></td>
-	</tr>
-	
-</table>
+<div id="fixedOrganisationUnits" style="display:none; margin-top:2px; margin-bottom:15px;">
+
+	<!-- Organisation Units -->
+
+#organisationUnitSelectionTree( false true false )
 
 </div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js	2012-03-04 13:46:17 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js	2012-04-07 14:06:33 +0000
@@ -114,44 +114,6 @@
     }
 }
 
-function getOrganisationUnits()
-{
-    var organisationUnitLevelList = document.getElementById( "organisationUnitLevel" );
-    var organisationUnitLevel = organisationUnitLevelList.options[organisationUnitLevelList.selectedIndex].value;
-
-    if ( organisationUnitLevel != null )
-    {
-		$.get( '../dhis-web-commons-ajax/getOrganisationUnits.action',
-		{
-			level: organisationUnitLevel
-		},getOrganisationUnitsReceived );
-    }
-}
-
-function getOrganisationUnitsReceived( xmlObject )
-{
-    var availableOrganisationUnits = byId( "availableOrganisationUnits" );
-    var selectedOrganisationUnits = byId( "selectedOrganisationUnits" );
-
-    clearList( availableOrganisationUnits );
-
-    var organisationUnits = xmlObject.getElementsByTagName( "organisationUnit" );
-
-    for ( var i = 0; i < organisationUnits.length; i++ )
-    {
-        var id = organisationUnits[i].getElementsByTagName( "id" )[0].firstChild.nodeValue;
-        var organisationUnitName = organisationUnits[i].getElementsByTagName( "name" )[0].firstChild.nodeValue;
-
-        if ( listContains( selectedOrganisationUnits, id ) == false )
-        {
-            var option = document.createElement( "option" );
-            option.value = id;
-            option.text = organisationUnitName;
-            availableOrganisationUnits.add( option, null );
-        }
-    }
-}
-
 function getOrganisationUnitChildren()
 {
     var organisationUnitList = byId( "availableOrganisationUnits" );

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2012-04-02 10:17:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2012-04-07 14:06:33 +0000
@@ -75,7 +75,7 @@
         return false;
     }
 
-    if ( !hasElements( "selectedOrganisationUnits" ) && !hasElements( "selectedOrganisationUnitGroups" ) && !organisationUnitReportParamsChecked() )
+    if ( !selectionTreeSelection.isSelected() && !hasElements( "selectedOrganisationUnitGroups" ) && !organisationUnitReportParamsChecked() )
     {
         setMessage( i18n_must_select_at_least_one_unit );