← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3939: implemented ajax-load for zero value storage

 

------------------------------------------------------------
revno: 3939
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-06-18 16:55:50 +0300
message:
  implemented ajax-load for zero value storage
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/OpenDataElementsZeroIsSignificantManagerAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.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-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js	2011-06-09 20:31:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisAjaxSelect.js	2011-06-18 13:55:50 +0000
@@ -174,7 +174,10 @@
                 $.each(json[settings.iterator], function(i, item)
                 {
                     var option = $(settings.handler(item));
-                    $select.append(option);
+
+                    if(option !== undefined) {
+                        $select.append(option);
+                    }
                 });
 
                 if (settings.connectedTo) {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/OpenDataElementsZeroIsSignificantManagerAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/OpenDataElementsZeroIsSignificantManagerAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/OpenDataElementsZeroIsSignificantManagerAction.java	2011-06-18 13:55:50 +0000
@@ -32,16 +32,13 @@
 import java.util.List;
 
 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.dataelement.comparator.DataElementNameComparator;
 
 import com.opensymphony.xwork2.Action;
 
 /**
  * @author Tran Thanh Tri
- * @version $Id$
  */
 
 public class OpenDataElementsZeroIsSignificantManagerAction
@@ -62,13 +59,6 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private List<DataElement> ignoreZeroValueDataElements;
-
-    public List<DataElement> getIgnoreZeroValueDataElements()
-    {
-        return ignoreZeroValueDataElements;
-    }
-
     private List<DataElement> zeroDataValueElements;
 
     public List<DataElement> getZeroDataValueElements()
@@ -76,31 +66,15 @@
         return zeroDataValueElements;
     }
 
-    private List<DataElementGroup> dataElementGroups;
-
-    public List<DataElementGroup> getDataElementGroups()
-    {
-        return dataElementGroups;
-    }
-
     @Override
     public String execute()
         throws Exception
     {
-        ignoreZeroValueDataElements = new ArrayList<DataElement>( dataElementService
-            .getDataElementsByZeroIsSignificant( false ) );
-
-        Collections.sort( ignoreZeroValueDataElements, new DataElementNameComparator() );
-
         zeroDataValueElements = new ArrayList<DataElement>( dataElementService
             .getDataElementsByZeroIsSignificant( true ) );
 
         Collections.sort( zeroDataValueElements, new DataElementNameComparator() );
 
-        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups() );
-
-        Collections.sort( dataElementGroups, new DataElementGroupNameComparator() );
-
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm	2011-03-17 14:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm	2011-06-18 13:55:50 +0000
@@ -1,4 +1,28 @@
 <script type="text/javascript">
+	jQuery(document).ready(function() {
+		jQuery("#ignoreZeroValueDataElements").dhisAjaxSelect({
+			source: "../dhis-web-commons-ajax-json/getDataElements.action",
+			iterator: "dataElements",
+			connectedTo: 'zeroDataValueElements',
+			handler: function(item) {
+				var option = jQuery("<option data-id='" + item.groups + "' />");
+				option.text( item.name );
+				option.attr( "value", item.id );
+	
+				return option;
+			},
+			filter: {
+				source: "../dhis-web-commons-ajax-json/getDataElementGroups.action",
+				label: 'dataelement group',
+				iterator: "dataElementGroups",
+				handler: function(item) {
+					return "<option data-key='id' data-value='" + item.id + "'>" + item.name + "</option>";
+				}
+			}
+		});
+	});
+
+/*
 	function getSaveZeroDataElements( value )
 	{		
 		jQuery.postJSON('../dhis-web-commons-ajax-json/getDataElements.action', {id: value },
@@ -12,13 +36,18 @@
 				}
 			});
 		});
-	}	
+	}
+*/	
 </script>
 
 <h3>$i18n.getString( "zero_storage_management" ) #openHelp( "zeroValueStorage" )</h3>
 <br/>
 <form id="ZeroDataValueManagement" method="POST" action="updateZeroIsSignificantForDataElements.action" onsubmit="selectAllById( 'zeroDataValueElements' )">
 <table>
