← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8893: improve displaying period in aggregate report web-light

 

------------------------------------------------------------
revno: 8893
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-11-06 10:41:55 +0700
message:
  improve displaying period in aggregate report web-light
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.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-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	2012-11-05 04:36:04 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	2012-11-06 03:41:55 +0000
@@ -259,8 +259,9 @@
         Validate.notNull( dataSetId );
 
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
-
+        
         CalendarPeriodType periodType = null;
+
         if ( dataSet.getPeriodType().getName().equalsIgnoreCase( "Yearly" ) )
         {
             periodType = (CalendarPeriodType) new YearlyPeriodType();
@@ -269,17 +270,31 @@
         {
             periodType = (CalendarPeriodType) dataSet.getPeriodType();
         }
-
-        List<Period> periods = periodType.generateLast5Years( new Date() );
-        FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
-        Collections.reverse( periods );
-
-        if ( periods.size() > (first + max) )
-        {
-            periods = periods.subList( first, max );
-        }
-
-        return periods;
+        
+        if ( dataSet.isAllowFuturePeriods() )
+        {
+            List<Period> periods = new ArrayList<Period>();
+            //if ( periodType.getName().equals( "Monthly" ) || periodType.getName().equals( "Quarterly" ))
+            //{
+                periods = periodType.generatePeriods( new Date() );
+                Collections.reverse( periods );
+            //}
+            return periods;
+        }
+        else
+        {
+            
+            List<Period> periods = periodType.generateLast5Years( new Date() );
+            FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+            Collections.reverse( periods );
+    
+            if ( periods.size() > (first + max) )
+            {
+                periods = periods.subList( first, max );
+            }
+    
+            return periods;
+        }
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm	2012-10-12 09:22:44 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm	2012-11-06 03:41:55 +0000
@@ -11,9 +11,7 @@
         $dataSetName
     </p>
 </div>
-
 <h2>$i18n.getString( "available_periods" )</h2>
-
 <p>
 <ul>
 #foreach( $period in $periods )