← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13063: check duplicated sms command's special characters

 

------------------------------------------------------------
revno: 13063
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-11-29 16:50:53 +0700
message:
  check duplicated sms command's special characters
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.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-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js	2013-11-29 08:05:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/command.js	2013-11-29 09:50:53 +0000
@@ -21,8 +21,8 @@
 	var rowId = jQuery('.trSpecialCharacter').length + 1;
 
 	var contend = '<tr id="trSpecialCharacter'+rowId+'" name="trSpecialCharacter'+rowId+'" class="trSpecialCharacter">'
-				+	'<td><input id="name'+rowId+'" name="name'+rowId+'" type="text" class="name {validate:{required:true}}"/></td>'
-				+	'<td><input id="value'+rowId+'" name="value'+rowId+'" type="text" class="value {validate:{required:true}}"/>'
+				+	'<td><input id="name'+rowId+'" name="name'+rowId+'" type="text" class="name {validate:{required:true}}" onblur="checkDuplicatedSpeCharName(this.value,'+rowId+')"/></td>'
+				+	'<td><input id="value'+rowId+'" name="value'+rowId+'" type="text" class="value {validate:{required:true}}" onblur="checkDuplicatedSpeCharValue(this.value, '+rowId+')"/>'
 				+   	'<input type="button" value="remove" onclick="removeSpecialCharactersForm('+rowId+')"/></td>'
 				+ '</tr>';
 	jQuery('#specialCharacters').append( contend );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm	2013-11-29 08:05:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm	2013-11-29 09:50:53 +0000
@@ -42,7 +42,6 @@
 	
 	function checkDuplicatedCode( value, index )
 	{
-		
 		for (var i=1; i<=jQuery('.trDataElementCode').length; i++ )
 		{
 			if ( i != index )
@@ -50,7 +49,7 @@
 				var otherValue = document.getElementById('codeValue'+i).value;
 				if( value!='' && value == otherValue )
 				{
-					markInvalid( 'codeValue'+index, 'Duplicated Value' );
+					markInvalid( 'codeValue'+index, 'Duplicated Code' );
 					break;
 				}
 				else
@@ -60,6 +59,46 @@
 			} 
 		}
 	};
+	
+	function checkDuplicatedSpeCharName( value, index )
+	{
+		for (var i=1; i<=jQuery('.trSpecialCharacter').length; i++ )
+		{
+			if ( i != index )
+			{
+				var otherValue = document.getElementById('name'+i).value;
+				if( value!='' && value == otherValue )
+				{
+					markInvalid( 'name'+index, 'Duplicated Name' );
+					break;
+				}
+				else
+				{
+					markValid( 'name'+index );
+				}
+			}
+		}
+	};
+	
+	function checkDuplicatedSpeCharValue( value, index )
+	{
+		for (var i=1; i<=jQuery('.trSpecialCharacter').length; i++ )
+		{
+			if ( i != index )
+			{
+				var otherValue = document.getElementById('value'+i).value;
+				if( value!='' && value == otherValue )
+				{
+					markInvalid( 'value'+index, 'Duplicated Value' );
+					break;
+				}
+				else
+				{
+					markValid( 'value'+index );
+				}
+			}
+		}
+	};
     
 </script>
 
@@ -178,10 +217,9 @@
 	<tbody id="specialCharacters">
 		#foreach( $specialCharacters in $smsCommand.specialCharacters )
 			<tr id="trSpecialCharacter$velocityCount" name="trSpecialCharacter$velocityCount" class="trSpecialCharacter">
-				<td><input type="text" id="name$velocityCount" name="name$velocityCount" class="name {validate:{required:true}}" value="$specialCharacters.name"/></td>
-				<td>
-					<input type="text" id="value$velocityCount" name="value$velocityCount" class="value {validate:{required:true}}" value="$specialCharacters.value"/><input type="button" value="remove" onclick="removeSpecialCharactersForm($velocityCount)"/>
-				</td>
+				<td><input type="text" id="name$velocityCount" name="name$velocityCount" class="name {validate:{required:true}}" value="$specialCharacters.name" onblur="checkDuplicatedSpeCharName(this.value, $velocityCount)"/></td>
+				<td><input type="text" id="value$velocityCount" name="value$velocityCount" class="value {validate:{required:true}}" value="$specialCharacters.value" onblur="checkDuplicatedSpeCharValue(this.value, $velocityCount)"/></td>
+				<td><input type="button" value="remove" onclick="removeSpecialCharactersForm($velocityCount)"/></input>
 			</tr>
 		#end
 	</tbody>