+    <col style="width: 450px"/>
+    <col/>
+    <col style="width: 450px"/>
+
 	<thead>
 		<tr>
 			<th>$i18n.getString( "ignore_zero_data_values" )</th>
@@ -26,42 +55,22 @@
 			<th>$i18n.getString( "store_zero_data_values" )</th>			
 		</tr>
 	</thead>
+
 	<tbody>
 		<tr>
 			<td>
-				<select onchange="getSaveZeroDataElements(this.value)">
-					<option value="">$i18n.getString( "all" )</option>
-					#foreach( $dataElementGroup in $dataElementGroups )
-						<option value='$dataElementGroup.id'>$encoder.htmlEncode( $dataElementGroup.name )</option>
-					#end
-				</select>
-			</td>
-			<td></td>
-			<td></td>			
-		</tr>
-		<tr>
-			<td><input type="text" style="width:100%" id="filterIgnoreZeroValue" onkeyup="filterList( this.value, 'ignoreZeroValueDataElements')"/></td>
-			<td></td>
-			<td><input type="text" style="width:100%" id="filterSaveZeroValue" onkeyup="filterList( this.value, 'zeroDataValueElements')"/></td>
-		</tr>
-		<tr>
-			<td>
-				<select id="ignoreZeroValueDataElements" name="ignoreZeroValueDataElements" size="10" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById('ignoreZeroValueDataElements', 'zeroDataValueElements')">
-					#foreach( $zero in $ignoreZeroValueDataElements )
-						<option value='$zero.id'>$encoder.htmlEncode( $zero.name )</option>
-					#end					
-				</select>
+				<select id="ignoreZeroValueDataElements" name="ignoreZeroValueDataElements" multiple="multiple" style="height: 200px; width: 100%;"></select>
 			</td>
 		
-			<td style="text-align:center">
-				<input type="button" value="&gt;" title="$i18n.getString('move_selected')" onclick="moveSelectedById('ignoreZeroValueDataElements', 'zeroDataValueElements')" style="width:50px"/><br/>
-				<input type="button" value="&lt;" title="$i18n.getString('move_selected')" onclick="moveSelectedById('zeroDataValueElements', 'ignoreZeroValueDataElements')" style="width:50px"/><br/>	
-                <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" onclick="moveAllById('ignoreZeroValueDataElements', 'zeroDataValueElements')" style="width:50px"/><br/>		
-				<input type="button" value="&lt;&lt;" title="$i18n.getString('move_all')" onclick="moveAllById('zeroDataValueElements', 'ignoreZeroValueDataElements')" style="width:50px"/>
-			</td>
+	        <td>
+	        	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'ignoreZeroValueDataElements' );"/><br/>
+	            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'zeroDataValueElements' );"/><br/>
+				<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'ignoreZeroValueDataElements' );"/><br/>
+				<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'zeroDataValueElements' );"/>
+	        </td>       
 	
 			<td>
-				<select id="zeroDataValueElements" name="zeroDataValueElements" size="10" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById('zeroDataValueElements', 'ignoreZeroValueDataElements')">
+				<select id="zeroDataValueElements" name="zeroDataValueElements" multiple="multiple" style="height: 200px; width: 100%; margin-top: 45px;">
 					#foreach( $zero in $zeroDataValueElements )
 						<option value='$zero.id'>$encoder.htmlEncode( $zero.name )</option>
 					#end
@@ -70,8 +79,10 @@
 		</tr>
 	</tbody>
 </table>
+
 <p>
 	<input type="submit" value="$i18n.getString( 'save' )" style="width:100px"/>
 	<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='index.action'" style="width:100px"/>
 </p>
+
 </form>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2011-06-10 11:09:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2011-06-18 13:55:50 +0000
@@ -100,7 +100,7 @@
     	
       <tr>
         <td>
-          <select id="availableDataElementsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
+          <select id="availableDataElementsList" name="availableDataElementsList" multiple="multiple" style="height: 200px; width: 100%;"></select>
         </td>
         <td>
         	<input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableDataElementsList' );"/><br/>