← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4126: implemented ajax-load in dataset for mobile

 

------------------------------------------------------------
revno: 4126
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-07-13 11:32:37 +0200
message:
  implemented ajax-load in dataset for mobile
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.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/ajax/jsonDataSets.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm	2011-05-16 14:21:57 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataSets.vm	2011-07-13 09:32:37 +0000
@@ -5,7 +5,8 @@
     "id": $!{dataSet.id},
     "name": "$!encoder.jsonEncode( ${dataSet.name} )",
     "shortName": "$!encoder.jsonEncode( ${dataSet.shortName} )",
-    "periodTypeId": "$!{dataSet.periodTypeId}"
+    "periodTypeId": "$!{dataSet.periodTypeId}",
+    "version": "$!{dataSet.version}"
   }#if( $velocityCount < $size ),#end
 #end
 ]

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java	2011-03-07 23:37:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/MobileDataSetListAction.java	2011-07-13 09:32:37 +0000
@@ -54,18 +54,6 @@
     // -------------------------------------------------------------------------
     // Getters and Setters
     // -------------------------------------------------------------------------
-    private List<DataSet> dataSets;
-    
-    public void setDataSets( List<DataSet> dataSets )
-    {
-        this.dataSets = dataSets;
-    }
-    
-    public List<DataSet> getDataSets()
-    {
-        return dataSets;
-    }
-    
     private List<DataSet> mobileDatasets;
 
     public List<DataSet> getMobileDatasets()
@@ -82,11 +70,9 @@
     public String execute()
         throws Exception
     {
-        dataSets = new ArrayList<DataSet>(dataSetService.getAllDataSets());
         mobileDatasets = new ArrayList<DataSet>(dataSetService.getDataSetsForMobile());
-        dataSets.removeAll( mobileDatasets );
-        Collections.sort( dataSets, new DataSetNameComparator() );
         Collections.sort( mobileDatasets, new DataSetNameComparator() );
+        
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java	2011-03-02 21:44:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateMobileDataSetAction.java	2011-07-13 09:32:37 +0000
@@ -52,6 +52,7 @@
                 dataSetService.updateDataSet( dataset );
             }
         }
+     
         for ( String id : availableList )
         {
             dataset = dataSetService.getDataSet( Integer.parseInt( id ) );
@@ -61,7 +62,7 @@
                 dataSetService.updateDataSet( dataset );
             }
         }
-        
+
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.vm	2011-03-18 14:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/mobileDatasetList.vm	2011-07-13 09:32:37 +0000
@@ -1,9 +1,32 @@
+<script type="text/javascript">
+	jQuery(document).ready(	function(){
+		jQuery("#availableList").dhisAjaxSelect({
+			source: "../dhis-web-commons-ajax-json/getDataSets.action",
+			iterator: 'dataSets',
+			connectedTo: 'selectedList',
+			handler: function(item) {
+				var option = jQuery("<option />");
+				option.text( item.name + "-Version " + item.version );
+				option.attr( "value", item.id );
+
+				return option;
+			}
+		});
+		
+		jQuery("#save").bind("click", function(e) {
+			jQuery("#availableList").children().attr("selected", "selected");
+			jQuery("#selectedList").children().attr("selected", "selected");
+		});
+	});
+</script>
+
 <h3>$i18n.getString( "mobile_dataset" )</h3>
 <form id="updateMobileDataset" name="updateMobileDataset" action="updateMobileDataset.action" method="post">
 <table id="dataSetSelectionArea">
-    <col/> ## Available DataSet of selected Organisation Unit
-    <col/> ## Filter
-    <col/> ## Mobile DataSet of selected Organisation Unit
+    <col style="width: 450px"/>
+    <col/>
+    <col style="width: 450px"/>
+
     <thead>
       <tr>
         <th>$i18n.getString( "available_datasets" )</th>
@@ -11,38 +34,37 @@
         <th>$i18n.getString( "mobile_dataset" )</th>
       </tr>
     </thead>
+
     <tbody>
 		<tr>
 		  <!---->
 		  <td>
-          <select size="15" id="availableList" name="availableList" multiple="multiple" style="min-width:20em;height:20em" ondblclick="moveSelectedById( 'availableList', 'selectedList');">
-              	#foreach( $dataset in $dataSets )
-              		<option value="$dataset.id">$encoder.htmlEncode( $dataset.name )-Version $dataset.version</option>
-          		#end
-          </select>
-          </td>
-		  <td>
-            <input type="button" value="&gt;" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="moveSelectedById( 'availableList', 'selectedList');"/><br/>
-            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="moveSelectedById( 'selectedList', 'availableList');"/><br/>
-            <input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="moveAllById( 'availableList', 'selectedList' );"/><br/>
-            <input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'selectedList', 'availableList' );"/>
-          </td>
-          <td>
-          <!---->
-          <select size="15" id="selectedList" name="selectedList" multiple="multiple" style="min-width:20em;height:20em" ondblclick="moveSelectedById( 'selectedList', 'availableList');">
-              	#foreach( $mobiledataset in $mobileDatasets )
-              		<option value="$mobiledataset.id">$encoder.htmlEncode( $mobiledataset.name )-Version $mobiledataset.version</option>
-          		#end
-          </select>
-          </td>
-          <td style="width:30px; text-align:center">
+		  	<select id="availableList" name="availableList" 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="dhisAjaxSelect_moveAllSelected( 'availableList' );"/><br/>
+            <input type="button" value="&lt;" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedList' );"/><br/>
+			<input type="button" value="&gt;&gt;" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableList' );"/><br/>
+			<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedList' );"/>
+        </td>
+
+        <td>
+          <select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;">
+        	#foreach( $mobiledataset in $mobileDatasets )
+      			<option value="$mobiledataset.id">$encoder.htmlEncode( $mobiledataset.name )-Version $mobiledataset.version</option>
+    		#end
+          </select>
+        </td>
+
+        <td style="width:30px; text-align:center">
             <a href="javascript:moveUpSelectedOption( 'selectedList' )"><img src="../images/move_up.png"/></a><br/><br/>
             <a href="javascript:moveDownSelectedOption( 'selectedList' )"><img src="../images/move_down.png"/></a><br/><br/>
-          </td>
+        </td>
 		</tr>
 		<tr>
         <td colspan="3">
-          <input type="submit" value="$i18n.getString( 'save' )" style="width:20em"/>
+          <input id="save" type="submit" value="$i18n.getString( 'save' )" style="width:20em"/>
         </td>
       </tr>
 	</tbody>