← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3133: Fix bug : Cannot insert dataelements of other program-stage while designing entry-form for progra...

 

------------------------------------------------------------
revno: 3133
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-03-23 10:34:16 +0700
message:
  Fix bug : Cannot insert dataelements of other program-stage while designing entry-form for program-satage ( Patient module ).
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/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-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js	2011-03-23 02:10:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewDataEntryForm.js	2011-03-23 03:34:16 +0000
@@ -5,7 +5,7 @@
 
 jQuery(function(){
 	dataElementSelector = jQuery("#dataElementSelection").dialog({
-		title: "$i18n.getString( 'dataelement' )",
+		title: i18n_dataelement,
 		minWidth: 650,
 		minHeight: 250,
 		width:650,
@@ -14,7 +14,7 @@
 	});
 	
 	otherProgramStageDataElements = jQuery("#otherProgramStageDataElements").dialog({
-		title: "$i18n.getString( 'dataelement_of_orther_program_stage' )",
+		title: i18n_dataelement_of_orther_program_stage,
 		minWidth: 650,
 		minHeight: 250,
 		width:650,
@@ -114,98 +114,6 @@
 	});
 }
 
-function insertDataElement( source )
-{
-	var oEditor = FCKeditorAPI.GetInstance('designTextarea') ;
-	
-	var dataElement = JSON.parse( jQuery( source + ' #dataElementIds').val() );
-	if( dataElement == null )
-	{
-		jQuery( source + " #message_").html( "<b>" + i18n_specify_dataelememt + "</b>" );
-		return;
-	}else{
-		jQuery( source + " #message_").html( "" );
-	}
-	var categoryOptionCombos = getSelectedValues( source + ' #optionComboIds' );
-	
-	var associationId = $association.id;
-	
-	var dataElementId = dataElement.id;	
-	var dataElementName = dataElement.name;	
-	var dataElementType = dataElement.type;
-	var viewByValue = jQuery( source + ' #viewBySelector' ).val();	
-	
-	var strPSDataEntryId   = "value["+ associationId +"].value:value["+ dataElementId +"].value";
-    var comboPSDataEntryId = "value["+ associationId +"].combo:value["+ dataElementId +"].combo";
-    var boolPSDataEntryId  = "value["+ associationId +"].boolean:value["+ dataElementId +"].boolean";
-    var datePSDataEntryId  = "value["+ associationId +"].date:value["+ dataElementId +"].date";
-	
-	if(viewByValue == "deid") dispName = "[ " + dataElementId;
-	else if (viewByValue == "deshortname") dispName = "[ " + dataElement.shortName;
-	else dispName = "[ " + dataElementName;
-	
-	viewByValue = "@@" + viewByValue + "@@";
-	
-	var id = "";
-	
-	var selectString = "";
-	
-	if( dataElementType == "string" )
-	{
-		if( categoryOptionCombos[0].default == 'true' )
-		{			
-			strPSDataEntryId  = strPSDataEntryId + ":value["+ categoryOptionCombos[0].id +"].value";
-			selectString += "<input name=\"entryfield\" id=\""+strPSDataEntryId+"\" type=\"text\" value=\"\" onkeypress=\"return keyPress(event, this)\" >";			
-			id = strPSDataEntryId;
-		}else{			
-			selectString = "<select name=\"entryselect\" id=\"" + comboPSDataEntryId + "\" > <option value=\"\">i18n_select_value</option>";
-		
-			jQuery.each( categoryOptionCombos, function(i, item ){
-				selectString += "<option value=\""+ item.id +"\" id=\"combo[" + item.id + "].combo\" >(" + item.name + ")</option>";
-			});
-			
-			selectString += "</select>";
-			
-			id = comboPSDataEntryId;
-		}		
-		
-	}else if (dataElementType == "bool")
-	{
-		selectString = "<select name=\"entryselect\" id=\"" + boolPSDataEntryId + "\" > <option value=\"\">i18n_select_value</option>";
-		selectString += "<option value=\"true\" >i18n_yes</option>";
-		selectString += "<option value=\"false\" >i18n_no</option>";
-		selectString += "</select>";
-		
-		id = boolPSDataEntryId;
-	}else if (dataElementType == "date")
-	{
-		selectString = "<input type=\"text\" id=\"" + datePSDataEntryId + "\" name=\"entryfield\" value=\"\">";	
-		id = datePSDataEntryId;
-	} else if ( dataElementType == "int" )
-	{
-		jQuery.each( categoryOptionCombos, function(i, item ){
-			optionComboName = item.name;
-			optionComboId = item.id;
-			var titleValue = "-- " + dataElementId + ". "+ dataElementName+" " + optionComboId + ". " + optionComboName+" ("+dataElementType+") --";
-			var displayName = dispName + " - " + optionComboName + " ]";
-			var dataEntryId = "value[" + associationId + "].value:value[" + dataElementId + "].value:value[" + optionComboId + "].value";
-			selectString += "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + dataEntryId + "\" style=\"width:10em;text-align:center\"/><br/>";
-			id = dataEntryId;
-		});
-	}
-	
-	if( checkExisted( id ) )
-	{		
-		jQuery( source + " #message_").html( "<b>" + i18n_dataelement_is_inserted + "</b>" );
-		return;
-	}else{
-		jQuery( source + " #message_").html("");
-	}
-	
-	oEditor.InsertHtml( selectString );
-	
-}
-
 function getSelectedValues( jQueryString )
 {
 	var result = new Array();
@@ -268,6 +176,96 @@
     	    	}
     	    }
     	);
