dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13594
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4393: Disabling caching with jquery instead. Made it consistent in whole module for it to work properly...
------------------------------------------------------------
revno: 4393
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-08-20 12:17:48 +0200
message:
Disabling caching with jquery instead. Made it consistent in whole module for it to work properly in IE.
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
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/history.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/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-19 23:11:39 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-20 10:17:48 +0000
@@ -225,11 +225,12 @@
storageManager.saveDataValue( dataValue );
$.ajax( {
- url : 'saveValue.action',
- data : dataValue,
- dataType : 'json',
- success : handleSuccess,
- error : handleError
+ url: 'saveValue.action',
+ data: dataValue,
+ dataType: 'json',
+ cache: false,
+ success: handleSuccess,
+ error: handleError
} );
};
=== 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-19 23:11:39 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-20 10:17:48 +0000
@@ -125,27 +125,32 @@
{
var KEY_METADATA = 'metadata';
- $.getJSON( 'getMetaData.action', function( json )
- {
- sessionStorage[KEY_METADATA] = JSON.stringify( json.metaData );
- } ).complete( function()
- {
-
- var metaData = JSON.parse( sessionStorage[KEY_METADATA] );
-
- significantZeros = metaData.significantZeros;
- dataElements = metaData.dataElements;
- indicatorFormulas = metaData.indicatorFormulas;
- dataSets = metaData.dataSets;
- dataSetAssociationSets = metaData.dataSetAssociationSets;
- organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;
-
- selection.responseReceived(); // Notify that meta data is loaded
- $( '#loaderSpan' ).hide();
- console.log( 'Meta-data loaded' );
-
- updateForms();
- } );
+ $.ajax( {
+ url: 'getMetaData.action',
+ cache: false,
+ dataType: 'json',
+ success: function( json )
+ {
+ sessionStorage[KEY_METADATA] = JSON.stringify( json.metaData );
+ },
+ complete: function()
+ {
+ var metaData = JSON.parse( sessionStorage[KEY_METADATA] );
+
+ significantZeros = metaData.significantZeros;
+ dataElements = metaData.dataElements;
+ indicatorFormulas = metaData.indicatorFormulas;
+ dataSets = metaData.dataSets;
+ dataSetAssociationSets = metaData.dataSetAssociationSets;
+ organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;
+
+ selection.responseReceived(); // Notify that meta data is loaded
+ $( '#loaderSpan' ).hide();
+ console.log( 'Meta-data loaded' );
+
+ updateForms();
+ }
+ } );
}
function uploadLocalData()
@@ -176,10 +181,11 @@
console.log( 'Uploaded complete data set: ' + key + ', with value: ' + value );
$.ajax( {
- url : 'registerCompleteDataSet.action',
- data : value,
- dataType : 'json',
- success : function( data, textStatus, jqXHR )
+ url: 'registerCompleteDataSet.action',
+ data: value,
+ dataType: 'json',
+ cache: false,
+ success: function( data, textStatus, jqXHR )
{
console.log( 'Successfully saved complete dataset with value: ' + value );
storageManager.clearCompleteDataSet( value );
@@ -210,10 +216,11 @@
console.log( 'Uploaded data value: ' + key + ', with value: ' + value );
$.ajax( {
- url : 'saveValue.action',
- data : value,
- dataType : 'json',
- success : function( data, textStatus, jqXHR )
+ url: 'saveValue.action',
+ data: value,
+ dataType: 'json',
+ cache: false,
+ success: function( data, textStatus, jqXHR )
{
storageManager.clearDataValueJSON( value );
console.log( 'Successfully saved data value with value: ' + value );
@@ -558,70 +565,75 @@
$( '[name="entryfield"]' ).filter( ':disabled' ).css( 'background-color', COLOR_GREY );
- $.getJSON( 'getDataValues.action',
- {
- periodId : periodId,
- dataSetId : dataSetId,
- organisationUnitId : currentOrganisationUnitId
- },
- function( json )
- {
- // Set data values, works for select lists too as data
- // value = select value
-
- $.each( json.dataValues, function( i, value )
- {
- var fieldId = '#' + value.id + '-val';
-
- if ( $( fieldId ) )
- {
- $( fieldId ).val( value.val );
- }
-
- dataValueMap[value.id] = value.val;
- } );
-
- // Set min-max values and colorize violation fields
-
- $.each( json.minMaxDataElements, function( i, value )
- {
- var minId = value.id + '-min';
- var maxId = value.id + '-max';
-
- var valFieldId = '#' + value.id + '-val';
-
- var dataValue = dataValueMap[value.id];
-
- if ( dataValue
- && ( ( value.min && new Number( dataValue ) < new Number( value.min ) ) || ( value.max && new Number(
- dataValue ) > new Number( value.max ) ) ) )
- {
- $( valFieldId ).css( 'background-color', COLOR_ORANGE );
- }
-
- currentMinMaxValueMap[minId] = value.min;
- currentMinMaxValueMap[maxId] = value.max;
- } );
-
- // Update indicator values in form
-
- updateIndicators();
-
- // Set completeness button
-
- if ( json.complete )
- {
- $( '#completeButton' ).attr( 'disabled', 'disabled' );
- $( '#undoButton' ).removeAttr( 'disabled' );
- }
- else
- {
- $( '#completeButton' ).removeAttr( 'disabled' );
- $( '#undoButton' ).attr( 'disabled', 'disabled' );
- }
-
- // TODO locking
- } );
+ $.ajax( {
+ url: 'getDataValues.action',
+ data:
+ {
+ periodId : periodId,
+ dataSetId : dataSetId,
+ organisationUnitId : currentOrganisationUnitId
+ },
+ cache: false,
+ dataType: 'json',
+ success: function( json )
+ {
+ // Set data values, works for select lists too as data
+ // value = select value
+
+ $.each( json.dataValues, function( i, value )
+ {
+ var fieldId = '#' + value.id + '-val';
+
+ if ( $( fieldId ) )
+ {
+ $( fieldId ).val( value.val );
+ }
+
+ dataValueMap[value.id] = value.val;
+ } );
+
+ // Set min-max values and colorize violation fields
+
+ $.each( json.minMaxDataElements, function( i, value )
+ {
+ var minId = value.id + '-min';
+ var maxId = value.id + '-max';
+
+ var valFieldId = '#' + value.id + '-val';
+
+ var dataValue = dataValueMap[value.id];
+
+ if ( dataValue
+ && ( ( value.min && new Number( dataValue ) < new Number( value.min ) ) || ( value.max && new Number(
+ dataValue ) > new Number( value.max ) ) ) )
+ {
+ $( valFieldId ).css( 'background-color', COLOR_ORANGE );
+ }
+
+ currentMinMaxValueMap[minId] = value.min;
+ currentMinMaxValueMap[maxId] = value.max;
+ } );
+
+ // Update indicator values in form
+
+ updateIndicators();
+
+ // Set completeness button
+
+ if ( json.complete )
+ {
+ $( '#completeButton' ).attr( 'disabled', 'disabled' );
+ $( '#undoButton' ).removeAttr( 'disabled' );
+ }
+ else
+ {
+ $( '#completeButton' ).removeAttr( 'disabled' );
+ $( '#undoButton' ).attr( 'disabled', 'disabled' );
+ }
+
+ // TODO locking
+ }
+ } );
}
function displayEntryFormCompleted()
@@ -726,16 +738,20 @@
disableCompleteButton();
- $.getJSON( 'getValidationViolations.action', params ).success( function( data )
- {
- registerCompleteDataSet( data );
- } ).error( function()
- {
- // no response from server, fake a positive result and save it
- registerCompleteDataSet( {
- 'response' : 'success'
- } );
- } );
+ $.ajax( { url: 'getValidationViolations.action',
+ cache: false,
+ data: params,
+ dataType: 'json',
+ success: function( data )
+ {
+ registerCompleteDataSet( data );
+ },
+ error: function()
+ {
+ // no response from server, fake a positive result and save it
+ registerCompleteDataSet( { 'response' : 'success' } );
+ }
+ } );
}
}
@@ -747,11 +763,9 @@
{
storageManager.saveCompleteDataSet( params );
- $.getJSON( 'registerCompleteDataSet.action', params ).success( function()
+ $.getJSON( 'registerCompleteDataSet.action', params, function()
{
storageManager.clearCompleteDataSet( params );
- } ).error( function()
- {
} );
}
else
@@ -1118,14 +1132,16 @@
this.downloadForm = function( dataSetId, formVersion )
{
$.ajax( {
- url : 'loadForm.action',
- data : {
+ url: 'loadForm.action',
+ data:
+ {
dataSetId : dataSetId
},
- dataType : 'text',
- dataSetId : dataSetId,
- formVersion : formVersion,
- success : function( data, textStatus, jqXHR )
+ dataSetId: dataSetId,
+ formVersion: formVersion,
+ cache: false,
+ dataType: 'text',
+ success: function( data, textStatus, jqXHR )
{
storageManager.saveForm( this.dataSetId, data );
storageManager.saveFormVersion( this.dataSetId, this.formVersion );
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2011-08-20 08:48:30 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2011-08-20 10:17:48 +0000
@@ -25,14 +25,20 @@
{
markComment( COLOR_YELLOW );
- var url = 'saveComment.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId
- + '&optionComboId=' + optionComboId + '&periodId=' + periodId + '&comment=' + value;
-
$.ajax( {
- url : url,
- dataType : 'json',
- success : handleResponse,
- error : handleError
+ url: 'saveComment.action',
+ data:
+ {
+ organisationUnitId: organisationUnitId,
+ dataElementId: dataElementId,
+ optionComboId: optionComboId,
+ periodId: periodId,
+ value: value
+ },
+ dataType: 'json',
+ cache: false,
+ success: handleResponse,
+ error: handleError
} );
};
@@ -140,20 +146,28 @@
function markValueForFollowup( dataElementId, periodId, sourceId, categoryOptionComboId )
{
- var url = 'markValueForFollowup.action?dataElementId=' + dataElementId + '&periodId=' + periodId + '&sourceId='
- + sourceId + '&categoryOptionComboId=' + categoryOptionComboId + '&r=' + Math.random();
-
- $.getJSON( url, function( json )
- {
- if ( json.message == 'marked' )
- {
- $( '#followup' ).attr( 'src', '../images/marked.png' );
- $( '#followup' ).attr( 'alt', i18n_unmark_value_for_followup );
- }
- else if ( json.message == 'unmarked' )
- {
- $( '#followup' ).attr( 'src', '../images/unmarked.png' );
- $( '#followup' ).attr( 'alt', i18n_mark_value_for_followup );
- }
- } );
+ $.ajax( { url: 'markValueForFollowup.action',
+ data:
+ {
+ dataElementId: dataElementId,
+ periodId: periodId,
+ sourceId: sourceId,
+ categoryOptionComboId: categoryOptionComboId
+ },
+ cache: false,
+ dataType: 'json',
+ success: function( json )
+ {
+ if ( json.message == 'marked' )
+ {
+ $( '#followup' ).attr( 'src', '../images/marked.png' );
+ $( '#followup' ).attr( 'alt', i18n_unmark_value_for_followup );
+ }
+ else if ( json.message == 'unmarked' )
+ {
+ $( '#followup' ).attr( 'src', '../images/unmarked.png' );
+ $( '#followup' ).attr( 'alt', i18n_mark_value_for_followup );
+ }
+ }
+ } );
}