← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7912: fix deleted gateway bug

 

------------------------------------------------------------
revno: 7912
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-08-14 16:50:07 +0700
message:
  fix deleted gateway bug
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.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/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-07-24 04:04:14 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-08-14 09:50:07 +0000
@@ -1119,7 +1119,6 @@
 {
 	var beforeValidateHandler = kwargs["beforeValidateHandler"];
 	var rules = kwargs["rules"];
-
 	var validator = jQuery("#" + formId ).validate({
 		meta:"validate",
 		errorElement:"span",

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java	2012-08-10 10:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java	2012-08-14 09:50:07 +0000
@@ -131,7 +131,7 @@
     public String execute()
         throws Exception
     {
-
+        
         smsServiceStatus = smsLibService.getServiceStatus();
 
         smsConfig = smsConfigurationManager.getSmsConfiguration();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-08-10 10:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2012-08-14 09:50:07 +0000
@@ -19,6 +19,7 @@
 delete=Delete
 check_all=Click Here To Check All
 error_delete=Please check before delete
+required_data_error=Please fill in required fields (*)
 new_message=You have new messages, press F5 to view them
 sms_service_is_runnning=SMS Service is running
 sms_service_is_stopped=SMS Service is stopped
@@ -79,7 +80,6 @@
 config_my_gateway =Configure My Gateway
 delete_checked_option =Delete Checked Options
 import =Import
-error_import=Please Check Before Import
 phone_number=Phone number
 raw_phone_number=Raw phone numbers
 assigned_user_number=User assigned to organisation unit 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2012-08-13 02:55:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml	2012-08-14 09:50:07 +0000
@@ -115,6 +115,7 @@
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-maintenance-mobile/smsServiceConfiguration.vm</param>
       <param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
+      <param name="javascripts">javascript/gateway.js</param>
 	  <param name="requiredAuthorities">F_MOBILE_SETTINGS</param>
     </action>
 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js	2012-08-10 06:29:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js	2012-08-14 09:50:07 +0000
@@ -65,39 +65,60 @@
 
 function saveGatewayConfig()
 {
-	lockScreen();
+	
 	if ( currentType == 'modem' )
 	{
-		jQuery.postJSON( "saveModemConfig.action", {
-			gatewayType: getFieldValue( 'gatewayType' ),
-			name: getFieldValue( 'modemFields input[id=name]' ),
-			port: getFieldValue( 'modemFields input[id=port]' ),
-			baudRate: getFieldValue( 'modemFields input[id=baudRate]' ),
-			manufacturer: getFieldValue( 'modemFields input[id=manufacturer]' ),
-			model: getFieldValue( 'modemFields input[id=model]' ),
-			pin: getFieldValue( 'modemFields input[id=pin]' ),
-			inbound: getFieldValue( 'modemFields select[id=inbound]' ),
-			outbound: getFieldValue( 'modemFields select[id=outbound]' )
-		}, function ( json ) {
-			unLockScreen();
-			showMessage( json );
-		} );
+		var port = getFieldValue( 'modemFields input[id=port]' );
+		var baudRate = getFieldValue( 'modemFields input[id=baudRate]' );
+		if ( port == "" || baudRate == "")
+		{	
+			showErrorMessage( i18n_required_data_error );
+		}
+		else
+		{
+			lockScreen();		
+			jQuery.postJSON( "saveModemConfig.action", {
+				gatewayType: getFieldValue( 'gatewayType' ),
+				name: getFieldValue( 'modemFields input[id=name]' ),
+				port: getFieldValue( 'modemFields input[id=port]' ),
+				baudRate: getFieldValue( 'modemFields input[id=baudRate]' ),
+				manufacturer: getFieldValue( 'modemFields input[id=manufacturer]' ),
+				model: getFieldValue( 'modemFields input[id=model]' ),
+				pin: getFieldValue( 'modemFields input[id=pin]' ),
+				inbound: getFieldValue( 'modemFields select[id=inbound]' ),
+				outbound: getFieldValue( 'modemFields select[id=outbound]' )
+			}, function ( json ) {
+				unLockScreen();
+				showMessage( json );
+			} );
+		}
 	}
 	else if ( currentType == 'bulksms' )
 	{
-		jQuery.postJSON( "saveBulkSMSConfig.action", {
-			gatewayType: getFieldValue( 'gatewayType' ),
-			name: getFieldValue( 'bulksmsFields input[id=name]' ),
-			username: getFieldValue( 'bulksmsFields input[id=username]' ),
-			password: getFieldValue( 'bulksmsFields input[id=password]' ),
-			region: getFieldValue( 'bulksmsFields select[id=region]' )
-		}, function ( json ) {
-			unLockScreen();
-			showMessage( json );
-		} );
+		var username = getFieldValue( 'bulksmsFields input[id=username]' );
+		var password = getFieldValue( 'bulksmsFields input[id=password]' );
+		if ( username == "" || password == "")
+		{	
+			showErrorMessage( i18n_required_data_error );
+		}
+		else
+		{
+			lockScreen();
+			jQuery.postJSON( "saveBulkSMSConfig.action", {
+				gatewayType: getFieldValue( 'gatewayType' ),
+				name: getFieldValue( 'bulksmsFields input[id=name]' ),
+				username: getFieldValue( 'bulksmsFields input[id=username]' ),
+				password: getFieldValue( 'bulksmsFields input[id=password]' ),
+				region: getFieldValue( 'bulksmsFields select[id=region]' )
+			}, function ( json ) {
+				unLockScreen();
+				showMessage( json );
+			} );
+		}
 	}
 	else if ( currentType == 'clickatell' )
 	{
+		lockScreen();
 		jQuery.postJSON( "saveClickatellConfig.action", {
 			gatewayType: getFieldValue( 'gatewayType' ),
 			name: getFieldValue( 'clickatellFields input[id=name]' ),
@@ -111,6 +132,7 @@
 	}
 	else
 	{
+		lockScreen();
 		jQuery.postJSON( "saveHTTPConfig.action", {
 			gatewayType: getFieldValue( 'gatewayType' ),
 			name: getFieldValue( 'genericHTTPFields input[id=name]' ),
@@ -131,4 +153,43 @@
 	} else {
 		showErrorMessage( json.message, 7000 );
 	}
+}
+
+function deleteItem( itemId, itemName, confirmation, action, success )
+{                
+    var result = window.confirm( confirmation + "\n\n" + itemName );
+    
+    if ( result )
+    {
+		refreshIndex( itemId );
+    	$.postJSON(
+    	    action,
+    	    {
+    	        "id": itemId   
+    	    },
+    	    function( json )
+    	    { 
+    	    	if ( json.response == "success" )
+    	    	{
+					jQuery( "tr#tr" + itemId ).remove();
+	                
+					jQuery( "table.listTable tbody tr" ).removeClass( "listRow listAlternateRow" );
+	                jQuery( "table.listTable tbody tr:odd" ).addClass( "listAlternateRow" );
+	                jQuery( "table.listTable tbody tr:even" ).addClass( "listRow" );
+					jQuery( "table.listTable tbody" ).trigger("update");
+  
+					if ( success && typeof( success) == "function" )
+					{
+						success.call();
+					}
+  
+					showSuccessMessage( i18n_delete_success );
+    	    	}
+    	    	else if ( json.response == "error" )
+    	    	{ 
+					showWarningMessage( json.message );
+    	    	}
+    	    }
+    	);
+    }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm	2012-08-10 10:02:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm	2012-08-14 09:50:07 +0000
@@ -47,6 +47,20 @@
 			showById('btnAddGw');
 		}
 	} );
+	
+	function refreshIndex( indexDeleted ) {
+		var gwSize = getFieldValue( 'gatewaySize' ); 
+		
+		if ( indexDeleted < gwSize )
+		{
+			for ( indexDeleted + 1 ;indexDeleted + 1 <= gwSize - 1 ;indexDeleted++ )
+			{
+				document.getElementById(indexDeleted + 1).href = 'showUpdateGateWayConfigForm.action?index='+indexDeleted;
+			}			
+		}
+		//var theLink = document.getElementById("1").getAttribute("href");
+		
+	};
 
 	var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_gateway" ) , "'")';
 	var i18n_stop_sms_service = '$encoder.jsEscape( $i18n.getString( "stop_sms_service" ) , "'")';
@@ -59,6 +73,7 @@
 
 <h3>$i18n.getString( "sms_service_configuration" )</h3>
 <input id="isSettingAvailable" name="isSettingAvailable" type="hidden" #if ( $!smsConfig ) value="true" #else value="false" #end/>
+<input id="gatewaySize" name="gatewaySize" type="hidden" value="$gatewayConfigMap.keySet().size()"/>
 <form id="saveSmsConfigurationForm" name="saveSmsConfigurationForm" action="saveSmsConfiguration.action" method="post" >
   <table id="detailsList" border="0">
     <col/> ## Labels
@@ -127,7 +142,7 @@
 							#set( $gw = $!gatewayConfigMap.get( $key ) )
 							<td>$!encoder.htmlEncode( $gw.name )</td>
 							<td style="text-align:right">
-							  <a href="showUpdateGateWayConfigForm.action?index=$key" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>		
+							  <a id="$key" href="showUpdateGateWayConfigForm.action?index=$key" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>		
 							  <a href="javascript:removeGateway( $key, '$!encoder.jsEncode( $gw.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
 							</td>
 						</tr>
@@ -177,6 +192,6 @@
 	
 	function removeGateway( key, name )
 	{
-		removeItem( key, name, i18n_confirm_delete, "removeGatewayConfig.action", function() { window.location="showSMSConfigureForm.action"; } );
+		removeItem( key, name, i18n_confirm_delete, "removeGatewayConfig.action");
 	}
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm	2012-08-13 04:09:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm	2012-08-14 09:50:07 +0000
@@ -11,6 +11,7 @@
     });
 	
 	var i18n_add_update_success = '$encoder.jsEscape( $i18n.getString( "add_update_gateway_success" ) , "'")';
+	var i18n_required_data_error = '$encoder.jsEscape( $i18n.getString( "required_data_error" ) , "'" )';
 </script>
 <h3>$i18n.getString( "add_update_gateway_management" )</h3>
 <form id="addGateWayConfigForm" name="addGateWayConfigForm">
@@ -39,11 +40,11 @@
 				<td><input type="text" name="name" id="name" style="width: 28em" value="$!encoder.htmlEncode( $!bulkGateway.name )"/></td>
 			</tr>
 			<tr>
-				<td>$i18n.getString( "username" ):</td>
+				<td>$i18n.getString( "username" ) <em title="Required" class="required">*</em>:</td>
 				<td><input type="text" name="username" id="username" style="width: 28em" value="$!bulkGateway.username"/></td>
-			</tr>
+			</tr> 
 			<tr>
-				<td>$i18n.getString( "password" ):</td>
+				<td>$i18n.getString( "password" ) <em title="Required" class="required">*</em>:</td>
 				<td><input type="text" name="password" id="password" style="width: 28em" value="$!bulkGateway.password"/></td>
 			</tr>
 			<tr>
@@ -67,11 +68,11 @@
 				<td><input type="text" name="name" id="name" style="width: 28em" value="$!encoder.htmlEncode( $!modemGateway.name )"/></td>
 			</tr>
 			<tr>
-				<td>$i18n.getString( "port" )<em title="Required" class="required">*</em>:</td>
+				<td>$i18n.getString( "port" ) <em title="Required" class="required">*</em>:</td>
 				<td><input type="text" name="port" id="port" style="width: 28em" value="$!modemGateway.port"/></td>
 			</tr>
 			<tr>
-				<td>$i18n.getString( "baudrate" )<em title="Required" class="required">*</em>:</td>
+				<td>$i18n.getString( "baudrate" ) <em title="Required" class="required">*</em>:</td>
 				<td><input type="text" name="baudRate" id="baudRate" style="width: 28em" value="$!modemGateway.baudRate"/></td>
 			</tr>
 			<tr>