+}
+
+
+	function insertDataElement( source, associationId )
+	{
+		var oEditor = FCKeditorAPI.GetInstance('designTextarea') ;
+
+		var dataElement = JSON.parse( jQuery( source + ' #dataElementIds').val() );
+		if( dataElement == null )
+		{
+			jQuery( source + " #message_").html( "<b>" + i18n_specify_dataelememt + "</b>" );
+			return;
+		}else{
+			jQuery( source + " #message_").html( "" );
+		}
+		var categoryOptionCombos = getSelectedValues( source + ' #optionComboIds' );
+
+		var dataElementId = dataElement.id;	
+		var dataElementName = dataElement.name;	
+		var dataElementType = dataElement.type;
+		var viewByValue = jQuery( source + ' #viewBySelector' ).val();	
+
+		var strPSDataEntryId   = "value["+ associationId +"].value:value["+ dataElementId +"].value";
+		var comboPSDataEntryId = "value["+ associationId +"].combo:value["+ dataElementId +"].combo";
+		var boolPSDataEntryId  = "value["+ associationId +"].boolean:value["+ dataElementId +"].boolean";
+		var datePSDataEntryId  = "value["+ associationId +"].date:value["+ dataElementId +"].date";
+
+		if(viewByValue == "deid") dispName = "[ " + dataElementId;
+		else if (viewByValue == "deshortname") dispName = "[ " + dataElement.shortName;
+		else dispName = "[ " + dataElementName;
+
+		viewByValue = "@@" + viewByValue + "@@";
+
+		var id = "";
+
+		var selectString = "";
+
+		if( dataElementType == "string" )
+		{
+			if( categoryOptionCombos[0].default == 'true' )
+			{			
+				strPSDataEntryId  = strPSDataEntryId + ":value["+ categoryOptionCombos[0].id +"].value";
+				selectString += "<input name=\"entryfield\" id=\""+strPSDataEntryId+"\" type=\"text\" value=\"\" onkeypress=\"return keyPress(event, this)\" >";			
+				id = strPSDataEntryId;
+			}else{			
+				selectString = "<select name=\"entryselect\" id=\"" + comboPSDataEntryId + "\" > <option value=\"\">i18n_select_value</option>";
+			
+				jQuery.each( categoryOptionCombos, function(i, item ){
+					selectString += "<option value=\""+ item.id +"\" id=\"combo[" + item.id + "].combo\" >(" + item.name + ")</option>";
+				});
+				
+				selectString += "</select>";
+				
+				id = comboPSDataEntryId;
+			}		
+			
+		}else if (dataElementType == "bool")
+		{
+			selectString = "<select name=\"entryselect\" id=\"" + boolPSDataEntryId + "\" > <option value=\"\">i18n_select_value</option>";
+			selectString += "<option value=\"true\" >i18n_yes</option>";
+			selectString += "<option value=\"false\" >i18n_no</option>";
+			selectString += "</select>";
+			
+			id = boolPSDataEntryId;
+		}else if (dataElementType == "date")
+		{
+			selectString = "<input type=\"text\" id=\"" + datePSDataEntryId + "\" name=\"entryfield\" value=\"\">";	
+			id = datePSDataEntryId;
+		} else if ( dataElementType == "int" )
+		{
+			jQuery.each( categoryOptionCombos, function(i, item ){
+				optionComboName = item.name;
+				optionComboId = item.id;
+				var titleValue = "-- " + dataElementId + ". "+ dataElementName+" " + optionComboId + ". " + optionComboName+" ("+dataElementType+") --";
+				var displayName = dispName + " - " + optionComboName + " ]";
+				var dataEntryId = "value[" + associationId + "].value:value[" + dataElementId + "].value:value[" + optionComboId + "].value";
+				selectString += "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + dataEntryId + "\" style=\"width:10em;text-align:center\"/><br/>";
+				id = dataEntryId;
+			});
+		}
 		
-		//checkValueIsExist( 'name', 'validateDataEntryForm.action', {dataEntryFormId:getFieldValue('dataEntryFormId')} );
-}
+		if( checkExisted( id ) )
+		{		
+			jQuery( source + " #message_").html( "<b>" + i18n_dataelement_is_inserted + "</b>" );
+			return;
+		}else{
+			jQuery( source + " #message_").html("");
+		}
+
+		oEditor.InsertHtml( selectString );
+
+	}
+

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm	2011-03-23 02:10:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm	2011-03-23 03:34:16 +0000
@@ -86,7 +86,7 @@
             <input type="submit" name="save" value="$i18n.getString( 'save' )" style="width:100px"/>
             <input type="button" name="cancel" value="$i18n.getString( 'cancel' )" style="width:100px" onclick="window.location='programStage.action?id=$!programStageId'">            
 			#if( $!dataEntryForm )
