← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5568: GUI for groups in report table

 

------------------------------------------------------------
revno: 5568
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-23 19:01:04 +0100
message:
  GUI for groups in report table
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  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/org/hisp/dhis/reporting/i18n_module.properties
  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/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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-12-23 13:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-12-23 18:01:04 +0000
@@ -170,31 +170,28 @@
  */
 function isChecked( checkboxId )
 {
-	return jQuery( "#" + checkboxId ).length && jQuery( "#" + checkboxId ).is( ":checked" );   
+	return jQuery( "#" + checkboxId ).length && jQuery( "#" + checkboxId ).is( ":checked" );
 }
 
 /**
- * Checks the checkbox with the given jQuery Selector String if the checkbox
- * exists.
+ * Toggles the checked property of checkbox elements.
  */
-function checkALL( jQuerySelectorString )
+function toggleChecked( checkBoxId )
 {
-    jQuery.each( jQuery( jQuerySelectorString ), function(i, item ){
-		item.checked = true;
-	});
+	var box = jQuery( "#" + checkBoxId );
+	
+	if ( box.length )
+	{
+		box.prop( "checked", !box.is( ":checked" ) );
+	}
 }
 
-function toggleChecked( checked, name )
-{
-	if( checked ) checkALL( "input[type=checkbox][name=" + name + "]" );
-	else unCheckALL( "input[type=checkbox][name=" + name + "]" );
-}
 /**
  * Checks the checkbox with the given identifier if the checkbox exists.
  */
 function check( checkBoxId )
 {
-    jQuery( "#" + checkBoxId ).attr("checked", true );
+    jQuery( "#" + checkBoxId ).prop( "checked", true );
 }
 
 /**
@@ -202,18 +199,7 @@
  */
 function uncheck( checkBoxId )
 {
-    jQuery( "#" + checkBoxId ).attr("checked", false );
-}
-
-/**
- * unChecks the checkbox with the given jQuery Selector String if the checkbox
- * exists.
- */
-function unCheckALL( jQuerySelectorString )
-{
-    jQuery.each( jQuery( jQuerySelectorString ), function(i, item ){
-		item.checked = false;
-	});
+    jQuery( "#" + checkBoxId ).prop( "checked", false );
 }
 
 /**

=== 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	2011-02-28 17:34:25 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java	2011-12-23 18:01:04 +0000
@@ -36,6 +36,7 @@
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -54,6 +55,8 @@
 import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
 import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
 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.period.MonthlyPeriodType;
@@ -130,6 +133,13 @@
         this.organisationUnitService = organisationUnitService;
     }
     
+    private OrganisationUnitGroupService organisationUnitGroupService;
+    
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
     private DataSetService dataSetService;
 
     public void setDataSetService( DataSetService dataSetService )
@@ -255,6 +265,13 @@
         return organisationUnits;
     }
     
+    private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
+
+    public List<OrganisationUnitGroup> getOrganisationUnitGroups()
+    {
+        return organisationUnitGroups;
+    }
+
     private ReportTable reportTable;
 
     public ReportTable getReportTable()
@@ -297,6 +314,13 @@
         return selectedOrganisationUnits;
     }
     
+    private List<OrganisationUnitGroup> selectedOrganisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
+
+    public List<OrganisationUnitGroup> getSelectedOrganisationUnitGroups()
+    {
+        return selectedOrganisationUnitGroups;
+    }
+
     private SortedMap<Integer, String> reportingPeriods = new TreeMap<Integer, String>();
 
     public SortedMap<Integer, String> getReportingPeriods()
@@ -323,54 +347,45 @@
 
         if ( dimension )
         {
-            categoryCombos = new ArrayList<DataElementCategoryCombo>( categoryService.getAllDataElementCategoryCombos() );
-            
+            categoryCombos = new ArrayList<DataElementCategoryCombo>( categoryService.getAllDataElementCategoryCombos() );            
             Collections.sort( categoryCombos, new DataElementCategoryComboNameComparator() );            
         }
         else
         {        
-            dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
-            
+            dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );            
             Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
             
-            dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );
-            
-            Collections.sort( dataElements, new DataElementNameComparator() );
-            
-            FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
-            
+            dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements() );            
+            Collections.sort( dataElements, new DataElementNameComparator() );            
+            FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );            
             displayPropertyHandler.handle( dataElements );
             
-            indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups() );
-            
+            indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups() );            
             Collections.sort( indicatorGroups, new IndicatorGroupNameComparator() );
-                    
-            indicators = new ArrayList<Indicator>( indicatorService.getAllIndicators() );
-            
-            Collections.sort( indicators, indicatorComparator );
-            
+            
+            indicators = new ArrayList<Indicator>( indicatorService.getAllIndicators() );            
+            Collections.sort( indicators, indicatorComparator );            
             displayPropertyHandler.handle( indicators );
             
-            dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-            
+            dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );            
             Collections.sort( dataSets, new DataSetNameComparator() ); 
         }
         
         periodTypes = periodService.getAllPeriodTypes();
         
         periods = new MonthlyPeriodType().generatePeriods( new Date() );
-
         Collections.reverse( periods );
         FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
         
         levels = organisationUnitService.getOrganisationUnitLevels();
         
         organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
-
         displayPropertyHandler.handle( organisationUnits );
-
         Collections.sort( organisationUnits, organisationUnitComparator );
         
+        organisationUnitGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getOrganisationUnitGroupsWithGroupSets() );
+        Collections.sort( organisationUnitGroups, new IdentifiableObjectNameComparator() );
+        
         // ---------------------------------------------------------------------
         // Reporting periods
         // ---------------------------------------------------------------------
@@ -416,6 +431,8 @@
             selectedPeriods = reportTable.getPeriods();
             
             selectedOrganisationUnits = reportTable.getUnits();
+            
+            selectedOrganisationUnitGroups = reportTable.getOrganisationUnitGroups();
         }
         
         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	2011-12-22 19:59:19 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-12-23 18:01:04 +0000
@@ -43,6 +43,7 @@
 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.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -106,6 +107,13 @@
         this.organisationUnitService = organisationUnitService;
     }
     
+    private OrganisationUnitGroupService organisationUnitGroupService;
+    
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
     private DataSetService dataSetService;
 
     public void setDataSetService( DataSetService dataSetService )
@@ -214,6 +222,13 @@
     {
         this.selectedOrganisationUnits = selectedOrganisationUnits;
     }
+    
+    private List<String> selectedOrganisationUnitGroups = new ArrayList<String>();
+
+    public void setSelectedOrganisationUnitGroups( List<String> selectedOrganisationUnitGroups )
+    {
+        this.selectedOrganisationUnitGroups = selectedOrganisationUnitGroups;
+    }
 
     private boolean reportingMonth;
 
@@ -368,6 +383,7 @@
         List<Indicator> indicators = new ArrayList<Indicator>();
         List<DataSet> dataSets = new ArrayList<DataSet>();
         List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();
+        List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>(); 
 
         for ( Integer id : getIntegerCollection( selectedDataElements ) )
         {
@@ -389,6 +405,11 @@
             units.add( organisationUnitService.getOrganisationUnit( id ) );
         }
         
+        for ( Integer id : getIntegerCollection( selectedOrganisationUnitGroups ) )
+        {
+            organisationUnitGroups.add( organisationUnitGroupService.getOrganisationUnitGroup( id ) );
+        }
+        
         DataElementCategoryCombo categoryCombo = categoryComboId != null ? categoryService.getDataElementCategoryCombo( categoryComboId ) : null;
         
         RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth,
@@ -409,9 +430,9 @@
         if ( tableId == null )
         {
             reportTable = new ReportTable( tableName, regression,
-                dataElements, indicators, dataSets, periods, null, units, null, new ArrayList<OrganisationUnitGroup>(),
-                categoryCombo, doIndicators, doPeriods, doOrganisationUnits, relatives, reportParams, 
-                null, null );
+                dataElements, indicators, dataSets, periods, null, units, null, organisationUnitGroups,
+                categoryCombo, doIndicators, doPeriods, doOrganisationUnits, relatives, reportParams, null, null );
+            
             reportTable.setSortOrder( sortOrder );
             reportTable.setTopLimit( topLimit );
         }
@@ -428,6 +449,7 @@
             reportTable.setDataSets( dataSets );
             reportTable.setPeriods( periods );
             reportTable.setUnits( units );
+            reportTable.setOrganisationUnitGroups( organisationUnitGroups );
             reportTable.setCategoryCombo( categoryCombo );
             reportTable.setDoIndicators( doIndicators );
             reportTable.setDoPeriods( doPeriods );

=== 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	2011-12-22 21:17:05 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-12-23 18:01:04 +0000
@@ -67,6 +67,7 @@
     <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" />
   </bean>
 
@@ -78,6 +79,7 @@
     <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" />
   </bean>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-12-22 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-12-23 18:01:04 +0000
@@ -397,4 +397,6 @@
 last_month=Last month
 last_quarter=Last quarter
 last_six_month=Last six-month
-last_2_sixmonths=Last 2 six-months
\ No newline at end of file
+last_2_sixmonths=Last 2 six-months
+available_organisation_unit_groups=Available organisation unit groups
+selected_organisation_unit_groups=Selected organisation unit groups
\ No newline at end of file

=== 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	2011-10-27 12:08:07 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2011-12-23 18:01:04 +0000
@@ -275,6 +275,54 @@
     
 </table>
 
+<span><a href="javascript:toggleOrganisationUnitGroups()">Toggle organisation unit groups</a>&nbsp;</span>
+
+<div id="organisationUnitGroupsDiv" style="display:none">
+
+<table>
+
+	<!-- Organisation Unit Groups -->
+
+	<tr>
+		<th>$i18n.getString( "available_organisation_unit_groups" )</th>
+	</tr>
+	<tr>
+		<td>
+			<select multiple size="6" id="availableOrganisationUnitGroups" name="availableOrganisationUnitGroups" style="min-width:640px" ondblclick="moveSelectedById( 'availableOrganisationUnitGroups', 'selectedOrganisationUnitGroups' )">
+				#foreach ( $group in $organisationUnitGroups )
+					<option value="$group.id">$encoder.htmlEncode( $group.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( 'availableOrganisationUnitGroups', 'selectedOrganisationUnitGroups' )"><input 
+				type="button" value="$i18n.getString( 'add_all' )" title="$i18n.getString( 'add_all' )" style="width:120px" onclick="moveAllById( 'availableOrganisationUnitGroups', 'selectedOrganisationUnitGroups' )"><input 
+				type="button" value="$i18n.getString( 'remove_selected' )" title="$i18n.getString( 'remove_selected' )" style="width:120px" onclick="moveSelectedById( 'selectedOrganisationUnitGroups', 'availableOrganisationUnitGroups' )"><input 
+				type="button" value="$i18n.getString( 'remove_all' )" title="$i18n.getString( 'remove_all' )" style="width:120px" onclick="moveAllById( 'selectedOrganisationUnitGroups', 'availableOrganisationUnitGroups' )">
+		</td>
+	</tr>
+	<tr>
+		<th>$i18n.getString( "selected_organisation_unit_groups" )</th>
+	</tr>
+	<tr>
+		<td>
+			<select multiple size="6" id="selectedOrganisationUnitGroups" name="selectedOrganisationUnitGroups" style="min-width:640px" ondblclick="moveSelectedById( 'selectedOrganisationUnitGroups', 'availableOrganisationUnitGroups' )">				
+				#foreach ( $group in $selectedOrganisationUnitGroups )
+					<option value="$group.id">$encoder.htmlEncode( $group.name )</option>
+				#end
+			</select>
+		</td>
+	</tr>
+	<tr>
+		<td style="height:15px"></td>
+	</tr>
+	
+</table>
+
+</div>
+
 <span><a href="javascript:toggleFixedOrganisationUnits()">Toggle fixed organisation units</a>&nbsp;</span>
 
 <div id="fixedOrganisationUnits" style="display:none">
@@ -397,9 +445,9 @@
 </table>
 	
 </div>
-	
-<table>	
 
+<table>
+	
 	<!-- Relative Periods -->
 	
 	<tr>

=== 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	2011-10-11 14:54:46 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js	2011-12-23 18:01:04 +0000
@@ -38,6 +38,11 @@
 
     selectAllById( "selectedPeriods" );
     selectAllById( "selectedOrganisationUnits" );
+    
+    if ( isNotEmpty( "selectedOrganisationUnitGroups" ) )
+    {
+        selectAllById( "selectedOrganisationUnitGroups" );
+    }
 }
 
 // -----------------------------------------------------------------------------
@@ -187,6 +192,11 @@
     $( '#fixedPeriods' ).toggle( 'fast' );
 }
 
+function toggleOrganisationUnitGroups()
+{
+	$( '#organisationUnitGroupsDiv' ).toggle( 'fast' );
+}
+
 // -----------------------------------------------------------------------------
 // Dashboard
 // -----------------------------------------------------------------------------