← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4366: Data entry, displaying progress indicator and disabling data set selection until meta-data is ready

 

------------------------------------------------------------
revno: 4366
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-08-19 10:39:08 +0200
message:
  Data entry, displaying progress indicator and disabling data set selection until meta-data is ready
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-08-18 17:44:21 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-08-19 08:39:08 +0000
@@ -51,13 +51,13 @@
  * Page init. The order of events is:
  * 
  * 1. Load ouwt
- * 2. Load meta-data
- * 3. Upload potential locally stored data values to server
- * 4. Check and potentially download updated forms from server 
+ * 2. Load meta-data (and notify ouwt)
+ * 3. Check and potentially download updated forms from server 
  */
 $( document ).ready( function()
 {
     selection.setListenerFunction( organisationUnitSelected );
+    $( '#loaderSpan' ).show();
 
     $( '#orgUnitTree' ).one( 'ouwtLoaded', function() {
     	console.log( 'Ouwt loaded' );    	
@@ -120,7 +120,10 @@
 		dataSetAssociationSets = json.metaData.dataSetAssociationSets;
 		organisationUnitAssociationSetMap = json.metaData.organisationUnitAssociationSetMap;
 		
-		console.log( 'Meta-data loaded' );		
+		selection.responseReceived(); // Notify that meta data is loaded
+		$( '#loaderSpan' ).hide();
+		console.log( 'Meta-data loaded' );	
+		
 	    updateForms();
 	} );
 }
@@ -358,46 +361,47 @@
     currentOrganisationUnitId = orgUnits[0];
     var organisationUnitName = orgUnitNames[0];
 
-    $( '#selectedDataSetId' ).removeAttr( 'disabled' );
-
-    var dataSetId = $( '#selectedDataSetId' ).val();
-    var periodId = $( '#selectedPeriodId' ).val();
-
     $( '#selectedOrganisationUnit' ).val( organisationUnitName );
     $( '#currentOrganisationUnit' ).html( organisationUnitName );
 
-    clearListById( 'selectedDataSetId' );
-
-    addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
-
     var dataSetList = getSortedDataSetList();
 
-    var dataSetValid = false;
-
-    for ( i in dataSetList )
-    {
-        addOptionById( 'selectedDataSetId', dataSetList[i].id, dataSetList[i].name );
-
-        if ( dataSetId == dataSetList[i].id )
-        {
-            dataSetValid = true;
-        }
-    }
-
-    if ( dataSetValid && dataSetId != null )
-    {
-        $( '#selectedDataSetId' ).val( dataSetId );
-
-        if ( periodId && periodId != -1 && dataEntryFormIsLoaded )
-        {
-            showLoader();
-            loadDataValues();
-        }
-    }
-    else
-    {
-        clearPeriod();
-    }
+	if ( dataSetList.length )
+	{
+	    $( '#selectedDataSetId' ).removeAttr( 'disabled' );	
+	    clearListById( 'selectedDataSetId' );	
+	    addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
+	
+	    var dataSetId = $( '#selectedDataSetId' ).val();
+	    var periodId = $( '#selectedPeriodId' ).val();
+	
+	    var dataSetValid = false;
+	
+	    for ( i in dataSetList )
+	    {
+	        addOptionById( 'selectedDataSetId', dataSetList[i].id, dataSetList[i].name );
+	
+	        if ( dataSetId == dataSetList[i].id )
+	        {
+	            dataSetValid = true;
+	        }
+	    }
+	
+	    if ( dataSetValid && dataSetId != null )
+	    {
+	        $( '#selectedDataSetId' ).val( dataSetId );
+	
+	        if ( periodId && periodId != -1 && dataEntryFormIsLoaded )
+	        {
+	            showLoader();
+	            loadDataValues();
+	        }
+	    }
+	    else
+	    {
+	        clearPeriod();
+	    }
+	}
 }
 
 // -----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-08-18 12:59:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm	2011-08-19 08:39:08 +0000
@@ -51,7 +51,8 @@
 	</tr>	
 	<tr>
 		<td><label for="selectedDataSetId">$i18n.getString( "data_set" )</label></td>
-		<td><select id="selectedDataSetId" name="selectedDataSetId" style="width:350px" onchange="dataSetSelected()" disabled="disabled"></select></td>
+		<td><select id="selectedDataSetId" name="selectedDataSetId" style="width:350px" onchange="dataSetSelected()" disabled="disabled"></select>
+			<span id="loaderSpan" style="display:none"><img src='../images/ajax-loader-bar.gif'></span></td>
 	</tr>	
 	<tr>
 		<td><label for="selectedPeriodId">$i18n.getString( "period" )</label></td>