← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7058: local vn - Fixed bug of showing entry form.

 

------------------------------------------------------------
revno: 7058
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-05-28 15:09:58 +0700
message:
  local vn - Fixed bug of showing entry form.
modified:
  local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js


--
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 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js	2012-05-28 03:47:36 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js	2012-05-28 08:09:58 +0000
@@ -432,16 +432,16 @@
 				}
 
 				autoCompletedField();
-				
-				jQuery("#valueInput").bind('change', periodSelected);
-				jQuery("#value").bind('select', periodSelected);
+
+				jQuery("#valueInput").bind('change', periodSelected('bind change'));
+				jQuery("#value").bind('select', periodSelected('bind select'));
 				
 				showById('attributeDiv');
 			}
 			else
 			{
 				jQuery("#valueInput").unbind('change');
-				jQuery("#value").unbind('change');
+				jQuery("#value").unbind('select');
 				hideById('attributeDiv');
 			}
 			
@@ -455,7 +455,7 @@
 
 function loadDepartmentFormSelected()
 {
-    var periodName = $( '#selectedPeriodId  option:selected' ).text();
+    var periodName = $( '#selectedPeriodId option:selected' ).text();
     var dataSetId = $( '#subDataSetId option:selected' ).val();
 
     $( '#currentPeriod' ).html( periodName );
@@ -465,7 +465,7 @@
     if ( periodId && periodId != -1 && dataSetId != -1 )
     {
         showLoader();
-        loadForm( dataSetId, byId( 'valueInput' ).value );
+        loadForm( dataSetId, getFieldValue( 'valueInput' ) );
     }
 	else
 	{
@@ -475,7 +475,7 @@
 
 function periodSelected()
 {
-    var periodName = $( '#selectedPeriodId option:selected' ).text();
+	var periodName = $( '#selectedPeriodId option:selected' ).text();
     var dataSetId = $( '#selectedDataSetId option:selected' ).val();
 
     $( '#currentPeriod' ).html( periodName );
@@ -484,8 +484,12 @@
 
     if ( periodId && periodId != -1 )
     {
-        showLoader();
-        loadForm( dataSetId, getFieldValue( 'valueInput' ) );
+		if ( hasElements( 'subDataSetId' ) && getFieldValue( 'subDataSetId' ) == null ) {
+			return;
+		} else {
+			showLoader();
+			loadForm( dataSetId, getFieldValue( 'valueInput' ) );
+		}
     }
 	else
 	{
@@ -1585,21 +1589,8 @@
 			},
 			select: function( event, ui ) {
 				ui.item.option.selected = true;
-			},
-			change: function( event, ui ) {
-				if ( !ui.item ) {
-					var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
-					valid = false;
-					select.children( "option" ).each(function() {
-						if ( $( this ).text().match( matcher ) ) {
-							this.selected = valid = true;
-							return false;
-						}
-					});
-					if ( !valid ) {
-						return false;
-					}
-				}
+				setFieldValue( 'valueInput', ui.item.option.value );
+				periodSelected();
 			}
 		}).addClass( "ui-widget ui-widget-content ui-corner-left" );
 
@@ -1610,6 +1601,14 @@
 			.appendTo( ul );
 	};
 
+	input.keypress( function( e )
+	{
+		code= (e.keyCode ? e.keyCode : e.which);
+		if ( code == 13 ) {
+			periodSelected();
+		}
+	});
+	
 	showById('valueButton');
 	var button = $( "#valueButton" )
 		.attr( "title", i18n_show_all_items )