← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2174: Centralized the paging code

 

------------------------------------------------------------
revno: 2174
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-11-25 22:34:02 +0100
message:
  Centralized the paging code
removed:
  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
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm
  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/dataElementGroup.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/paging/paging.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2010-11-25 21:34:02 +0000
@@ -9,68 +9,63 @@
 	<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> $numberOfPages
-					</td>
-					<td>
-						<span >$i18n.getString("size_of_page"):</span>
-					
-						<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onchange="changePageSize('$baseLink');">
-					</td>
-					<td>
-						<span >$i18n.getString("jump_to_page"):</span>
-					
-						<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onchange="jumpToPage('$baseLink');">
-					</td>
-					<td>
-						<input type="button" id="submitButton" value="$i18n.getString('go')" onclick="jumpToPage('$baseLink');">
-					</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="${baseLink}currentPage=1&pageSize=${pageSize}" class="first" title="First">&laquo;&laquo;</a>
-			<a href="${baseLink}currentPage=${prev}&pageSize=${pageSize}" class="prev" title="Previous">&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="${baseLink}currentPage=${p}&pageSize=${pageSize}" class="page" title="Page $p">$p</a>
-				#else
-					<span class="page" title="Page $p">$p</span>
-				#end
-			#end
-		#end
-		
-		#if ( $currentPage < $numberOfPages )
-			#set ( $next = $currentPage + 1 )
-			<a href="${baseLink}currentPage=${next}&pageSize=${pageSize}" class="next" title="Next">&raquo;</a>
-			<a href="${baseLink}currentPage=${numberOfPages}&pageSize=${pageSize}" class="last" title="Last">&raquo;&raquo;</a>
-		#else
-			<span class="next" title="Next">&raquo; </span>
-			<span class="last" title="Last">&raquo;&raquo;</span>
-		#end
-		</div>
-		
-		</td>
-		</tr>
+			<tr>
+				<td>
+					<span>$i18n.getString("no_of_pages"):</span> $numberOfPages
+				</td>
+				<td>
+					<span>$i18n.getString("size_of_page"):</span>
+					<input type="text" id="sizeOfPage" value="$!pageSize" style="width:50px" onchange="changePageSize('$baseLink');">
+				</td>
+				<td>
+					<span>$i18n.getString("jump_to_page"):</span>					
+					<input type="text" id="jumpToPage" value="$!currentPage" style="width:50px" onchange="jumpToPage('$baseLink');">
+				</td>
+				<td>
+					<input type="button" id="submitButton" value="$i18n.getString('go')" onclick="jumpToPage('$baseLink');">
+				</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="${baseLink}currentPage=1&pageSize=${pageSize}" class="first" title="First">&laquo;&laquo;</a>
+				<a href="${baseLink}currentPage=${prev}&pageSize=${pageSize}" class="prev" title="Previous">&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="${baseLink}currentPage=${p}&pageSize=${pageSize}" class="page" title="Page $p">$p</a>
+					#else
+						<span class="page" title="Page $p">$p</span>
+					#end
+				#end
+			#end
+			
+			#if ( $currentPage < $numberOfPages )
+				#set ( $next = $currentPage + 1 )
+				<a href="${baseLink}currentPage=${next}&pageSize=${pageSize}" class="next" title="Next">&raquo;</a>
+				<a href="${baseLink}currentPage=${numberOfPages}&pageSize=${pageSize}" class="last" title="Last">&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>
\ No newline at end of file

=== 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-11-07 12:01:24 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2010-11-25 21:34:02 +0000
@@ -107,91 +107,22 @@
 #end
 
 #macro( organisationUnitSelectionTree $cleanAll $multipleSelectionAllowed $requied )
