← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2382: check existing dataelement when insert to form when design data entry form

 

------------------------------------------------------------
revno: 2382
committer: tranthanhtri <tranthanhtri@tranthanhtri-PC>
branch nick: trunk
timestamp: Mon 2010-10-18 15:12:47 +0700
message:
  check existing dataelement when insert to form when design data entry form
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-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/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-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	2010-10-15 13:15:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2010-10-18 08:12:47 +0000
@@ -822,6 +822,9 @@
 		maxDate: '+0d +0w',
 		constrainInput: true
 	});
+	
+	if( today == undefined ) today = false;
+	
 	if( today ){
 		s = jQuery("#" + id );		
 		if( s.val()=='' ) s.val( getCurrentDate() );		

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2010-10-14 08:54:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2010-10-18 08:12:47 +0000
@@ -124,4 +124,5 @@
 confirm_save                                                = This operation will change the old orgunits assigned to these datasets.\nAre you sure to save this?
 not_change_old_but_assign_new_only                          = Do not change the old assignment but assign new only.
 datasets_different_orgunitlist                              = These selected datasets are not the same the list of organsation unit.
-optional                                                    = Optional expansion
\ No newline at end of file
+optional                                                    = Optional expansion
+dataelement_is_inserted										= Data Element was inserted
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2010-10-13 05:33:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2010-10-18 08:12:47 +0000
@@ -5,11 +5,8 @@
     	
     #if($status == "EDIT")
         dataEntryFormId = $dataEntryForm.id;
-    #end
-    
-    var FCKConfig;
-    var FCK;
-
+    #end    
+  
 	var autoSave = '$!autoSave';
 	
 	var oFCKeditor;
@@ -19,14 +16,11 @@
 				autoSave = false;
 				validateDataEntryForm();
 			} );	
-
-			//oFCKeditor = new FCKeditor( 'designTextarea', "100%", 600 );
-			//oFCKeditor.BasePath = "javascript/FCK/";
-	       // oFCKeditor.ReplaceTextarea();
 						
 			jQuery("#dataElementSelection").resizable({
 				minHeight:210,
-				minWidth:300,
+				minWidth:400,
+				width:400,
 				alsoResize: "#dataElementList"				
 			});			
 			
@@ -76,6 +70,11 @@
 	margin-top:5px;
 }
 
+#message_{
+	display:block;
+	color:red;	
+}
+
 </style>
 
 
@@ -138,7 +137,7 @@
 
 <div id="dataElementSelection" class="ui-widget-content">
 <h3 class="ui-widget-header"><b>$i18n.getString( 'dataelement' )</b></h3>
-	<div id="dataElementList" style="height:150px;overflow:auto">
+	<div id="dataElementList" style="height:150px;overflow:auto;border:1px solid #7AAED5">
 	<table width="100%">
 		#foreach( $operand in $operands )
 			<tr id="tr$velocityCount" onclick="select($velocityCount)">
@@ -150,18 +149,27 @@
 		#end
 	</table>
 	</div>
-	<br>
-	<b>$i18n.getString( "view_as" )</b>
-	<select name="viewBySelector" id="viewBySelector" style="width:150px">		
-		<option value="deid">$i18n.getString( "id" )</option>
-		<option value="dename">$i18n.getString( "name" )</option>
-		<option value="deshortname" selected>$i18n.getString( "short_name" )</option> 	
-	</select>
-	<input type="button" value="Insert" onclick="insertDataElement()"/>
+	<table>
+		<tr>
+			<td>
+				<b>$i18n.getString( "view_as" )</b><br>
+				<select name="viewBySelector" id="viewBySelector" style="width:150px">		
+					<option value="deid">$i18n.getString( "id" )</option>
+					<option value="dename">$i18n.getString( "name" )</option>
+					<option value="deshortname" selected>$i18n.getString( "short_name" )</option> 	
+				</select>
+				<input type="button" value="Insert" onclick="insertDataElement()"/>
+			</td>
+			<td>
+				<span id="message_"></span>
+			</td>
+		</tr>
+	</table>	
 </div>
 
 <script>
 	var i18n_save_success = '$encoder.jsEscape( $i18n.getString( "save_success" ) , "'" )';
+	var i18n_dataelement_is_inserted = '$encoder.jsEscape( $i18n.getString( "dataelement_is_inserted" ) , "'" )';
 	
 	var t;
 	var timer_is_on=0;
@@ -225,17 +233,44 @@
 	
 	viewByValue = "@@" + viewByValue + "@@";
 	
+	var id = "";
+	var html = "";
+	
 	if (dataElementType == "bool")
 	{
-		oEditor.InsertHtml("<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryselect\" id=\""+ boolDataEntryId +"\" style=\"width:4em;text-align:center\"/>" );			
-		
-	}	
-	else 
+		id = boolDataEntryId;
+		html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryselect\" id=\""+ boolDataEntryId +"\" style=\"width:4em;text-align:center\"/>";
+		
+		
+	}else 
 	{	
-		oEditor.InsertHtml("<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + dataEntryId + "\" style=\"width:4em;text-align:center\"/>");			
-			
+		id = dataEntryId;
+		html = "<input title=\"" + titleValue + "\" view=\""+viewByValue+"\" value=\"" + displayName + "\" name=\"entryfield\" id=\"" + dataEntryId + "\" style=\"width:4em;text-align:center\"/>" ;			
 	}	
 	
-}
+	if( checkExisted( id ) )
+	{		
+		jQuery( "#message_").html( "<b>" + i18n_dataelement_is_inserted + "</b>" );
+		return;
+	}else{
+		jQuery( "#message_").html("");
+	}
+	
+	oEditor.InsertHtml( html );
+	
+}
+
+function checkExisted( id )
+{	
+	var result = false;
+	var html = FCKeditorAPI.GetInstance('designTextarea').GetHTML();
+	var input = jQuery( html ).find("select, :text");
+	input.each( function(i, item){		
+		if( id == item.id ) result = true;		
+	});
+	
+	return result;
+}
+
 	
 </script>