← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3741: added paging for indicator groups

 

------------------------------------------------------------
revno: 3741
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-05-25 15:17:19 +0200
message:
  added paging for indicator groups
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.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-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java	2011-05-24 20:20:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java	2011-05-25 13:17:19 +0000
@@ -36,6 +36,8 @@
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator;
 import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.system.filter.DataElementGroupWithoutGroupSetFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.system.util.IdentifiableObjectUtils;
 
 /**
@@ -67,6 +69,13 @@
         this.key = key;
     }
 
+    public boolean filterNoGroupSet;
+
+    public void setFilterNoGroupSet( boolean filterNoGroupSet )
+    {
+        this.filterNoGroupSet = filterNoGroupSet;
+    }
+
     private List<Integer> removeDataElementGroups = new ArrayList<Integer>();
 
     public void setRemoveDataElementGroups( String removeDataElementGroups )
@@ -98,6 +107,11 @@
     {
         dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
 
+        if ( filterNoGroupSet )
+        {
+            FilterUtils.filter( dataElementGroups, new DataElementGroupWithoutGroupSetFilter() );
+        }
+
         if ( removeDataElementGroups.size() > 0 )
         {
             for ( Integer id : removeDataElementGroups )

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java	2011-05-24 09:42:48 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java	2011-05-25 13:17:19 +0000
@@ -28,13 +28,17 @@
  */
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
 import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.system.filter.IndicatorGroupWIthoutGroupSetFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.system.util.IdentifiableObjectUtils;
 
 /**
@@ -65,6 +69,28 @@
         this.key = key;
     }
 
+    public boolean filterNoGroupSet = false;
+
+    public void setFilterNoGroupSet( boolean filterNoGroupSet )
+    {
+        this.filterNoGroupSet = filterNoGroupSet;
+    }
+
+    private List<Integer> removeIndicatorGroups = new ArrayList<Integer>();
+
+    public void setRemoveIndicatorGroups( String removeIndicatorGroups )
+    {
+        if ( removeIndicatorGroups.length() > 0 )
+        {
+            List<String> stringList = Arrays.asList( removeIndicatorGroups.split( "," ) );
+
+            for ( String s : stringList )
+            {
+                this.removeIndicatorGroups.add( Integer.parseInt( s ) );
+            }
+        }
+    }
+
     private List<IndicatorGroup> indicatorGroups;
 
     public List<IndicatorGroup> getIndicatorGroups()
@@ -80,6 +106,20 @@
     {
         indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups() );
 
+        if ( filterNoGroupSet )
+        {
+            FilterUtils.filter( indicatorGroups, new IndicatorGroupWIthoutGroupSetFilter() );
+        }
+
+        if ( removeIndicatorGroups.size() > 0 )
+        {
+            for ( Integer id : removeIndicatorGroups )
+            {
+                IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( id );
+                indicatorGroups.remove( indicatorGroup );
+            }
+        }
+
         if ( key != null )
         {
             indicatorGroups = IdentifiableObjectUtils.filterNameByKey( indicatorGroups, key, true );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm	2011-05-24 20:20:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm	2011-05-25 13:17:19 +0000
@@ -13,6 +13,9 @@
 				option.attr( "value", item.id );
 
 				return option;
+			},
+			params: {
+				filterNoGroupSet: true
 			}
 		});
 	});
@@ -52,11 +55,11 @@
 		<td>
 			<select id="availableDataElementGroupsList" name="availableDataElementGroupsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
 		</td>
-		
+
         <td style="text-align:center">          
-        	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'availableDataElementsList' );"/><br/>
+  	     	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'availableDataElementGroupsList' );"/><br/>
             <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'groupMembers' );"/><br/>
-			<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisPaging_moveAll( 'availableDataElementsList' );"/><br/>
+			<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisPaging_moveAll( 'availableDataElementGroupsList' );"/><br/>
 			<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisPaging_moveAll( 'groupMembers' );"/>
         </td>
     

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm	2011-03-31 13:13:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addIndicatorGroupSet.vm	2011-05-25 13:17:19 +0000
@@ -1,4 +1,25 @@
 <script type="text/javascript" src="javascript/addIndicatorGroupSet.js"></script>
+<script>
+	jQuery(function() {
+		jQuery("#availableIndicatorGroupsList").dblclick(dhisPaging_availableList_dblclick("availableIndicatorGroupsList", "groupMembers", "removeIndicatorGroups"));
+		jQuery("#groupMembers").dblclick(dhisPaging_selectedList_dblclick("groupMembers", "availableIndicatorGroupsList", "removeIndicatorGroups"));
+
+		jQuery("#availableIndicatorGroupsList").dhisPaging({
+			source: "../dhis-web-commons-ajax-json/getIndicatorGroups.action",
+			iterator: "indicatorGroups",
+			handler: function(item) {
+				var option = jQuery("<option />");
+				option.text( item.name );
+				option.attr( "value", item.id );
+
+				return option;
+			},
+			params: {
+				filterNoGroupSet: true
+			}
+		});
+	});
+</script>
 
 <h3>$i18n.getString( "add_indicatorgroupset" )</h3>
 
@@ -18,43 +39,39 @@
 </table>
 
 <table>
+    <col style="width: 450px"/>
+    <col/>
+    <col/>
+
 	<tr>
-		<th>$i18n.getString( "available_indicatorgroup" )</th><td></td><th>$i18n.getString( "group_members" )
-		<select id="memberValidator" class="{validate:{required:true}}" style="display:none"/></th>
-	</tr>
-	<tr>		
-		<td><input type="text" id="availableIndicatorGroupsFilter" onkeyup="filterList( this.value, 'availableIndicatorGroups' )" style="width:25em"/></td>
-		<td style="text-align:center">&lt; $i18n.getString( "filters" ) &gt;</td>
-		<td><input type="text" id="groupMembersFilter" onkeyup="filterList( this.value, 'groupMembers' )" style="width:25em"/></td>
-	</tr>
+		<th>$i18n.getString( "available_indicatorgroup" )</th>
+		<th></th>
+		<th>$i18n.getString( "group_members" )
+			<select id="memberValidator" class="{validate:{required:true}}" style="display:none"/>
+		</th>
+	</tr>
+
 	<tr>
 		<td>
-			<select id="availableIndicatorGroups" size="2" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById( 'availableIndicatorGroups', 'groupMembers' )">
-				#foreach( $indicatorGroup in $availableGroups )
-					<option value="$indicatorGroup.id">$encoder.htmlEncode( $indicatorGroup.name )</option>
-				#end
-			</select>
+			<select id="availableIndicatorGroupsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
 		</td>
-		
+
         <td style="text-align:center">          
-            <input type="button" value="&gt;" title="$i18n.getString('move_selected')" style="width:50px" onclick="moveSelectedById( 'availableIndicatorGroups', 'groupMembers' )"/><br/>
-            <input type="button" value="&lt;" title="$i18n.getString('remove_selected')" style="width:50px" onclick="moveSelectedById( 'groupMembers', 'availableIndicatorGroups' )"/><br/>
-            <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="moveAllById( 'availableIndicatorGroups', 'groupMembers' )"/><br/>
-            <input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'groupMembers', 'availableIndicatorGroups' )"/>
+        	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'availableIndicatorGroupsList' );"/><br/>
+            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'groupMembers' );"/><br/>
+			<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisPaging_moveAll( 'availableIndicatorGroupsList' );"/><br/>
+			<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisPaging_moveAll( 'groupMembers' );"/>
         </td>
-    
-		<td>
-			<select id="groupMembers" name="groupMembers" size="2" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById( 'groupMembers', 'availableIndicatorGroups' )">				
-			</select>
-		</td>
-		<td>
-			<a href="javascript:moveUpSelectedOption( 'groupMembers')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" alt="$i18n.getString( 'move_up' )"></a>
-			<br/>
-			<a href="javascript:moveDownSelectedOption( 'groupMembers' )" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" alt="$i18n.getString( 'move_up' )"></a>
+
+		<td>
+			<select id="groupMembers" name="groupMembers" multiple="multiple" style="height: 100%; width: 100%;"></select>
 		</td>
 	</tr>
 </table>
 
-<p><input type="submit" value="$i18n.getString( 'add' )" style="width:10em" /><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicatorGroupSet.action'" style="width:10em"/></p>
+<p>
+	<input type="submit" value="$i18n.getString( 'add' )" style="width:10em" />
+	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicatorGroupSet.action'" style="width:10em"/>
+</p>
 
 </form>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm	2011-05-24 20:20:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm	2011-05-25 13:17:19 +0000
@@ -28,6 +28,7 @@
 			},
 			removeDataElementGroups: removeDataElementGroupsList,
 			params: {
+				filterNoGroupSet: true,
 				removeDataElementGroups: removeDataElementGroupsList.join(",")
 			}
 		});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.vm	2011-03-31 13:13:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateIndicatorGroupSet.vm	2011-05-25 13:17:19 +0000
@@ -1,6 +1,38 @@
 <script type="text/javascript" src="javascript/updateIndicatorGroupSet.js"></script>
 <script type="text/javascript">
+	function getRemoveIndicatorGroups() {
+		var list = [
+		#foreach( $indicatorGroup in $selectedGroups )
+            ${indicatorGroup.id}
+        #end
+		];
+
+		return list;	
+	}
+
 	jQuery(document).ready(	function() {
+		jQuery("#availableIndicatorGroupsList").dblclick(dhisPaging_availableList_dblclick("availableIndicatorGroupsList", "groupMembers", "removeIndicatorGroups"));
+		jQuery("#groupMembers").dblclick(dhisPaging_selectedList_dblclick("groupMembers", "availableIndicatorGroupsList", "removeIndicatorGroups"));
+
+		var removeIndicatorGroupsList = getRemoveIndicatorGroups();
+
+		jQuery("#availableIndicatorGroupsList").dhisPaging({
+			source: "../dhis-web-commons-ajax-json/getIndicatorGroups.action",
+			iterator: "indicatorGroups",
+			handler: function(item) {
+				var option = jQuery("<option />");
+				option.text( item.name );
+				option.attr( "value", item.id );
+
+				return option;
+			},
+			removeIndicatorGroups: removeIndicatorGroupsList,
+			params: {
+				filterNoGroupSet: true,
+				removeIndicatorGroups: removeIndicatorGroupsList.join(",")
+			}
+		});
+
 		checkValueIsExist( "name", "validateIndicatorGroupSet.action", {id: $indicatorGroupSet.id});			
 	});
 </script>
@@ -23,47 +55,43 @@
 </table>
 
 <table>
+    <col style="width: 450px"/>
+    <col/>
+    <col/>
+
 	<tr>
-		<th>$i18n.getString( "available_indicatorgroup" )</th><td></td><th>$i18n.getString( "group_members" )
-		<select id="memberValidator" class="{validate:{required:true}}" style="display:none"/></th>
-	</tr>
-	<tr>		
-		<td><input type="text" id="availableIndicatorGroupsFilter" onkeyup="filterList( this.value, 'availableIndicatorGroups' )" style="width:25em"/></td>
-		<td style="text-align:center">&lt; $i18n.getString( "filters" ) &gt;</td>
-		<td><input type="text" id="groupMembersFilter" onkeyup="filterList( this.value, 'groupMembers' )" style="width:25em"/></td>
-	</tr>
+		<th>$i18n.getString( "available_indicatorgroup" )</th>
+		<th></th>
+		<th>$i18n.getString( "group_members" )
+			<select id="memberValidator" class="{validate:{required:true}}" style="display:none"/>
+		</th>
+	</tr>
+
 	<tr>
 		<td>
-			<select id="availableIndicatorGroups" size="2" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById( 'availableIndicatorGroups', 'groupMembers' )">
-				#foreach( $indicatorGroup in $availableGroups )
-                    <option value="$indicatorGroup.id">$encoder.htmlEncode( $indicatorGroup.name )</option>
-                #end
-			</select>
+			<select id="availableIndicatorGroupsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
 		</td>
-		
+
         <td style="text-align:center">          
-            <input type="button" value="&gt;" title="$i18n.getString('move_selected')" style="width:50px" onclick="moveSelectedById( 'availableIndicatorGroups', 'groupMembers' )"/><br/>
-            <input type="button" value="&lt;" title="$i18n.getString('remove_selected')" style="width:50px" onclick="moveSelectedById( 'groupMembers', 'availableIndicatorGroups' )"/><br/>
-            <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="moveAllById( 'availableIndicatorGroups', 'groupMembers' )"/><br/>
-            <input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'groupMembers', 'availableIndicatorGroups' )"/>
+        	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'availableIndicatorGroupsList' );"/><br/>
+            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisPaging_moveAllSelected( 'groupMembers' );"/><br/>
+			<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisPaging_moveAll( 'availableIndicatorGroupsList' );"/><br/>
+			<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisPaging_moveAll( 'groupMembers' );"/>
         </td>
-    
+
 		<td>
-			<select id="groupMembers" name="groupMembers" size="2" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById( 'groupMembers', 'availableIndicatorGroups' )">
+			<select id="groupMembers" name="groupMembers" multiple="multiple" style="height: 100%; width: 100%;">
 				#foreach( $indicatorGroup in $selectedGroups )
                     <option value="$indicatorGroup.id">$encoder.htmlEncode( $indicatorGroup.name )</option>
                 #end
 			</select>
 		</td>
-		
-		<td>
-			<a href="javascript:moveUpSelectedOption( 'groupMembers')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" alt="$i18n.getString( 'move_up' )"/></a>
-			<br/>
-			<a href="javascript:moveDownSelectedOption( 'groupMembers' )" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" alt="$i18n.getString( 'move_up' )"/></a>
-		</td>
 	</tr>
 </table>
 
-<p><input type="submit" value="$i18n.getString( 'update' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicatorGroupSet.action'" style="width:10em"/></p>
+<p>
+	<input type="submit" value="$i18n.getString( 'update' )" style="width:10em"/>
+	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='indicatorGroupSet.action'" style="width:10em"/>
+</p>
 
 </form>