← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2001: Centralize pagination in search function by using velocity macro.

 

------------------------------------------------------------
revno: 2001
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Sun 2010-11-07 19:01:24 +0700
message:
  Centralize pagination in search function by using velocity macro.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSearch.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementSearch.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.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/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2010-09-14 09:03:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2010-11-07 12:01:24 +0000
@@ -113,3 +113,85 @@
 		#parse( "/dhis-web-commons/oust/selectionTreeSingleSelect.vm" )
 	#end	
 #end
+
+
+#macro( searchingPagination $methodName )
+<div class="paging-container">
+	#set ( $baseLink 		= $paging.baseLink )
+	#set ( $pageSize 		= $paging.pageSize )
+	#set ( $currentPage 	= $paging.currentPage )
+	#set ( $startPage 		= $paging.startPage )
+	#set ( $numberOfPages	= $paging.numberOfPages )
+	
+	<input type="hidden" id="baseLink" value="$!baseLink"/>
+	<input type="hidden" id="currentPage" value="$!currentPage"/>
+	#if ( $numberOfPages > 0 )
+		<table style="background-color: #ebf0f6;" width='100%'>
+				<tr>
+					<td>
+						<span>$i18n.getString("no_of_pages"):</span> <span id="numberOfPage">$numberOfPages</span>
+					</td>
+					<td>
+						<span >$i18n.getString("size_of_page"):</span>
+					
+						<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onchange="changePageSizeSearch();">
+					</td>
+					<td>
+						<span >$i18n.getString("jump_to_page"):</span>
+					
+						<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onchange="jumpToPageSearch();">
+					</td>
+					<td>
+						<input type="button" id="submitButton" value="$i18n.getString('go')" onclick="jumpToPageSearch();">
+					</td>
+				
+		</tr>
+		
+		<tr>
+			<td colspan='4' ><hr/></td>
+		</tr>
+		
+		<tr>
+		<td colspan='4'>
+		<div class="paging">
+		#if ($currentPage > 1)
+			#set ( $prev = $currentPage - 1 )
+			<a href="#" class="first" title="First" onclick="$methodName(1, ${pageSize});">&laquo;&laquo;</a>
+			<a href="#" class="prev" title="Previous" onclick="$methodName(${prev}, ${pageSize});">&laquo;</a>
+		#else
+			<span class="first" title="First">&laquo;&laquo;</span>
+			<span class="prev" title="Previous">&laquo;</span>
+		#end
+		
+		#foreach( $i in [0..4]   )
+			#set( $p = $startPage + $i )
+			#if ( $p <= $numberOfPages )
+				#if( $i > 0 )
+					<span class="seperator">|</span>
+				#end
+				#if( $p != $currentPage )
+					<a href="#" class="page" title="Page $p" onclick="$methodName(${p}, ${pageSize});">$p</a>
+				#else
+					<span class="page" title="Page $p">$p</span>
+				#end
+			#end
+		#end
+		
+		#if ( $currentPage < $numberOfPages )
+			#set ( $next = $currentPage + 1 )
+			<a href="#" class="next" title="Next" onclick="$methodName(${next}, ${pageSize});">&raquo;</a>
+			<a href="#" class="last" title="Last" onclick="$methodName(${numberOfPages}, ${pageSize});">&raquo;&raquo;</a>
+		#else
+			<span class="next" title="Next">&raquo; </span>
+			<span class="last" title="Last">&raquo;&raquo;</span>
+		#end
+		</div>
+		
+		</td>
+		</tr>
+		</table>
+	#end
+</div>
+#end
+
+

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSearch.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSearch.vm	2010-11-02 13:02:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSearch.vm	2010-11-07 12:01:24 +0000
@@ -1,5 +1,7 @@
 <script type="text/javascript" src="../main.js"></script>
 
+
+
 <table class="listTable" id="dataElementGroupList">
 	<col/>
 	<col width="20"/>
@@ -25,80 +27,4 @@
 	</tbody>
 </table>
 <p></p>
-<div class="paging-container">
-	#set ( $baseLink 		= $paging.baseLink )
-	#set ( $pageSize 		= $paging.pageSize )
-	#set ( $currentPage 	= $paging.currentPage )
-	#set ( $startPage 		= $paging.startPage )
-	#set ( $numberOfPages	= $paging.numberOfPages )
-	
-	<input type="hidden" id="baseLink" value="$!baseLink"/>
-	<input type="hidden" id="currentPage" value="$!currentPage"/>
-	#if ( $numberOfPages > 0 )
-		<table style="background-color: #ebf0f6;" width='100%'>
-				<tr>
-					<td>
-						<span>$i18n.getString("no_of_pages"):</span> <span id="numberOfPage">$numberOfPages</span>
-					</td>
-					<td>
-						<span >$i18n.getString("size_of_page"):</span>
-					
-						<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onchange="changePageSizeSearch();">
-					</td>
-					<td>
-						<span >$i18n.getString("jump_to_page"):</span>
-					
-						<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onchange="jumpToPageSearch();">
-					</td>
-					<td>
-						<input type="button" id="submitButton" value="$i18n.getString('go')" onclick="jumpToPageSearch();">
-					</td>
-				
-		</tr>
-		
-		<tr>
-			<td colspan='4' ><hr/></td>
-		</tr>
-		
-		<tr>
-		<td colspan='4'>
-		<div class="paging">
-		#if ($currentPage > 1)
-			#set ( $prev = $currentPage - 1 )
-			<a href="#" class="first" title="First" onclick="searchDataElementGroupPaging(1, ${pageSize});">&laquo;&laquo;</a>
-			<a href="#" class="prev" title="Previous" onclick="searchDataElementGroupPaging(${prev}, ${pageSize});">&laquo;</a>
-		#else
-			<span class="first" title="First">&laquo;&laquo;</span>
-			<span class="prev" title="Previous">&laquo;</span>
-		#end
-		
-		#foreach( $i in [0..4]   )
-			#set( $p = $startPage + $i )
-			#if ( $p <= $numberOfPages )
-				#if( $i > 0 )
-					<span class="seperator">|</span>
-				#end
-				#if( $p != $currentPage )
-					<a href="#" class="page" title="Page $p" onclick="searchDataElementGroupPaging(${p}, ${pageSize});">$p</a>
-				#else
-					<span class="page" title="Page $p">$p</span>
-				#end
-			#end
-		#end
-		
-		#if ( $currentPage < $numberOfPages )
-			#set ( $next = $currentPage + 1 )
-			<a href="#" class="next" title="Next" onclick="searchDataElementGroupPaging(${next}, ${pageSize});">&raquo;</a>
-			<a href="#" class="last" title="Last" onclick="searchDataElementGroupPaging(${numberOfPages}, ${pageSize});">&raquo;&raquo;</a>
-		#else
-			<span class="next" title="Next">&raquo; </span>
-			<span class="last" title="Last">&raquo;&raquo;</span>
-		#end
-		</div>
-		
-		</td>
-		</tr>
-		</table>
-	#end
-</div>
-
+#searchingPagination( "searchDataElementGroupPaging" )
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementSearch.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementSearch.vm	2010-10-28 18:21:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementSearch.vm	2010-11-07 12:01:24 +0000
@@ -36,81 +36,4 @@
 	</tbody>
 </table>
 <p></p>