-	#if( $multipleSelectionAllowed ==true )
-		#parse( "/dhis-web-commons/oust/selectionTreeMultipleSelect.vm" )		
-	#else
-		#parse( "/dhis-web-commons/oust/selectionTreeSingleSelect.vm" )
-	#end	
+#if( $multipleSelectionAllowed ==true )
+	#parse( "/dhis-web-commons/oust/selectionTreeMultipleSelect.vm" )		
+#else
+	#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
+#macro( filterDiv $action )
+$i18n.getString( "filter_by_name" ):	
+<div style="inline">
+	<input type="text" id="key" value="$!{key}">
+	<input type="button" value="$i18n.getString( 'filter' )" onclick="filterInternal()"/>	
+	<input type="button" value="$i18n.getString( 'clear' )" onclick="clearInternal()"/>		
 </div>
+<script>
+function filterInternal() { window.location.href="${action}.action?key=" + $( '#key' ).val(); }
+function clearInternal() { window.location.href="${action}.action"; }
+</script>
 #end
-
-

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2010-11-22 14:00:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties	2010-11-25 21:34:02 +0000
@@ -382,15 +382,17 @@
 move_to_top         = Move to top
 move_to_bottom      = Move to bottom
 
-
 #-- Paging messages  ----------------------------------------------------------------------#
 
 no_of_pages 	= No. of pages
 size_of_page 	= Size of page
 jump_to_page 	= Jump to page
 go				= Go
+filter_by_name	= Filter by name
+filter			= Filter
+clear			= Clear
 
-delete_success = Delete object successfully.
+delete_success = Object deleted
 process = Processing...
 
 #-- Export PDF messages  ----------------------------------------------------------------------#

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java	2010-11-25 21:34:02 +0000
@@ -27,20 +27,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
-import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.datadictionary.DataDictionaryService;
 import org.hisp.dhis.datadictionary.comparator.DataDictionaryNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator;
 import org.hisp.dhis.options.datadictionary.DataDictionaryModeManager;
 import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
 import org.hisp.dhis.paging.ActionPagingSupport;
@@ -111,13 +109,6 @@
         return dataElements;
     }
 
-    private List<DataElementGroup> dataElementGroups;
-
-    public List<DataElementGroup> getDataElementGroups()
-    {
-        return dataElementGroups;
-    }
-
     private List<DataDictionary> dataDictionaries;
 
     public List<DataDictionary> getDataDictionaries()
@@ -141,177 +132,72 @@
         this.dataDictionaryId = dataDictionaryId;
     }
 
-    private Integer dataElementGroupId;
-
-    public void setDataElementGroupId( Integer dataElementGroupId )
-    {
-        this.dataElementGroupId = dataElementGroupId;
-    }
-
-    public Integer getDataElementGroupId()
-    {
-        return dataElementGroupId;
-    }
-    
     private String key;
+    
+    public String getKey()
+    {
+        return key;
+    }
 
     public void setKey( String key )
     {
         this.key = key;
     }
