← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6097: (patient) Use jQuery methods insteads of Request object in dhis-web-maintenance-dataset.

 

------------------------------------------------------------
revno: 6097
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-02-24 12:14:52 +0700
message:
  (patient) Use jQuery methods insteads of Request object in dhis-web-maintenance-dataset.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/DelDataEntryFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.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-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/DelDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/DelDataEntryFormAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/DelDataEntryFormAction.java	2012-02-24 05:14:52 +0000
@@ -31,7 +31,6 @@
 import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.i18n.I18n;
 
 import com.opensymphony.xwork2.Action;
 
@@ -59,18 +58,7 @@
     {
         this.dataSetService = dataSetService;
     }
-
-    // -------------------------------------------------------------------------
-    // I18n
-    // -------------------------------------------------------------------------
-
-    private I18n i18n;
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
+    
     // -------------------------------------------------------------------------
     // Getters & setters
     // -------------------------------------------------------------------------
@@ -88,14 +76,7 @@
     {
         this.dataEntryFormId = dataEntryFormId;
     }
-
-    private String message;
-
-    public String getMessage()
-    {
-        return message;
-    }
-
+    
     // -------------------------------------------------------------------------
     // Action
     // -------------------------------------------------------------------------
@@ -106,14 +87,7 @@
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
 
         DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm( dataEntryFormId );
-        
-        if ( dataSet == null || dataEntryForm == null )
-        {
-            message = i18n.getString( "unable_delete" );
-
-            return INPUT;
-        }
-
+       
         dataSet.setDataEntryForm( null );
         dataSet.increaseVersion();
         

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-02-23 11:12:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2012-02-24 05:14:52 +0000
@@ -37,7 +37,6 @@
 delete=Delete this form
 dataset=Data set
 dataentryform_confirm_delete=Are you sure you want to delete this data entry form?
-unable_delete=Unable to delete data entry form
 insert=Insert
 select_dataset=Select dataset
 sort_section=Sort section

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2012-02-13 20:04:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml	2012-02-24 05:14:52 +0000
@@ -194,7 +194,6 @@
 
     <action name="delDataEntryForm" class="org.hisp.dhis.dataset.action.dataentryform.DelDataEntryFormAction">
       <result name="success" type="redirect">dataSet.action</result>
-      <result name="input" type="velocity-xml">/dhis-web-maintenance-dataset/responseInput.vm</result>
     </action>
 
     <action name="selectDataElement" class="org.hisp.dhis.dataset.action.dataentryform.SelectDataElementAction">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js	2011-05-07 22:34:06 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js	2012-02-24 05:14:52 +0000
@@ -5,72 +5,51 @@
 
 function removeDataEntryForm( dataSetIdField, dataEntryFormId, dataEntryFormName )
 {
-  var request = new Request();
-  request.setResponseTypeXML( 'message' );
-  request.setCallbackSuccess( removeDataEntryFormCompleted );
- 
-  var requestString = 'delDataEntryForm.action?dataSetId=' + dataSetIdField + "&dataEntryFormId=" + dataEntryFormId;
   var result = window.confirm( i18n_confirm_delete + '\n\n' + dataEntryFormName );
 
   if ( result )
   {
-    request.send( requestString );
-  }
-  
-  return false;
-}
-
-function removeDataEntryFormCompleted( messageElement )
-{
-  var type = messageElement.getAttribute( 'type' );
-  var message = messageElement.firstChild.nodeValue;
-
-  if ( type == 'input' )
-  {
-    document.getElementById( 'message' ).innerHTML = message;
-    document.getElementById( 'message' ).style.display = 'block';
-  }
-  else
-  {
-  	window.location.href = 'index.action';
-  }
-}
-
+	window.location.href = 'delDataEntryForm.action?dataSetId=' + dataSetIdField + "&dataEntryFormId=" + dataEntryFormId;
+  }
+}
 
 // ----------------------------------------------------------------------
 // Validation
 // ----------------------------------------------------------------------
 
 function validateDataEntryForm()
