← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2126: Fix bug : Delete dataentry form didn't work.

 

------------------------------------------------------------
revno: 2126
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-09-16 12:35:12 +0700
message:
  Fix bug : Delete dataentry form didn't work.
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/META-INF/dhis/beans.xml
  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/viewDataEntryForm.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-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	2010-09-16 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/DelDataEntryFormAction.java	2010-09-16 05:35:12 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.i18n.I18n;
@@ -44,6 +46,13 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    private DataEntryFormService dataEntryFormService;
+
+    public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+    {
+        this.dataEntryFormService = dataEntryFormService;
+    }
+
     private DataSetService dataSetService;
 
     public void setDataSetService( DataSetService dataSetService )
@@ -73,6 +82,13 @@
         this.dataSetId = dataSetId;
     }
 
+    private int dataEntryFormId;
+
+    public void setDataEntryFormId( int dataEntryFormId )
+    {
+        this.dataEntryFormId = dataEntryFormId;
+    }
+
     private String message;
 
     public String getMessage()
@@ -88,17 +104,21 @@
         throws Exception
     {
         DataSet dataSet = dataSetService.getDataSet( dataSetId );
+
+        DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm( dataEntryFormId );
         
-        if ( dataSet == null )
+        if ( dataSet == null || dataEntryForm == null )
         {
             message = i18n.getString( "unable_delete" );
 
             return INPUT;
         }
-        
+
         dataSet.setDataEntryForm( null );
         
         dataSetService.updateDataSet( dataSet );
+        
+        dataEntryFormService.deleteDataEntryForm( dataEntryForm );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2010-09-16 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2010-09-16 05:35:12 +0000
@@ -357,6 +357,9 @@
 		<property name="dataSetService">
 			<ref bean="org.hisp.dhis.dataset.DataSetService"/>
 		</property>
+		<property name="dataEntryFormService">
+			<ref bean="org.hisp.dhis.dataentryform.DataEntryFormService"/>
+		</property>
 	</bean>
 	
 	<bean id="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	2010-09-16 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js	2010-09-16 05:35:12 +0000
@@ -3,13 +3,13 @@
 // Delete DataEntryForm
 // -----------------------------------------------------------------------------
 
-function removeDataEntryForm( dataSetIdField, dataEntryFormName )
+function removeDataEntryForm( dataSetIdField, dataEntryFormId, dataEntryFormName )
 {
   var request = new Request();
   request.setResponseTypeXML( 'message' );
   request.setCallbackSuccess( removeDataEntryFormCompleted );
  
-  var requestString = 'delDataEntryForm.action?dataSetId=' + dataSetIdField;
+  var requestString = 'delDataEntryForm.action?dataSetId=' + dataSetIdField + "&dataEntryFormId=" + dataEntryFormId;
   var result = window.confirm( i18n_confirm_delete + '\n\n' + dataEntryFormName );
 
   if ( result )
@@ -185,7 +185,12 @@
 
 	var request = new Request();
 	request.setResponseTypeXML( 'dataSet' );
-	request.setCallbackSuccess( function (xmlObject){setMessage(i18n_save_success);} );
+	request.setCallbackSuccess( 
+		function (xmlObject)
+			{
+				setMessage(i18n_save_success); 
+				stat == "ADD";
+			} );
 	  
 	var params = 'nameField=' + getFieldValue('nameField');
 		params += '&designTextarea=' + designTextarea;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2010-09-16 05:12:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2010-09-16 05:35:12 +0000
@@ -70,7 +70,7 @@
           <input type="button" name="cancel" value="$i18n.getString( "cancel" )" onclick="window.location.href='dataSet.action'">
         </td>
         <td id="cde_deletebuttoncell">
-          <input type="button" name="delete" value="$i18n.getString( "delete" )" onclick="removeDataEntryForm( $dataSet.id, '$dataEntryForm.name' )" #if($status == "ADD") disabled #end>
+          <input type="button" name="delete" value="$i18n.getString( "delete" )" onclick="removeDataEntryForm( '$dataSet.id', '$dataEntryForm.id', '$dataEntryForm.name' )" #if($status == "ADD") disabled #end>
         </td>
         </tr>
 		<tr><td><span id="message"></span></td></tr>