-    
-    public String getKey()
-    {
-        return key;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @SuppressWarnings( "unchecked" )
+
+    // -------------------------------------------------------------------------
+    // Action implemantation
+    // -------------------------------------------------------------------------
+
     public String execute()
     {
-        prepareDataDictionary();
-
-        // ---------------------------------------------------------------------
-        // Criteria
-        // ---------------------------------------------------------------------
-
-        List<DataElement> allResult;
-        
-        if ( dataDictionaryId != null && dataElementGroupId == null )
-        {
-            allResult = new ArrayList<DataElement>( dataDictionaryService.getDataElementsByDictionaryId( dataDictionaryId ) );
-
-            Collections.sort( allResult, dataElementComparator );
-            this.paging = createPaging( allResult.size() );
-            dataElements = getBlockElement( allResult, paging.getStartPos(), paging.getPageSize() );
-        }
-        else if ( dataDictionaryId == null && dataElementGroupId != null )
-        {
-            allResult = new ArrayList<DataElement>( dataElementService.getDataElementsByGroupId( dataElementGroupId ) );
-            
-            Collections.sort( allResult, dataElementComparator );
-            this.paging = createPaging( allResult.size() );
-            dataElements = getBlockElement( allResult, paging.getStartPos(), paging.getPageSize() );
-        }
-        else if ( dataDictionaryId != null && dataElementGroupId != null )
-        {
-            Collection<DataElement> dictionary = dataDictionaryService.getDataElementsByDictionaryId( dataDictionaryId );
-
-            Collection<DataElement> members = dataElementService.getDataElementsByGroupId( dataElementGroupId );
-            
-            allResult = new ArrayList<DataElement>( CollectionUtils.intersection( dictionary, members ) );
-
-            Collections.sort( allResult, dataElementComparator );
-            this.paging = createPaging( allResult.size() );
-            dataElements = getBlockElement( allResult, paging.getStartPos(), paging.getPageSize() );
-        }
-        else
-        {
-            this.paging = createPaging( dataElementService.getDataElementCount() );
-
-            dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsBetween( paging.getStartPos(), paging.getPageSize() ) );
-        }
-
-        displayPropertyHandler.handle( dataElements );
-        
-        return SUCCESS;
-    }
-    
-    public String searchDataElementByName()
-    {
-        
-        prepareDataDictionary();
-        
-        // ---------------------------------------------------------------------
-        // Criteria
-        // ---------------------------------------------------------------------
-        if ( key.isEmpty() )
-        {
-            return INPUT;
-        }
-
-        
-        List<DataElement> allResult;
-        
-        if ( dataDictionaryId != null && dataDictionaryId != -1 && (dataElementGroupId == null || dataElementGroupId == -1 ) )
-        {
-            allResult = new ArrayList<DataElement>( dataDictionaryService.getDataElementsByDictionaryId( dataDictionaryId ) );
-            allResult = searchByDataElementName(allResult, key);
-            Collections.sort( allResult, dataElementComparator );
-            this.paging = createPaging( allResult.size() );
-            dataElements = getBlockElement( allResult, paging.getStartPos(), paging.getPageSize() );
-        }
-        else if ( (dataDictionaryId == null || dataDictionaryId == -1) && dataElementGroupId != null  && dataElementGroupId != -1 )
-        {
-            allResult = new ArrayList<DataElement>( dataElementService.getDataElementsByGroupId( dataElementGroupId ) );
-            allResult = searchByDataElementName(allResult, key);
-            Collections.sort( allResult, dataElementComparator );
-            this.paging = createPaging( allResult.size() );
-            dataElements = getBlockElement( allResult, paging.getStartPos(), paging.getPageSize() );
-        }
-        else if ( dataDictionaryId != null && dataElementGroupId != null && dataDictionaryId != -1 && dataElementGroupId != -1 )
-        {
-            Collection<DataElement> dictionary = dataDictionaryService.getDataElementsByDictionaryId( dataDictionaryId );
-
-            Collection<DataElement> members = dataElementService.getDataElementsByGroupId( dataElementGroupId );
-            
-            allResult = new ArrayList<DataElement>( CollectionUtils.intersection( dictionary, members ) );
-            allResult = searchByDataElementName(allResult, key);
-            Collections.sort( allResult, dataElementComparator );
-            this.paging = createPaging( allResult.size() );
-            dataElements = getBlockElement( allResult, paging.getStartPos(), paging.getPageSize() );
-        }
-        else
-        {
-            this.paging = createPaging( dataElementService.getDataElementCountByName( key ) );
-            dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsBetweenByName( key, this.paging.getStartPos(), this.paging.getPageSize() ) );
-        }
-
-        displayPropertyHandler.handle( dataElements );
-        return SUCCESS;
-    }
-
-    private void prepareDataDictionary()
-    {
         if ( dataDictionaryId == null ) // None, get current data dictionary
         {
             dataDictionaryId = dataDictionaryModeManager.getCurrentDataDictionary();
         }
-        else if ( dataDictionaryId == -1 ) // All, reset current data
-        // dictionary
+        else if ( dataDictionaryId == -1 ) // All, reset current data dictionary
         {
             dataDictionaryModeManager.setCurrentDataDictionary( null );
 
             dataDictionaryId = null;
         }
-        else
-        // Specified, set current data dictionary
+        else  // Specified, set current data dictionary
         {
             dataDictionaryModeManager.setCurrentDataDictionary( dataDictionaryId );
         }
 
-        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
-
-        Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
-
         dataDictionaries = new ArrayList<DataDictionary>( dataDictionaryService.getAllDataDictionaries() );
 
         Collections.sort( dataDictionaries, new DataDictionaryNameComparator() );
+
+        // ---------------------------------------------------------------------
+        // Criteria
+        // ---------------------------------------------------------------------
+
+        if ( isNotBlank( key ) ) // Filter on key only if set
+        {
+            this.paging = createPaging( dataElementService.getDataElementCountByName( key ) );
+            
+            dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
+        }
+        else if ( dataDictionaryId != null )
+        {
+            dataElements = new ArrayList<DataElement>( dataDictionaryService.getDataElementsByDictionaryId( dataDictionaryId ) );
+            
+            this.paging = createPaging( dataElements.size() );
+            
+            dataElements = getBlockElement( dataElements, paging.getStartPage(), paging.getEndPos() );
+        }
+        else
+        {
+            this.paging = createPaging( dataElementService.getDataElementCount() );
+            
+            dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsBetween( paging.getStartPos(), paging.getPageSize() ) );
+        }
+
+        Collections.sort( dataElements, dataElementComparator );
+
+        displayPropertyHandler.handle( dataElements );
+
+        return SUCCESS;
     }
