← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10537: remove need for psiid when adding comments in data entry forms (reuse #programStageInstanceId)

 

------------------------------------------------------------
revno: 10537
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-04-13 14:22:28 +0700
message:
  remove need for psiid when adding comments in data entry forms (reuse #programStageInstanceId)
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
  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/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.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-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2013-04-13 06:52:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2013-04-13 07:22:28 +0000
@@ -29,7 +29,7 @@
 			<th class='coordinates1'><label for="latitude">&nbsp;$i18n.getString( "latitude" )</label></th>
 			<th class='coordinates2'>
 				<input type="text" class='criteria' id="latitude" name="latitude" class="{validate:{number:true,min:-90,max:90}}" placeholder='$i18n.getString("enter_a_number")' >
-				<img style='cursor:pointer' src='images/save.png' title='$i18n.getString("save")' onclick='saveCoordinatesEvent($!programStageInstance.id);' />
+				<img style='cursor:pointer' src='images/save.png' title='$i18n.getString("save")' onclick='saveCoordinatesEvent();' />
 			</th>
 		</tr>
 		#end
@@ -37,7 +37,9 @@
 		<tr>
 			<th class='coordinates1'><label for="postComment">$i18n.getString('post_comment'):</label></th>
 			<th colspan='3'>
-				<input type="text" class="{validate:{maxlength:160}} criteria" name="comment_$programStageInstance.id" id="comment_$programStageInstance.id" style="width:430px;#if($programStageInstance.programStage.captureCoordinates=='false') margin-left:10px; #end " onkeypress="keypressOnComent(event,this,$programStageInstance.id);">
+				<input type="text" class="{validate:{maxlength:160}} criteria"
+                        style="width:430px;#if($programStageInstance.programStage.captureCoordinates=='false') margin-left:10px; #end "
+                       onkeypress="keypressOnComment( event, this );">
 			</th>
 		</tr>
 

=== 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-04-12 08:25:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2013-04-13 07:22:28 +0000
@@ -1821,8 +1821,12 @@
 		});
 }
 
-function keypressOnComent(event, field, programStageInstanceId )
+function keypressOnComment(event, field, programStageInstanceId )
 {
+    if(!programStageInstanceId) {
+        programStageInstanceId = $( "#entryFormContainer input[id='programStageInstanceId']" ).val();
+    }
+
 	var key = getKeyCode( event );
 	if ( key==13 ){ // Enter
 		addComment( field, programStageInstanceId );
@@ -1849,10 +1853,12 @@
 			var date = new Date();
 			var currentTime = date.getHours() + ":" + date.getMinutes();
 			var content = "<tr><td>" + getCurrentDate("currentDate") + " " + currentTime + "</td>"
+
 			if(programStageName!=undefined)
 			{
 				content += "<td>" + programStageName + "</td>"
 			}
+
 			content += "<td>" + getFieldValue('currentUsername') + "</td>"
 			content += "<td>" + commentText + "</td></tr>";
 			jQuery('#commentTB').prepend(content);
@@ -1876,7 +1882,7 @@
 {
 	jQuery.postUTF8( 'removePatientComment.action',
 		{
-			programStageInstanceId:programStageInstanceId,
+			programStageInstanceId: programStageInstanceId,
 			id: commentId
 		}, function ( json )
 		{
@@ -1969,12 +1975,13 @@
      $tbody.find( 'tr:visible:odd' ).removeClass( 'listRow' ).removeClass( 'listAlternateRow' ).addClass( 'listAlternateRow' );
 }
 
-function saveCoordinatesEvent(programStageInstanceId)
+function saveCoordinatesEvent()
 {
+	var programStageInstanceId = $( "#entryFormContainer input[id='programStageInstanceId']" ).val();
 	var longitude = jQuery.trim(getFieldValue('longitude'));
 	var latitude = jQuery.trim(getFieldValue('latitude'));
 	var isValid = true;
-	
+
 	if(longitude=='' && latitude==''){
 		isValid = true;
 	}
@@ -2016,7 +2023,7 @@
 	if( isValid ){
 		jQuery.postJSON( "saveCoordinatesEvent.action",
 			{ 
-				programStageInstanceId:programStageInstanceId,
+				programStageInstanceId: programStageInstanceId,
 				longitude: longitude,
 				latitude: latitude
 			}, 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-04-13 06:52:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-04-13 07:22:28 +0000
@@ -634,8 +634,9 @@
         type: 'GET',
         dataType: 'json'
     } ).done(function(data) {
+        $( "#programStageInstanceId" ).val( data.id );
+        $( "#entryFormContainer input[id='programStageInstanceId']" ).val( data.id );
         $( "#entryFormContainer input[id='incidentDate']" ).val( data.programInstance.dateOfIncident );
-        $( "#entryFormContainer input[id='programStageInstanceId']" ).val( data.id );
         $( "#entryFormContainer input[id='programInstanceId']" ).val( data.programInstance.id );
         $( "#entryFormContainer input[id='irregular']" ).val( data.programStage.irregular );
         $( "#entryFormContainer input[id='displayGenerateEventBox']" ).val( data.programStage.displayGenerateEventBox );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2013-04-10 04:45:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingList.vm	2013-04-13 07:22:28 +0000
@@ -98,7 +98,7 @@
 				<tr>
 					<td>$i18n.getString( "post_comment" )</td>
 					<td>
-						<input type='text' id='commentText' name='commentText' onkeypress="keypressOnComent(event,this,'$programStageInstance.id');">
+						<input type='text' id='commentText' name='commentText' onkeypress="keypressOnComment(event,this,'$programStageInstance.id');">
 						<input type='button' value="+" class='tiny-button' title='$i18n.getString("post_comment")' onclick="addComment( byId('commentText'),'$programStageInstance.id');">
 					</td>
 				</tr>