← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2360: Apply pagination in standard report list.

 

------------------------------------------------------------
revno: 2360
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Mon 2010-12-13 21:58:04 +0700
message:
  Apply pagination in standard report list.
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java
  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/viewReportForm.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/reportviewer/action/GetAllReportsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java	2010-05-17 13:40:52 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java	2010-12-13 14:58:04 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.apache.commons.lang.StringUtils.isNotBlank;
 import static org.hisp.dhis.util.ContextUtils.getBaseUrl;
 
 import java.util.ArrayList;
@@ -35,22 +36,21 @@
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.options.SystemSettingManager;
+import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.report.ReportManager;
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.report.comparator.ReportComparator;
 import org.hisp.dhis.report.manager.ReportConfiguration;
 
-import org.apache.struts2.ServletActionContext;
-import com.opensymphony.xwork2.Action;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$
  */
 public class GetAllReportsAction
-    implements Action
+    extends ActionPagingSupport<Report>
 {
     private static final String SEPARATOR = "/";
     private static final String BASE_QUERY = "frameset?__report=";
@@ -81,7 +81,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
+    // Input & Output
     // -------------------------------------------------------------------------
 
     private List<Report> reports = new ArrayList<Report>();
@@ -90,6 +90,18 @@
     {
         return reports;
     }
+    
+    private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
+
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
 
     // -------------------------------------------------------------------------
     // Action implementation
@@ -136,6 +148,35 @@
         
         Collections.sort( reports, new ReportComparator() );
         
+        if ( isNotBlank( key ) )
+        {
+            reports = searchByName( reports, key );
+            
+            this.paging = createPaging( reports.size() );
+            
+            reports = getBlockElement( reports, paging.getStartPos(), paging.getPageSize() );
+           
+        }
+        else {
+            this.paging = createPaging( reports.size() );
+                
+            reports = getBlockElement( reports, paging.getStartPos(), paging.getPageSize() );
+        }
+        
         return SUCCESS;
     }
+    
+    private List<Report> searchByName( List<Report> reports, String key )
+    {
+        List<Report> result = new ArrayList<Report>();
+
+        for ( Report each : reports )
+        {
+            if ( each.getName().contains( key ) )
+            {
+                result.add( each );
+            }
+        }
+        return result;
+    }
 }

=== 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	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2010-12-13 14:58:04 +0000
@@ -146,6 +146,7 @@
       <param name="menu">/dhis-web-reporting/menu.vm</param>
       <param name="javascripts">javascript/report.js</param>
       <param name="requiredAuthorities">F_REPORT_VIEW</param>
+	  <param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
     </action>
     
     <action name="displayConfigureReportForm" class="org.hisp.dhis.reporting.reportviewer.action.GetReportConfigurationAction">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2010-12-03 05:41:34 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2010-12-13 14:58:04 +0000
@@ -8,7 +8,8 @@
         <td style="vertical-align:top">
             <table width="100%">
 				 <tr>
-                	<td colspan="6" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='displayAddReportForm.action'"></td>
+				 	<td>#filterDiv( "displayViewReportForm" )</td>
+                	<td colspan="5" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='displayAddReportForm.action'"></td>
                 </tr>
 			</table>
             <table class="listTable" id="listTable">
@@ -36,6 +37,8 @@
                 #end
                 </tbody>
             </table>
+			<p></p>
+			#parse( "/dhis-web-commons/paging/paging.vm" )
                         
         </td>
         <td style="width:20em; padding-left:2em; vertical-align:top">