-
-    private List<DataElement> searchByDataElementName( List<DataElement> dataElementList, String key )
-    {
-        List<DataElement> result = new ArrayList<DataElement>();
-        for ( DataElement eachElement : dataElementList )
-        {
-            if ( eachElement.getName().contains( key.trim() ) )
-            {
-                result.add( eachElement );
-            }
-        }
-        return result;
-    }    
-}
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java	2010-11-25 21:34:02 +0000
@@ -34,6 +34,8 @@
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.paging.ActionPagingSupport;
 
+import static org.apache.commons.lang.StringUtils.*;
+
 /**
  * @author Torgeir Lorange Ostby
  * @version $Id: GetDataElementGroupListAction.java 2869 2007-02-20 14:26:09Z andegje $
@@ -53,54 +55,51 @@
     }
 
     // -------------------------------------------------------------------------
-    // Input and Output
+    // Input
     // -------------------------------------------------------------------------
 
-    private List<DataElementGroup> dataElementGroups;
-
-    public List<DataElementGroup> getDataElementGroups()
-    {
-        return dataElementGroups;
-    }
-    
     private String key;
-    
+        
     public String getKey()
     {
         return key;
     }
-    
+
     public void setKey( String key )
     {
         this.key = key;
     }
 
     // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<DataElementGroup> dataElementGroups;
+
+    public List<DataElementGroup> getDataElementGroups()
+    {
+        return dataElementGroups;
+    }
+    
+    // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
 
     public String execute()
     {
-        this.paging = createPaging( dataElementService.getDataElementGroupCount() );
-
-        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getDataElementGroupsBetween( paging.getStartPos(), paging.getPageSize() ) );
-
-        return SUCCESS;
-    }
-    
-    public String searchByName()
-    {
-        if ( key != null && !key.trim().isEmpty() ) 
-        {   
+        if ( isNotBlank( key) )
+        {
             this.paging = createPaging( dataElementService.getDataElementGroupCountByName( key ) );
             
             dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getDataElementGroupsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
-            
-            return SUCCESS;
         }
         else
         {
-            return execute();
+            this.paging = createPaging( dataElementService.getDataElementGroupCount() );
+
+            dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getDataElementGroupsBetween( paging.getStartPos(), paging.getPageSize() ) );
         }
+
+        return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/struts.xml	2010-11-25 21:34:02 +0000
@@ -26,12 +26,6 @@
 			<param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
 		</action>
 		
-		<action name="searchDataElement"
-			class="org.hisp.dhis.dd.action.dataelement.GetDataElementListAction" method="searchDataElementByName">
-			<result name="success" type="velocity">
-				/dhis-web-maintenance-datadictionary/dataElementSearch.vm</result>
-		</action>
-
 		<action name="showSortDataElementForm"
 			class="org.hisp.dhis.dd.action.dataelement.GetDataElementListSortOrderAction">
 			<result name="success" type="velocity">/main.vm</result>
@@ -199,12 +193,6 @@
 			<param name="stylesheets">../dhis-web-commons/paging/paging.css</param>
 		</action>
 
-		<action name="searchDataElementGroup"
-			class="org.hisp.dhis.dd.action.dataelementgroup.GetDataElementGroupListAction" method="searchByName">
-			<result name="success" type="velocity">
-				/dhis-web-maintenance-datadictionary/dataElementGroupSearch.vm</result>
-		</action>
-
 		<action name="removeDataElementGroup"
 			class="org.hisp.dhis.dd.action.dataelementgroup.RemoveDataElementGroupAction">
 			<result name="success" type="velocity-json">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-11-25 21:34:02 +0000
@@ -6,16 +6,11 @@
 		<td style="vertical-align:top">
 			<table width="100%">
 				<tr valign="bottom">
-					<td>$i18n.getString( "filter_by_name" ): 
-					<form style="display:inline" action="none" onsubmit="return false">
-						<div style="inline"><input type="text" id='key'>
-						<input type="button" value="$i18n.getString( "go" )" onclick="searchDataElementName();" />
-						</div>
-					</form></td>
+					<td>#filterDiv( "dataElement" )</td>
 					<td>
 					   $i18n.getString( "select_data_dictionary" ):
 					   <div style="inline">
-					       <select id="dataDictionaryList" name="dataDictionaryList" onchange="criteriaChanged()" style="min-width:140px">
+					       <select id="dataDictionaryList" name="dataDictionaryList" onchange="criteriaChanged()" style="min-width:180px">
 					           <option value="-1">[ $i18n.getString( "all" ) ]</option>
 					           #foreach( $dictionary in $dataDictionaries )
 					           <option value="$dictionary.id" #if ( $dictionary.id == $dataDictionaryId ) selected="selected"#end>$dictionary.name</option>
@@ -23,17 +18,6 @@
 				            </select>
 						</div>
 					</td>
-					<td>
-						$i18n.getString( "filter_by_group_view_all" ):
-						<div style="inline">
-							<select id="dataElementGroupList" name="dataElementGroupList" onchange="criteriaChanged()" style="min-width:200px">
-								<option value="null">[ $i18n.getString( "all" ) ]</option>
-								#foreach( $dataElementGroup in $dataElementGroups )
-								<option value="$dataElementGroup.id" #if ( $dataElementGroup.id == $dataElementGroupId ) selected="selected"#end>$dataElementGroup.name</option>
-								#end
-							</select>
-						</div>
-					</td>
 					<td style="text-align:right">
 						<input type="button" value="$i18n.getString( 'get_pdf' )" onclick="exportPdfByType( 'dataelement' );" style="width:80px"/>
                         <input type="button" value="$i18n.getString( 'sort' )" onclick="window.location.href='showSortDataElementForm.action'" style="width:80px"/>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm	2010-11-25 21:34:02 +0000
@@ -6,14 +6,7 @@
 		<td style="vertical-align:top">
 			<table width="100%">
 				<tr>
-					<td>$i18n.getString( "filter_by_name" ): 
-					<form style="display:inline" action="none" onsubmit="return false">
-						<div style="inline">
-							<input type="text" id="key" name="id"/>
-							<input type="button" value="$i18n.getString( 'go' )" id="searchButton" onclick="searchDataElementGroup()" />
-						</div>
-					</form>
-					</td>
+					<td>#filterDiv( "dataElementGroup" )</td>
 					<td style="text-align:right"><input type="button" value="$i18n.getString( 'add_new' )" onclick="window.location.href='showAddDataElementGroupForm.action'" style="width:80px"/></td>
 				</tr>
 			</table>

=== removed 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-07 12:01:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroupSearch.vm	1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
-<script type="text/javascript" src="../main.js"></script>
-
-
-
-<table class="listTable" id="dataElementGroupList">
-	<col/>
-	<col width="20"/>
-	<col width="20"/>
-	<col width="20"/>
-	<col width="20"/>
-	<thead>				
-		<tr>
-			<th>$i18n.getString( "name" )</th>
-			<th colspan="4" class="{sorter: false}">$i18n.getString( "operations" )</th>
-		</tr>
-	</thead>
-	<tbody id="list">
-	#foreach( $dataElementGroup in $dataElementGroups )
-	<tr id="tr${dataElementGroup.id}">
-		<td onclick="showDataElementGroupDetails( $dataElementGroup.id )">$encoder.htmlEncode( $dataElementGroup.name )</td>
-		<td style="text-align:center"><a href="showUpdateDataElementGroupForm.action?id=$dataElementGroup.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a></td>
-		<td style="text-align:center"><a href="javascript:translate( 'DataElementGroup', '$dataElementGroup.id' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a></td>
-		<td style="text-align:center"><a href="javascript:removeDataElementGroup( $dataElementGroup.id, '$encoder.jsEncode( $dataElementGroup.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a></td>
-		<td style="text-align:center"><a href="javascript:showDataElementGroupDetails( $dataElementGroup.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a></td>
-	</tr>
-	#end
-	</tbody>
-</table>
-<p></p>
-#searchingPagination( "searchDataElementGroupPaging" )
\ No newline at end of file

=== removed 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-11-07 12:01:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementSearch.vm	1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
-<script type="text/javascript" src="../main.js"></script>
-<table class="listTable" id="dataElementList">
-	<col/>
-    <col/>
-    <col/>
-	<col width="20"/>
-	<col width="20"/>
-	<col width="20"/>
-    <col width="20"/>
-    #if ( $forumIntegration )
-    <col width="20"/>
-    #end
-    <thead>				
-		<tr>
-			<th colspan="3" >$i18n.getString( "name" )</th>
-			<th colspan="5" class="{sorter: false}">$i18n.getString( "operations" )</th>
-		</tr>
-	</thead>
-	<tbody id="list">
-	#foreach( $dataElement in $dataElements )
-	<tr id="tr${dataElement.id}">
-		<td colspan="3" onclick="showDataElementDetails( $dataElement.id )">$encoder.htmlEncode( $dataElement.name )</td>
-		#if ( $dataDictionaryMode == "extended" )
-		<td style="text-align:center"><a href="showUpdateExtendedDataElementForm.action?id=$dataElement.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a></td>
-		#else
-		<td style="text-align:center"><a href="showUpdateDataElementForm.action?id=$dataElement.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a></td>
-		#end
-		<td style="text-align:center"><a href="javascript:translate( 'DataElement', '$dataElement.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a></td>
-		<td style="text-align:center"><a href="javascript:removeDataElement( $dataElement.id, '$encoder.jsEncode( $dataElement.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a></td>
-		<td style="text-align:center"><a href="javascript:showDataElementDetails( $dataElement.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a></td>
-		#if ( $forumIntegration )
-		<td style="text-align:center"><a href="$dataElement.url" title="$i18n.getString( 'forum' )" target="_blank"><img src="../images/forum.png" alt="$i18n.getString( 'forum' )"/></a></td>
-		#end
-	</tr>
-	#end
-	</tbody>
-</table>
-<p></p>
-#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-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2010-11-25 21:34:02 +0000
@@ -33,10 +33,9 @@
 
 function criteriaChanged()
 {
-    var dataElementGroupId = getListValue( "dataElementGroupList" );
     var dataDictionaryId = getListValue( "dataDictionaryList" );
 	
-    var url = "dataElement.action?&dataDictionaryId=" + dataDictionaryId + "&dataElementGroupId=" + dataElementGroupId;
+    var url = "dataElement.action?&dataDictionaryId=" + dataDictionaryId;
 	
     window.location.href = url;
 }
@@ -322,63 +321,3 @@
 		dataElementValidators.append('<option value="' + item.value + '" selected="selected">' + item.value + '</option>');	
 	});
 }
-
-
-// -----------------------------------------------------------------------------
-// Search DataElement Name
-// -----------------------------------------------------------------------------
-
-function searchDataElementName(){
-	
-	var params = 'key=' + getFieldValue( 'key' );
-		params += '&dataDictionaryId=' + getFieldValue( 'dataDictionaryList' );
-		params += '&dataElementGroupId=' + getFieldValue( 'dataElementGroupList' );
-    
-    var url = 'searchDataElement.action?' + params;
-    
-    if( getFieldValue( 'key' ) != null && getFieldValue( 'key' ) != '' ) 
-    {
-    	$( '#content' ).load( url, null, unLockScreen );
-    	lockScreen();
-    }
-    else 
-    {
-    	window.location.href='dataElement.action?' + params;
-    }
-}
-
-function searchDataElementNamePagination(currentPage, pageSize) 
-{
-	
-	var params = 'key=' + getFieldValue( 'key' );
-		params += '&dataDictionaryId=' + getFieldValue( 'dataDictionaryList' );
-		params += '&dataElementGroupId=' + getFieldValue( 'dataElementGroupList' );
-		params += '&currentPage=' + currentPage;
-		params += '&pageSize=' + pageSize;
-
-    var url = 'searchDataElement.action?' + params;
-    
-    if( getFieldValue( 'key' ) != null && getFieldValue( 'key' ) != '' ) 
-    {
-    	$( '#content' ).load( url, null, unLockScreen );
-    	lockScreen();
-    }
-    else 
-    {
-    	window.location.href='dataElement.action?' + params;
-    }
-}
-
-function changePageSizeSearch()
-{
-    var pageSize = jQuery("#sizeOfPage").val();
-    searchDataElementNamePagination(1, pageSize);
-}
-
-function jumpToPageSearch()
-{
-    var pageSize = jQuery("#sizeOfPage").val();
-    var currentPage = jQuery("#jumpToPage").val();
-    searchDataElementNamePagination(currentPage, pageSize);
-}
-

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js	2010-11-25 21:34:02 +0000
@@ -36,58 +36,3 @@
 {
     removeItem( dataElementGroupId, dataElementGroupName, i18n_confirm_delete, "removeDataElementGroup.action" );
 }
-
-// -----------------------------------------------------------------------------
-// Search data element group
-// -----------------------------------------------------------------------------
-
-function searchDataElementGroup()
-{
-	var key = $( '#key' ).val();
-	
-    if ( key != null && key != '' ) 
-    {
-    	var url = 'searchDataElementGroup.action?key=' + key;
-    	
-    	$( '#content' ).load( url, unLockScreen );
-    	
-    	lockScreen();
-    }
-    else 
-    {
-    	window.location.href='dataElementGroup.action?' + params;
-    }
-}
-
-function searchDataElementGroupPaging( currentPage, pageSize ) 
-{
-	var params = 'key=' + getFieldValue( 'key' );
-		params += '&currentPage=' + currentPage;
-		params += '&pageSize=' + pageSize;
-
-    var url = 'searchDataElementGroup.action?' + params;
-    
-    if ( getFieldValue( 'key' ) != null && getFieldValue( 'key' ) != '' ) 
-    {
-    	$( '#content' ).load( url, null, unLockScreen );
-    	
-    	lockScreen();
-    }
-    else 
-    {
-    	window.location.href='dataElementGroup.action?' + params;
-    }
-}
-
-function changePageSizeSearch()
-{
-    var pageSize = $( '#sizeOfPage' ).val();
-    searchDataElementGroupPaging( 1, pageSize );
-}
-
-function jumpToPageSearch()
-{
-    var pageSize = $( '#sizeOfPage' ).val();
-    var currentPage = $( '#jumpToPage' ).val();
-    searchDataElementGroupPaging( currentPage, pageSize );
-}