← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6550: Minor improvement

 

------------------------------------------------------------
revno: 6550
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-11 22:40:12 +0200
message:
  Minor improvement
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.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 '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	2012-04-11 20:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2012-04-11 20:40:12 +0000
@@ -1593,20 +1593,25 @@
 
 function pingNotifications( category, tableId, completedCallback )
 {	
-	var lastUid = $( '#' + tableId ).prop( 'lastUid' );
+	var lastUid = $( '#' + tableId ).prop( 'lastUid' ); // Store on table property
 	
 	var param = lastUid ? '&lastUid=' + lastUid : '';
 		
 	$.getJSON( '../dhis-web-commons-ajax-json/getNotifications.action?category=' + category + param, function( json )
 	{
 		var html = '';
-		var completedHtml = '<img src="../images/completed.png">';
+		var isComplete = false;
 		
 		$.each( json.notifications, function( i, notification )
 		{
 			var first = i == 0;
 			var loaderHtml = '';			
 			
+			if ( notification.completed == "true" )
+			{
+				isComplete = true;
+			}
+			
 			if ( first )
 			{
 				$( '#' + tableId ).prop( 'lastUid', notification.uid );
@@ -1615,15 +1620,15 @@
 			}		
 			
 			html += '<tr><td>' + notification.time + '</td><td>' + notification.message + ' &nbsp;';
-			html += notification.completed == "true" ?  completedHtml : loaderHtml;
+			html += isComplete ?  '<img src="../images/completed.png">' : loaderHtml;
 			html += '</td></tr>';
-			
-			if ( notification.completed && completedCallback && completedCallback.call )
-			{
-				completedCallback();				
-			}
 		} );
 		
 		$( '#' + tableId ).prepend( html );
+		
+		if ( isComplete && completedCallback && completedCallback.call )
+		{
+			completedCallback();				
+		}
 	} );
 }

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js	2012-04-11 20:16:18 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/importDataValue.js	2012-04-11 20:40:12 +0000
@@ -14,18 +14,19 @@
 
 function pingNotificationsTimeout()
 {
-	pingNotifications( 'DATAVALUE_IMPORT', 'notificationTable', displayImportSummaryTimeout );	
+	pingNotifications( 'DATAVALUE_IMPORT', 'notificationTable', displaySummaryLink );	
 	pingTimeout = setTimeout( "pingNotificationsTimeout()", 1500 );
 }
 
-function displayImportSummaryTimeout()
+function displaySummaryLink()
 {
-	setTimeout( "displayImportSummary()", 2000 );	
+	window.clearTimeout( pingTimeout );
+	var html = '<tr><td></td><td><a href="javascript:displaySummary()">Display import summary</a></td></tr>';
+	$( '#notificationTable' ).prepend( html );
 }
 
-function displayImportSummary()
+function displaySummary()
 {	
-	window.clearTimeout( pingTimeout );
 	$( '#notificationDiv' ).hide();
-	$( '#importSummaryDiv' ).show().load( 'getDataValueImportSummary.action' );
+	$( '#importSummaryDiv' ).show( 'slow' ).load( 'getDataValueImportSummary.action' );
 }
\ No newline at end of file