← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12283: Completeness, went from external to iso period format

 

------------------------------------------------------------
revno: 12283
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-09-27 15:24:04 +0200
message:
  Completeness, went from external to iso period format
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm


--
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/completeness/action/GetDataCompletenessAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessAction.java	2013-09-27 13:24:04 +0000
@@ -49,6 +49,7 @@
 import org.hisp.dhis.oust.manager.SelectionTreeManager;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.hisp.dhis.util.SessionUtils;
 
@@ -191,7 +192,7 @@
             }
             else
             {
-                Period period = periodService.getPeriodByExternalId( periodId );
+                Period period = periodService.reloadPeriod( PeriodType.getPeriodFromIsoString( periodId ) );
                 Integer _periodId = period.getId();
 
                 DataSet dataSet = null;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js	2012-11-21 13:04:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js	2013-09-27 13:24:04 +0000
@@ -1,9 +1,40 @@
 
-function getPeriods( periodTypeList, availableList, selectedList, timespan )
-{
-    $( "#periodId" ).removeAttr( "disabled" );
-
-    getAvailablePeriods( periodTypeList, availableList, selectedList, timespan );
+var currentPeriodOffset = 0;
+var periodTypeFactory = new PeriodType();
+
+//------------------------------------------------------------------------------
+// Period
+//------------------------------------------------------------------------------
+
+function displayPeriods()
+{
+  var periodType = $( "#periodTypeId" ).val();
+  var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
+  periods = periodTypeFactory.reverse( periods );
+  periods = periodTypeFactory.filterFuturePeriodsExceptCurrent( periods );
+
+  $( "#periodId" ).removeAttr( "disabled" );
+  clearListById( "periodId" );
+
+  for ( i in periods )
+  {
+      addOptionById( "periodId", periods[i].iso, periods[i].name );
+  }
+}
+
+function displayNextPeriods()
+{
+  if ( currentPeriodOffset < 0 ) // Cannot display future periods
+  {
+      currentPeriodOffset++;
+      displayPeriods();
+  }
+}
+
+function displayPreviousPeriods()
+{
+  currentPeriodOffset--;
+  displayPeriods();
 }
 
 function displayCompleteness()

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm	2013-02-03 10:13:17 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataCompletenessForm.vm	2013-09-27 13:24:04 +0000
@@ -33,15 +33,15 @@
     
     <!-- PeriodType -->
 
-	<select id="periodTypeId" style="width:174px" onchange="getPeriods( 'periodTypeId', 'periodId', 'periodId', '0' )">
+	<select id="periodTypeId" style="width:174px" onchange="displayPeriods()">
 		<option value="0">[ $i18n.getString( "select_period_type" ) ]</option>
 		#foreach ( $type in $periodTypes )
 			<option value="$type.name">$i18n.getString( $type.name )</option>
 		#end
 	</select>
 
-	<input type="button" style="width:75px" value="$i18n.getString( 'prev_year' )" onclick="getPeriods( 'periodTypeId', 'periodId', 'periodId', '-1' )" />
-	<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="getPeriods( 'periodTypeId', 'periodId', 'periodId', '1' )" /><br>
+	<input type="button" style="width:75px" value="$i18n.getString( 'prev_year' )" onclick="displayPreviousPeriods()" />
+	<input type="button" style="width:75px" value="$i18n.getString( 'next_year' )" onclick="displayNextPeriods()" /><br>
 
 	<!-- Period -->