-{
-  var request = new Request();
-  request.setResponseTypeXML( 'message' );
-  if(autoSave == false){
-	request.setCallbackSuccess( dataEntryFormValidationCompleted );
-  }
-  else{
-	request.setCallbackSuccess( autoSaveDataEntryFormValidationCompleted );
-  }
-  
-  var requestString = 'validateDataEntryForm.action';
-
-  var params = 'name=' + document.getElementById( 'nameField' ).value;
-  
+{  
+  var params  = 'name=' + document.getElementById( 'nameField' ).value;
+	  params += '&dataSetId=' + document.getElementById( 'dataSetIdField' ).value;
   if(stat == "EDIT")
   {
     params += '&dataEntryFormId=' + dataEntryFormId;      
   }        
 
-  params += '&dataSetId=' + document.getElementById( 'dataSetIdField' ).value;
-  
-  request.sendAsPost( params );
-  request.send( requestString );
-
-  return false;
+  if(autoSave == false)
+  {
+	$.ajax({
+	   type: "POST",
+	   url: "validateDataEntryForm.action",
+	   data: params,
+	   dataType: "xml",
+	   success: dataEntryFormValidationCompleted
+	});
+  }
+  else{
+	$.ajax({
+	   type: "POST",
+	   url: "validateDataEntryForm.action",
+	   data: params,
+	   dataType: "xml",
+	   success: autoSaveDataEntryFormValidationCompleted
+	});
+  }
 }
 
 function dataEntryFormValidationCompleted( messageElement )
 {
+  messageElement = messageElement.getElementsByTagName( 'message' )[0];
   var type = messageElement.getAttribute( 'type' );
   var message = messageElement.firstChild.nodeValue;
 
@@ -100,24 +79,13 @@
 
 function findDataElementCount()
 {
-  var request = new Request();
-  request.setResponseTypeXML( 'dataSet' );
-  request.setCallbackSuccess( findDataElementCountCompleted );
-
-  // Clear the list
-  var dataElementList = document.getElementById( 'dataElementSelector' );
-  dataElementList.options.length = 0;
-
-  var requestString = 'getSelectedDataElements.action';
-  
-  var params = 'dataSetId=' + document.getElementById( 'dataSetIdField' ).value;
-        
-  params += '&designCode=' + htmlCode;
-  
-  request.sendAsPost( params );
-  request.send( requestString );
-
-  return false;
+  clearListById('dataElementSelector');
+  
+  $.post( 'getSelectedDataElements.action',
+	{
+		dataSetId:document.getElementById( 'dataSetIdField' ).value,
+		designCode:htmlCode
+	},findDataElementCountCompleted );
 }
 
 function findDataElementCountCompleted( dataSetElement )
@@ -152,6 +120,7 @@
 
 function autoSaveDataEntryFormValidationCompleted( messageElement )
 {
+  messageElement = messageElement.getElementsByTagName( 'message' )[0];
   var type = messageElement.getAttribute( 'type' );
   var message = messageElement.firstChild.nodeValue;
 
@@ -177,18 +146,6 @@
 function autoSaveDataEntryForm() {
 	var field = $("#designTextarea").ckeditorGet();
 	var designTextarea = htmlEncode(field.getData());
-
-	var request = new Request();
-	request.setResponseTypeXML( 'dataSet' );
-	request.setCallbackSuccess( 
-		function (xmlObject)
-			{
-				setMessage(i18n_save_success); 
-				stat = "EDIT";
-				dataEntryFormId = xmlObject.firstChild.nodeValue;
-				enable('delete');
-			} );
-	  
 	var params = 'nameField=' + getFieldValue('nameField');
 		params += '&designTextarea=' + designTextarea;
 		params += '&dataSetIdField=' + getFieldValue('dataSetIdField');
@@ -197,6 +154,16 @@
 		params += '&dataEntryFormId=' + getFieldValue('dataEntryFormId');
 	}
 	
-	request.sendAsPost(params);
-	request.send('autoSaveDataEntryForm.action');
+	$.ajax({
+		   type: "POST",
+		   url: "autoSaveDataEntryForm.action",
+		   data: params,
+		   dataType: "xml",
+		   success: function(xmlObject){
+				setMessage(i18n_save_success); 
+				stat = "EDIT";
+				dataEntryFormId = xmlObject.getElementsByTagName( 'message' )[0].firstChild.nodeValue;
+				enable('delete');
+		   }
+		});
 }
\ No newline at end of file