-			<input type="button" name="delete" value="$i18n.getString( 'delete' )" style="width:100px" onclick="deleteDataEntryForm( $association.id )" />
+			<input type="button" name="delete" value="$i18n.getString( 'delete' )" style="width:100px" onclick="deleteDataEntryForm( $programStage.id )" />
 			#end
         </td>		
     </tr>
@@ -124,7 +124,7 @@
 					<option value="dename">$i18n.getString( "name" )</option>
 					<option value="deshortname" selected>$i18n.getString( "short_name" )</option> 	
 				</select>
-				<input type="button" value="Insert" id="insert" name="insert" onclick="insertDataElement( '#dataElementSelection')"/>
+				<input type="button" value="Insert" id="insert" name="insert" onclick="insertDataElement( '#dataElementSelection', '$programStage.id')"/>
 			</td>
 			<td>
 				<span id="message_"></span>
@@ -166,10 +166,10 @@
 					<option value="dename">$i18n.getString( "name" )</option>
 					<option value="deshortname" selected>$i18n.getString( "short_name" )</option> 	
 				</select>
-				<input type="button" value="Insert" id="insert" name="insert" onclick="insertDataElement( '#otherProgramStageDataElements')"/>
+				<input type="button" value="Insert" id="insert" name="insert" onclick="insertDataElement( '#otherProgramStageDataElements', byId('programStageIds').value )"/>
 			</td>
 			<td>
-				<span id="message"></span>
+				<span id="message_"></span>
 			</td>
 		</tr>
 	</table>	
@@ -188,18 +188,13 @@
 <script type="text/javascript">   
     var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
 	var i18n_specify_dataelememt = '$encoder.jsEscape( $i18n.getString( "specify_dataelememt" ) , "'" )';
-    var i18n_choose_existing_dataentry = "$i18n.getString( 'choose_existing_dataentry' )";
+    var i18n_choose_existing_dataentry ='$encoder.jsEscape( $i18n.getString( "choose_existing_dataentry" ) , "'" )';
+	var i18n_dataelement = "$i18n.getString( 'dataelement' )";
+	var i18n_dataelement_of_orther_program_stage = "$i18n.getString( 'dataelement_of_orther_program_stage' )";
 	
 	jQuery(document).ready(	function()
 	{		
-		validation( 'saveDataEntryForm', function( form ){ validateDataEntryForm();});		
-		
-		/* #if( $!dataEntryForm )
-			checkValueIsExist('name', 'validateDataEntryForm.action', {dataEntryFormId:getFieldValue('dataEntryFormId')});
-		#else
-			checkValueIsExist('name', 'validateDataEntryForm.action');
-		#end */
-		
+		validation( 'saveDataEntryForm', function( form ){ validateDataEntryForm();});
 	});
 	
 	var previousName = '';