← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11457: Allow to register many phone numbers in custom entry form.

 

------------------------------------------------------------
revno: 11457
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-07-22 11:59:04 +0700
message:
  Allow to register many phone numbers in custom entry form.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	2013-07-02 03:54:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	2013-07-22 04:59:04 +0000
@@ -394,6 +394,7 @@
         else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_PHONE_NUMBER ) )
         {
             inputHtml += " class=\"{validate:{phone:true}}\" " + hidden + " " + TAG_CLOSE;
+            inputHtml += " <input type=\"button\" value=\"\" style=\"width:20px;\" class=\"phoneNumberTR\" onclick=\"addCustomPhoneNumberField(\"\");\" />";
         }
         
         // Age fields

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-07-18 04:01:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-07-22 04:59:04 +0000
@@ -2129,7 +2129,7 @@
 		+ '	<td></td>'
 		+ '	<td class="input-column">'
 		+ '		<input type="text" id="phoneNumber" name="phoneNumber" class="{validate:{phone:true}}" value="'+phoneNumberAreaCode+'"/>'
-		+ '		<input type="button" value="-" onclick="removePhoneNumberField(this)" style="width:20px;" class="{validate:{phone:true}}" value="' + phoneNumberAreaCode + '"/>'
+		+ '		<input type="button" value="-" onclick="removePhoneNumberField(this)" style="width:20px;" />'
 		+ '	</td>'
 		+ '</tr>' );
 }
@@ -2137,4 +2137,17 @@
 function removePhoneNumberField(_this)
 {
 	$(_this).parent().parent().remove();
-}
\ No newline at end of file
+}
+
+function addCustomPhoneNumberField( phoneNumber )
+{
+	var idx = $('.phoneNumberTR').length + 1;
+	$('.phoneNumberTR').last().after(
+		'<br/><input type="text" id="phoneNumber" name="phoneNumber" class="idxPhoneNumber' + idx + ' {validate:{phone:true}}" value=\"' + phoneNumber + '\" />'
+		+ '    <input type="button" value="-" class="phoneNumberTR idxPhoneNumber' + idx + '" onclick="removeCustomPhoneNumberField(' + idx + ')" style="width:20px;" />');
+}
+
+function removeCustomPhoneNumberField(idx)
+{
+	$('.idxPhoneNumber' + idx).remove();
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2013-07-12 04:32:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2013-07-22 04:59:04 +0000
@@ -63,7 +63,7 @@
 		<td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
 		<td class="input-column">
 			<input type="text" id="phoneNumber" name="phoneNumber" class="{validate:{phone:true}}"/>
-			<input type="button" value='+' style='width:20px;' onclick='addPhoneNumberField("$!phoneNumberAreaCode");' />
+			<input type="button" value='+' style='width:20px;' onclick='addPhoneNumberField($!phoneNumberAreaCode);' />
 		</td>
 	</tr>
 
@@ -258,6 +258,7 @@
 #end
 
 <script>
+	var phoneNumberAreaCode = "$!phoneNumberAreaCode";
 	#if($!patient.dobType && $!patient.dobType=='A') 
 		showById('age');
 		hideById('birthDate');
@@ -266,14 +267,19 @@
 		showById('birthDate');
 	#end
 	
-	#if( $!patient.phoneNumber && $patient.phoneNumber!="")
-		var phoneNumbers = "$!patient.phoneNumber".split(';');
-		setFieldValue('phoneNumber',phoneNumbers[0]);
+	var phoneNumbers = "$!patient.phoneNumber".split(';');
+	setFieldValue('phoneNumber',phoneNumbers[0]);
+	#if($!customRegistrationForm)
+		for( var i = 1;i<phoneNumbers.length;i++ )
+		{
+			addCustomPhoneNumberField(phoneNumbers[i]);
+		}
+	#elseif( $!patient.phoneNumber && $patient.phoneNumber!="")
 		for( var i = 1;i<phoneNumbers.length;i++ )
 		{
 			addPhoneNumberField(phoneNumbers[i]);
 		}
 	#else 
-		setFieldValue('phoneNumber',"$!phoneNumberAreaCode")
+		setFieldValue('phoneNumber',phoneNumberAreaCode)
 	#end
 </script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm	2013-07-18 06:02:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientLocation.vm	2013-07-22 04:59:04 +0000
@@ -30,7 +30,6 @@
 					
 	#if($patient.getFullName()=='')
 	<tr>
-		<td style="background-color:#88be3b; height:26px;">&nbsp;</td>
 		<td>
 			#if($flag==true)
 				$i18n.getString('identifier'):
@@ -42,7 +41,6 @@
 	</tr>
 	#end
 	<tr>
-		<td style="background-color:#88be3b; height:26px;">&nbsp;</td>
 		<td>$i18n.getString('gender'):</td>
 		<td>
 			#if($patient.gender=='F')
@@ -53,12 +51,10 @@
 		</td>
 	</tr>
 	<tr>
-		<td style="background-color:#88be3b; height:26px;">&nbsp;</td>
 		<td>$i18n.getString('date_of_birth'):</td>
 		<td>$!format.formatDate($!patient.birthDate)</td>
 	</tr>
 	<tr>
-		<td style="background-color:#88be3b; height:26px;">&nbsp;</td>
 		<td>$i18n.getString('age'):</td>
 		<td>$!patient.getAge()</td>
 	</tr>