← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3998: handle error in dataentry form (also disable button while talking to server to avoid "dblclick" p...

 

------------------------------------------------------------
revno: 3998
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-06-23 09:46:26 +0300
message:
  handle error in dataentry form (also disable button while talking to server to avoid "dblclick" problem)
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/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 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2011-06-19 21:36:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/org/hisp/dhis/de/i18n_module.properties	2011-06-23 06:46:26 +0000
@@ -124,4 +124,5 @@
 change_from							= change from
 to									= to
 on									= On
-value								= Value
\ No newline at end of file
+value								= Value
+no_response_from_server				= No response from server. Please check connectivity and try again.
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm	2011-01-25 16:02:32 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/completeRegistration.vm	2011-06-23 06:46:26 +0000
@@ -1,3 +1,7 @@
+<script type="text/javascript">
+	var i18n_no_response_from_server = '$encoder.jsEscape( $i18n.getString( "no_response_from_server" ) , "'")'; 
+</script>
+
 <input type="hidden" id="curLocaleCode" value="$locale.getLanguage()_$locale.getCountry()"/>
 <hr style="clear:both">
 <input type="button" id="completeButton" name="completeButton" value="$i18n.getString( 'complete' )" onclick="validateCompleteDataSet()" style="width:120px"#if( $registration ) disabled="disabled"#end>

=== 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-06-03 14:19:24 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-06-23 06:46:26 +0000
@@ -1,22 +1,23 @@
-
-var significantZeros = []; // Identifiers for which zero values are insignificant, also used in entry.js
-var indicatorFormulas = []; // Associative array with [indicator id, expression] for indicators in form, also used in entry.js
+var significantZeros = []; // Identifiers for which zero values are
+// insignificant, also used in entry.js
+var indicatorFormulas = []; // Associative array with [indicator id, expression]
+// for indicators in form, also used in entry.js
 
 function addEventListeners()
 {
-	$( '[name="entryfield"]' ).focus( valueFocus );
-	$( '[name="entryselect"]' ).focus( valueFocus );
+    $( '[name="entryfield"]' ).focus( valueFocus );
+    $( '[name="entryselect"]' ).focus( valueFocus );
 }
 
 function clearPeriod()
-{	
-	clearListById( 'selectedPeriodIndex' );	
-	clearEntryForm();
+{
+    clearListById( 'selectedPeriodIndex' );
+    clearEntryForm();
 }
 
 function clearEntryForm()
 {
-	$( '#contentDiv' ).html( '' );
+    $( '#contentDiv' ).html( '' );
 }
 
 // -----------------------------------------------------------------------------
@@ -26,34 +27,38 @@
 function organisationUnitSelected( orgUnits )
 {
     $( '#selectedDataSetId' ).removeAttr( 'disabled' );
-    
+
     var dataSetId = $( '#selectedDataSetId' ).val();
-    
+
     var url = 'loadDataSets.action';
-    
+
     clearListById( 'selectedDataSetId' );
-    
-    $.getJSON( url, function( json ) {    
-    	$( '#selectedOrganisationUnit' ).val( json.organisationUnit.name );
-    	$( '#currentOrganisationUnit' ).html( json.organisationUnit.name );
-    	
-    	addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
-    	
-    	for ( i in json.dataSets ) {
-    		addOptionById( 'selectedDataSetId', json.dataSets[i].id, json.dataSets[i].name );
-    	}
-    	
-    	if ( json.dataSetValid && dataSetId != null ) {
-    		$( '#selectedDataSetId' ).val( dataSetId );
-    		
-    		if ( json.periodValid ) {
-    			showLoader();
-    			$( '#contentDiv' ).load( 'select.action', displayEntryFormCompleted );
-    		}
-    	}
-    	else {
-    		clearPeriod();
-    	}
+
+    $.getJSON( url, function( json )
+    {
+        $( '#selectedOrganisationUnit' ).val( json.organisationUnit.name );
+        $( '#currentOrganisationUnit' ).html( json.organisationUnit.name );
+
+        addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
+
+        for ( i in json.dataSets )
+        {
+            addOptionById( 'selectedDataSetId', json.dataSets[i].id, json.dataSets[i].name );
+        }
+
+        if ( json.dataSetValid && dataSetId != null )
+        {
+            $( '#selectedDataSetId' ).val( dataSetId );
+
+            if ( json.periodValid )
+            {
+                showLoader();
+                $( '#contentDiv' ).load( 'select.action', displayEntryFormCompleted );
+            }
+        } else
+        {
+            clearPeriod();
+        }
     } );
 }
 
@@ -65,43 +70,45 @@
 
 function nextPeriodsSelected()
 {
-	displayPeriodsInternal( true, false );
+    displayPeriodsInternal( true, false );
 }
 
 function previousPeriodsSelected()
 {
-	displayPeriodsInternal( false, true );
+    displayPeriodsInternal( false, true );
 }
 
-function displayPeriodsInternal( next, previous ) 
+function displayPeriodsInternal( next, previous )
 {
-	disableNextPrevButtons();
-	
-	var url = 'loadNextPreviousPeriods.action?next=' + next + '&previous=' + previous;
-	
-	clearListById( 'selectedPeriodIndex' );
-	    
-    $.getJSON( url, function( json ) {    	
-		addOptionById( 'selectedPeriodIndex', '-1', '[ ' + i18n_select_period + ' ]' );
-	
-    	for ( i in json.periods ) {
-    		addOptionById( 'selectedPeriodIndex', i, json.periods[i].name );
-    	}
-    	
-    	enableNextPrevButtons();
+    disableNextPrevButtons();
+
+    var url = 'loadNextPreviousPeriods.action?next=' + next + '&previous=' + previous;
+
+    clearListById( 'selectedPeriodIndex' );
+
+    $.getJSON( url, function( json )
+    {
+        addOptionById( 'selectedPeriodIndex', '-1', '[ ' + i18n_select_period + ' ]' );
+
+        for ( i in json.periods )
+        {
+            addOptionById( 'selectedPeriodIndex', i, json.periods[i].name );
+        }
+
+        enableNextPrevButtons();
     } );
 }
 
 function disableNextPrevButtons()
 {
-	$( '#nextButton' ).attr( 'disabled', 'disabled' );
-	$( '#prevButton' ).attr( 'disabled', 'disabled' );
+    $( '#nextButton' ).attr( 'disabled', 'disabled' );
+    $( '#prevButton' ).attr( 'disabled', 'disabled' );
 }
 
 function enableNextPrevButtons()
 {
-	$( '#nextButton' ).removeAttr( 'disabled' );
-	$( '#prevButton' ).removeAttr( 'disabled' );
+    $( '#nextButton' ).removeAttr( 'disabled' );
+    $( '#prevButton' ).removeAttr( 'disabled' );
 }
 
 // -----------------------------------------------------------------------------
@@ -113,36 +120,39 @@
     $( '#selectedPeriodIndex' ).removeAttr( 'disabled' );
     $( '#prevButton' ).removeAttr( 'disabled' );
     $( '#nextButton' ).removeAttr( 'disabled' );
-    
-	var dataSetId = $( '#selectedDataSetId' ).val();	
-	var periodIndex = $( '#selectedPeriodIndex' ).val();
-	
-	if ( dataSetId && dataSetId != -1 )
-	{
-		var url = 'loadPeriods.action?dataSetId=' + dataSetId;
-
-	    clearListById( 'selectedPeriodIndex' );
-	    
-	    $.getJSON( url, function( json ) {
-	    	significantZeros = json.significantZeros;
-	    	indicatorFormulas = json.indicatorFormulas;
-	    	
-	    	addOptionById( 'selectedPeriodIndex', '-1', '[ ' + i18n_select_period + ' ]' );
-		
-	    	for ( i in json.periods ) {
-	    		addOptionById( 'selectedPeriodIndex', i, json.periods[i].name );
-	    	}
-	    	
-	    	if ( json.periodValid && periodIndex != null ) {
-	    		showLoader();	    		
-	    		$( '#selectedPeriodIndex' ).val( periodIndex );
-    			$( '#contentDiv' ).load( 'select.action', setDisplayModes );
-	    	}
-	    	else {
-	    		clearEntryForm();
-	    	}
-	    } );
-	}
+
+    var dataSetId = $( '#selectedDataSetId' ).val();
+    var periodIndex = $( '#selectedPeriodIndex' ).val();
+
+    if ( dataSetId && dataSetId != -1 )
+    {
+        var url = 'loadPeriods.action?dataSetId=' + dataSetId;
+
+        clearListById( 'selectedPeriodIndex' );
+
+        $.getJSON( url, function( json )
+        {
+            significantZeros = json.significantZeros;
+            indicatorFormulas = json.indicatorFormulas;
+
+            addOptionById( 'selectedPeriodIndex', '-1', '[ ' + i18n_select_period + ' ]' );
+
+            for ( i in json.periods )
+            {
+                addOptionById( 'selectedPeriodIndex', i, json.periods[i].name );
+            }
+
+            if ( json.periodValid && periodIndex != null )
+            {
+                showLoader();
+                $( '#selectedPeriodIndex' ).val( periodIndex );
+                $( '#contentDiv' ).load( 'select.action', setDisplayModes );
+            } else
+            {
+                clearEntryForm();
+            }
+        } );
+    }
 }
 
 // -----------------------------------------------------------------------------
@@ -151,11 +161,11 @@
 
 function displayModeSelected()
 {
-	showLoader();
-	
-	var url = 'select.action?displayMode=' + $("input[name='displayMode']:checked").val();
-	
-	$( '#contentDiv' ).load( url, displayEntryFormCompleted );
+    showLoader();
+
+    var url = 'select.action?displayMode=' + $( "input[name='displayMode']:checked" ).val();
+
+    $( '#contentDiv' ).load( url, displayEntryFormCompleted );
 }
 
 // -----------------------------------------------------------------------------
@@ -164,186 +174,193 @@
 
 function periodSelected()
 {
-	var periodName = $( '#selectedPeriodIndex :selected' ).text();
-	
-	$( '#currentPeriod' ).html( periodName );
-		
-	var periodIndex = $( '#selectedPeriodIndex' ).val();
-	
-	if ( periodIndex && periodIndex != -1 )	{
-		showLoader();
-		var url = 'select.action?selectedPeriodIndex=' + periodIndex;
-		$( '#contentDiv' ).load( url, setDisplayModes );
-	}
+    var periodName = $( '#selectedPeriodIndex :selected' ).text();
+
+    $( '#currentPeriod' ).html( periodName );
+
+    var periodIndex = $( '#selectedPeriodIndex' ).val();
+
+    if ( periodIndex && periodIndex != -1 )
+    {
+        showLoader();
+        var url = 'select.action?selectedPeriodIndex=' + periodIndex;
+        $( '#contentDiv' ).load( url, setDisplayModes );
+    }
 }
 
 function displayEntryFormCompleted()
 {
-	addEventListeners();
-	hideLoader();
-	enable( 'validationButton' );
-	updateIndicators();
+    addEventListeners();
+    hideLoader();
+    enable( 'validationButton' );
+    updateIndicators();
 }
 
 function setDisplayModes()
 {
-	displayEntryFormCompleted();
-	
-	$.getJSON( 'loadDisplayModes.action', function( json ) {
-		$( '#displayModeCustom' ).removeAttr( 'disabled' );
-		$( '#displayModeSection' ).removeAttr( 'disabled' );
-		$( '#displayModeDefault' ).removeAttr( 'disabled' );
-		
-		$( '#displayModeCustom' ).removeAttr( 'checked' );
-		$( '#displayModeSection' ).removeAttr( 'checked' );
-		$( '#displayModeDefault' ).removeAttr( 'checked' );
-		
-		if ( json.displayMode == 'customform' ) {
-			$( '#displayModeCustom' ).attr( 'checked', 'checked' );
-		}
-		else if ( json.displayMode == 'sectionform' ) {
-			$( '#displayModeSection' ).attr( 'checked', 'checked' );
-		}
-		else {
-			$( '#displayModeDefault' ).attr( 'checked', 'checked' );
-		}
-		
-		if ( !json.customForm ) {
-			$( '#displayModeCustom' ).attr( 'disabled', 'disabled' );
-		}		
-		if ( !json.sectionForm ) {
-			$( '#displayModeSection' ).attr( 'disabled', 'disabled' );
-		}		
-	} );
+    displayEntryFormCompleted();
+
+    $.getJSON( 'loadDisplayModes.action', function( json )
+    {
+        $( '#displayModeCustom' ).removeAttr( 'disabled' );
+        $( '#displayModeSection' ).removeAttr( 'disabled' );
+        $( '#displayModeDefault' ).removeAttr( 'disabled' );
+
+        $( '#displayModeCustom' ).removeAttr( 'checked' );
+        $( '#displayModeSection' ).removeAttr( 'checked' );
+        $( '#displayModeDefault' ).removeAttr( 'checked' );
+
+        if ( json.displayMode == 'customform' )
+        {
+            $( '#displayModeCustom' ).attr( 'checked', 'checked' );
+        } else if ( json.displayMode == 'sectionform' )
+        {
+            $( '#displayModeSection' ).attr( 'checked', 'checked' );
+        } else
+        {
+            $( '#displayModeDefault' ).attr( 'checked', 'checked' );
+        }
+
+        if ( !json.customForm )
+        {
+            $( '#displayModeCustom' ).attr( 'disabled', 'disabled' );
+        }
+        if ( !json.sectionForm )
+        {
+            $( '#displayModeSection' ).attr( 'disabled', 'disabled' );
+        }
+    } );
 }
 
-function valueFocus(e) 
+function valueFocus( e )
 {
-	//Retrieve the data element id from the id of the field
-	var baseId = e.target.id;	
-	
-	var opId = baseId;
-	var str = baseId;
-	
-	if(	baseId.indexOf(':') != -1 )
-	{
-		opId = baseId.substr( baseId.indexOf(':')+1, baseId.length );
-		str = baseId.substr( 0, baseId.indexOf(':') );
-	}
-	
-	var match1 = /.*\[(.*)\]/.exec(str); //value[-dataElementId-]	
-	var match2 = /.*\[(.*)\]/.exec(opId); //value[-optionComboId-]
-	
-	if ( ! match1 )
-	{				
-		return;
-	}
-
-	deId = match1[1];
-	ocId = match2[1];		
-	
-	var nameContainer = document.getElementById('value[' + deId + '].name');
-	var opCbContainer = document.getElementById('value[option' + ocId + '].name');
-	var minContainer = document.getElementById('value[' + deId + ':' + ocId +'].min');	
-	var maxContainer = document.getElementById('value[' + deId + ':' + ocId +'].max');
-	
-	if ( ! nameContainer )
-	{		
-		return;
-	}
-
-	var name = '';
-	var optionName = '';
-	
-	var as = nameContainer.getElementsByTagName('a');
-
-	if ( as.length > 0 )	//Admin rights: Name is in a link
-	{
-		name = as[0].firstChild.nodeValue;
-	} 
-	else 
-	{
-		name = nameContainer.firstChild.nodeValue;
-	}
-	
-	if( opCbContainer )
-	{	    
-		if( opCbContainer.firstChild )
-		{
-		    optionName = opCbContainer.firstChild.nodeValue;
-		}			
-	}
-	
-	if( minContainer )
-	{	    	    
-	    if( minContainer.firstChild )
-	    {        
-	        optionName += " - "+minContainer.firstChild.nodeValue; 
-	    }	    
-	}
-	
-	if( maxContainer )
-	{
-	    if( maxContainer.firstChild )
-	    {
-	        optionName += " - "+maxContainer.firstChild.nodeValue;
-	    }
-	}
-	    
-    var curDeSpan = document.getElementById('currentDataElement');
-     
+    // Retrieve the data element id from the id of the field
+    var baseId = e.target.id;
+
+    var opId = baseId;
+    var str = baseId;
+
+    if ( baseId.indexOf( ':' ) != -1 )
+    {
+        opId = baseId.substr( baseId.indexOf( ':' ) + 1, baseId.length );
+        str = baseId.substr( 0, baseId.indexOf( ':' ) );
+    }
+
+    var match1 = /.*\[(.*)\]/.exec( str ); // value[-dataElementId-]
+    var match2 = /.*\[(.*)\]/.exec( opId ); // value[-optionComboId-]
+
+    if ( !match1 )
+    {
+        return;
+    }
+
+    deId = match1[1];
+    ocId = match2[1];
+
+    var nameContainer = document.getElementById( 'value[' + deId + '].name' );
+    var opCbContainer = document.getElementById( 'value[option' + ocId + '].name' );
+    var minContainer = document.getElementById( 'value[' + deId + ':' + ocId + '].min' );
+    var maxContainer = document.getElementById( 'value[' + deId + ':' + ocId + '].max' );
+
+    if ( !nameContainer )
+    {
+        return;
+    }
+
+    var name = '';
+    var optionName = '';
+
+    var as = nameContainer.getElementsByTagName( 'a' );
+
+    if ( as.length > 0 ) // Admin rights: Name is in a link
+    {
+        name = as[0].firstChild.nodeValue;
+    } else
+    {
+        name = nameContainer.firstChild.nodeValue;
+    }
+
+    if ( opCbContainer )
+    {
+        if ( opCbContainer.firstChild )
+        {
+            optionName = opCbContainer.firstChild.nodeValue;
+        }
+    }
+
+    if ( minContainer )
+    {
+        if ( minContainer.firstChild )
+        {
+            optionName += " - " + minContainer.firstChild.nodeValue;
+        }
+    }
+
+    if ( maxContainer )
+    {
+        if ( maxContainer.firstChild )
+        {
+            optionName += " - " + maxContainer.firstChild.nodeValue;
+        }
+    }
+
+    var curDeSpan = document.getElementById( 'currentDataElement' );
+
     curDeSpan.firstChild.nodeValue = name;
-    
-    document.getElementById("currentOptionCombo").innerHTML  = optionName;
-	
+
+    document.getElementById( "currentOptionCombo" ).innerHTML = optionName;
+
 }
 
 function keyPress( event, field )
 {
     var key = event.keyCode || event.charCode || event.which;
-    
-    var focusField = ( key == 13 || key == 40 ) ? getNextEntryField( field ) : ( key == 38 ) ? getPreviousEntryField( field ) : false;
-    
+
+    var focusField = ( key == 13 || key == 40 ) ? getNextEntryField( field )
+            : ( key == 38 ) ? getPreviousEntryField( field ) : false;
+
     if ( focusField )
     {
         focusField.focus();
     }
-    
+
     return true;
 }
 
 function getNextEntryField( field )
 {
-	var index = field.getAttribute( 'tabindex' );
-	
-	field = $( 'input[name="entryfield"][tabindex="' + (++index) + '"]' );
-	
-	while ( field )
-	{
-		if ( field.is( ':disabled' ) || field.is( ':hidden' ) ) {
-			field = $( 'input[name="entryfield"][tabindex="' + (++index) + '"]' );
-		}
-		else {
-			return field;
-		}
-	}
+    var index = field.getAttribute( 'tabindex' );
+
+    field = $( 'input[name="entryfield"][tabindex="' + ( ++index ) + '"]' );
+
+    while ( field )
+    {
+        if ( field.is( ':disabled' ) || field.is( ':hidden' ) )
+        {
+            field = $( 'input[name="entryfield"][tabindex="' + ( ++index ) + '"]' );
+        } else
+        {
+            return field;
+        }
+    }
 }
 
 function getPreviousEntryField( field )
 {
-	var index = field.getAttribute( 'tabindex' );
-	
-	field = $( 'input[name="entryfield"][tabindex="' + (--index) + '"]' );
-	
-	while ( field )
-	{
-		if ( field.is( ':disabled' ) || field.is( ':hidden' ) )	{
-			field = $( 'input[name="entryfield"][tabindex="' + (--index) + '"]' );
-		}
-		else {
-			return field;
-		}
-	}
+    var index = field.getAttribute( 'tabindex' );
+
+    field = $( 'input[name="entryfield"][tabindex="' + ( --index ) + '"]' );
+
+    while ( field )
+    {
+        if ( field.is( ':disabled' ) || field.is( ':hidden' ) )
+        {
+            field = $( 'input[name="entryfield"][tabindex="' + ( --index ) + '"]' );
+        } else
+        {
+            return field;
+        }
+    }
 }
 
 // -----------------------------------------------------------------------------
@@ -352,37 +369,61 @@
 
 function validateCompleteDataSet()
 {
-	var confirmed = confirm( i18n_confirm_complete );
-	
-	if ( confirmed ) {
-		$.getJSON( 'getValidationViolations.action', registerCompleteDataSet );
-	}
+    var confirmed = confirm( i18n_confirm_complete );
+
+    if ( confirmed )
+    {
+        $( '#completeButton' ).attr( 'disabled', 'disabled' );
+        $( '#undoButton' ).removeAttr( 'disabled' );
+
+        $.getJSON( 'getValidationViolations.action', registerCompleteDataSet ).error( function()
+        {
+            $( '#completeButton' ).removeAttr( 'disabled' );
+            $( '#undoButton' ).attr( 'disabled', 'disabled' );
+
+            alert( i18n_no_response_from_server );
+        } );
+    }
 }
 
 function registerCompleteDataSet( json )
 {
-	if ( json.response == 'success' ) {
-		$.getJSON( 'registerCompleteDataSet.action', function() {
-			$( '#completeButton' ).attr( 'disabled', 'disabled' );
-			$( '#undoButton' ).removeAttr( 'disabled' );
-		} );
-	}
-	else {
-		window.open( 'validate.action', '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );
-	}
+    if ( json.response == 'success' )
+    {
+        $.getJSON( 'registerCompleteDataSet.action', function()
+        {
+        } ).error( function()
+        {
+            $( '#completeButton' ).removeAttr( 'disabled' );
+            $( '#undoButton' ).attr( 'disabled', 'disabled' );
+
+            alert( i18n_no_response_from_server );
+        } );
+    } else
+    {
+        window.open( 'validate.action', '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );
+    }
 }
 
 function undoCompleteDataSet()
 {
-	var confirmed = confirm( i18n_confirm_undo );
-	
-	if ( confirmed )
-	{
-		$.getJSON( 'undoCompleteDataSet.action', function() {
-			$( '#completeButton' ).removeAttr( 'disabled' );
-			$( '#undoButton' ).attr( 'disabled', 'disabled' );
-		} );
-	}
+    var confirmed = confirm( i18n_confirm_undo );
+
+    if ( confirmed )
+    {
+        $( '#completeButton' ).removeAttr( 'disabled' );
+        $( '#undoButton' ).attr( 'disabled', 'disabled' );
+
+        $.getJSON( 'undoCompleteDataSet.action', function()
+        {
+        } ).error( function()
+        {
+            $( '#completeButton' ).attr( 'disabled', 'disabled' );
+            $( '#undoButton' ).removeAttr( 'disabled' );
+
+            alert( i18n_no_response_from_server );
+        } );
+    }
 }
 
 // -----------------------------------------------------------------------------
@@ -400,15 +441,16 @@
 
 function viewHist( dataElementId, optionComboId )
 {
-	viewHistory( dataElementId, optionComboId, true );
+    viewHistory( dataElementId, optionComboId, true );
 }
 
 function viewHistory( dataElementId, optionComboId, showComment )
 {
-    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId + '&showComment=' + showComment, '_blank', 'width=580,height=710,scrollbars=yes' );
+    window.open( 'viewHistory.action?dataElementId=' + dataElementId + '&optionComboId=' + optionComboId
+            + '&showComment=' + showComment, '_blank', 'width=580,height=710,scrollbars=yes' );
 }
 
 function closeCurrentSelection()
 {
-	$( '#currentSelection' ).fadeOut();
+    $( '#currentSelection' ).fadeOut();
 }