-  		<div class="paging-container">
-	
-	#set ( $baseLink 		= $paging.baseLink )
-	#set ( $pageSize 		= $paging.pageSize )
-	#set ( $currentPage 	= $paging.currentPage )
-	#set ( $startPage 		= $paging.startPage )
-	#set ( $numberOfPages	= $paging.numberOfPages )
-	
-	<input type="hidden" id="baseLink" value="$!baseLink"/>
-	<input type="hidden" id="currentPage" value="$!currentPage"/>
-	#if ( $numberOfPages > 0 )
-		<table style="background-color: #ebf0f6;" width='100%'>
-				<tr>
-					<td>
-						<span>$i18n.getString("no_of_pages"):</span> <span id="numberOfPage">$numberOfPages</span>
-					</td>
-					<td>
-						<span >$i18n.getString("size_of_page"):</span>
-					
-						<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onchange="changePageSizeSearch();">
-					</td>
-					<td>
-						<span >$i18n.getString("jump_to_page"):</span>
-					
-						<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onchange="jumpToPageSearch();">
-					</td>
-					<td>
-						<input type="button" id="submitButton" value="$i18n.getString('go')" onclick="jumpToPageSearch();">
-					</td>
-				
-		</tr>
-		
-		<tr>
-			<td colspan='4' ><hr/></td>
-		</tr>
-		
-		<tr>
-		<td colspan='4'>
-		<div class="paging">
-		#if ($currentPage > 1)
-			#set ( $prev = $currentPage - 1 )
-			<a href="#" class="first" title="First" onclick="searchDataElementNamePaging(1, ${pageSize});">&laquo;&laquo;</a>
-			<a href="#" class="prev" title="Previous" onclick="searchDataElementNamePaging(${prev}, ${pageSize});">&laquo;</a>
-		#else
-			<span class="first" title="First">&laquo;&laquo;</span>
-			<span class="prev" title="Previous">&laquo;</span>
-		#end
-		
-		#foreach( $i in [0..4]   )
-			#set( $p = $startPage + $i )
-			#if ( $p <= $numberOfPages )
-				#if( $i > 0 )
-					<span class="seperator">|</span>
-				#end
-				#if( $p != $currentPage )
-					<a href="#" class="page" title="Page $p" onclick="searchDataElementNamePaging(${p}, ${pageSize});">$p</a>
-				#else
-					<span class="page" title="Page $p">$p</span>
-				#end
-			#end
-		#end
-		
-		#if ( $currentPage < $numberOfPages )
-			#set ( $next = $currentPage + 1 )
-			<a href="#" class="next" title="Next" onclick="searchDataElementNamePaging(${next}, ${pageSize});">&raquo;</a>
-			<a href="#" class="last" title="Last" onclick="searchDataElementNamePaging(${numberOfPages}, ${pageSize});">&raquo;&raquo;</a>
-		#else
-			<span class="next" title="Next">&raquo; </span>
-			<span class="last" title="Last">&raquo;&raquo;</span>
-		#end
-		</div>
-		
-		</td>
-		</tr>
-		</table>
-	#end
-	
-</div>
+#searchingPagination( "searchDataElementNamePagination" )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2010-11-07 12:01:24 +0000
@@ -347,7 +347,7 @@
     }
 }
 
-function searchDataElementNamePaging(currentPage, pageSize) 
+function searchDataElementNamePagination(currentPage, pageSize) 
 {
 	
 	var params = 'key=' + getFieldValue( 'key' );
@@ -372,13 +372,13 @@
 function changePageSizeSearch()
 {
     var pageSize = jQuery("#sizeOfPage").val();
-    searchDataElementNamePaging(1, pageSize);
+    searchDataElementNamePagination(1, pageSize);
 }
 
 function jumpToPageSearch()
 {
     var pageSize = jQuery("#sizeOfPage").val();
     var currentPage = jQuery("#jumpToPage").val();
-    searchDataElementNamePaging(currentPage, pageSize);
+    searchDataElementNamePagination(currentPage, pageSize);
 }