dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13420
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4294: made dataValue into json in entry.js. created a custom trigger for when ouwt is loaded in ouwt.js.
------------------------------------------------------------
revno: 4294
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-08-15 11:02:23 +0200
message:
made dataValue into json in entry.js. created a custom trigger for when ouwt is loaded in ouwt.js.
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.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/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-08-12 16:09:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-08-15 09:02:23 +0000
@@ -38,13 +38,9 @@
if ( !skipInitialCall )
{
- jQuery( "body" ).bind( "ajaxComplete", function( e, xhr, settings )
+ $( "#orgUnitTree" ).bind( "ouwtLoaded", function()
{
- if ( settings.url.indexOf( "getOrganisationUnitTree" ) && settings.data === undefined )
- {
- selection.responseReceived();
- jQuery( "body" ).unbind( "ajaxComplete" );
- }
+ selection.responseReceived();
} );
}
};
@@ -120,6 +116,8 @@
{
sync_and_reload();
}
+
+ $( "#orgUnitTree" ).trigger( "ouwtLoaded" );
} );
};
=== 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-13 14:22:53 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-15 09:02:23 +0000
@@ -70,10 +70,10 @@
for ( k in matcher )
{
var match = matcher[k];
-
+
// Remove brackets from expression to simplify extraction of identifiers
-
- var operand = match.replace( /[\[\]]/g, '' );
+
+ var operand = match.replace( /[\[\]]/g, '' );
var dataElementId = operand.substring( 0, operand.indexOf( SEPARATOR ) );
var categoryOptionComboId = operand.substring( operand.indexOf( SEPARATOR ) + 1, operand.length );
@@ -82,7 +82,8 @@
var value = $( fieldId ) && $( fieldId ).val() ? $( fieldId ).val() : '0';
- expression = expression.replace( match, value ); // TODO signed numbers
+ expression = expression.replace( match, value ); // TODO signed
+ // numbers
}
return expression;
@@ -129,7 +130,7 @@
if ( isValidZeroNumber( value ) )
{
// If value = 0 and zero not significant for data element, skip
-
+
if ( significantZeros.indexOf( dataElementId ) == -1 )
{
$( fieldId ).css( 'background-color', COLOR_GREEN );
@@ -209,20 +210,21 @@
function ValueSaver( dataElementId_, optionComboId_, organisationUnitId_, periodId_, value_, resultColor_ )
{
- var dataElementId = dataElementId_;
- var optionComboId = optionComboId_;
- var value = value_;
+ var dataValue = {
+ "dataElementId" : dataElementId_,
+ "optionComboId" : optionComboId_,
+ "organisationUnitId" : organisationUnitId_,
+ "periodId" : periodId_,
+ "value" : value_,
+ };
+
var resultColor = resultColor_;
- var organisationUnitId = organisationUnitId_;
- var periodId = periodId_;
this.save = function()
{
- var url = 'saveValue.action?organisationUnitId=' + organisationUnitId + '&dataElementId=' + dataElementId
- + '&optionComboId=' + optionComboId + '&periodId=' + periodId + '&value=' + value;
-
$.ajax( {
- url : url,
+ url : "saveValue.action",
+ data : dataValue,
dataType : 'json',
success : handleResponse,
error : handleError
@@ -252,6 +254,6 @@
function markValue( color )
{
- $( '#' + dataElementId + '-' + optionComboId + '-val' ).css( 'background-color', color );
+ $( '#' + dataValue.dataElementId + '-' + dataValue.optionComboId + '-val' ).css( 'background-color', color );
}
}