← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4686: (wip) Show details - Data element - Changed ajax Request to use jQuery.

 

------------------------------------------------------------
revno: 4686
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-09-26 17:48:38 +0700
message:
  (wip) Show details - Data element - Changed ajax Request to use jQuery.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.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/ajax/jsonDataElement.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm	2010-12-12 19:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm	2011-09-26 10:48:38 +0000
@@ -8,6 +8,20 @@
     "description": "$!encoder.jsonEncode( ${dataElement.description} )",
     "active": "$!{dataElement.active}",
     "type": "$!{dataElement.type}",
-    "aggregationOperator": "$!{dataElement.aggregationOperator}"
+	"valueType": "$!{dataElement.type}",
+	"domainType": "${dataElement.getDomainTypeNullSafe()}",
+    "aggregationOperator": "$!{dataElement.aggregationOperator}",
+	"categoryCombo": "$!encoder.xmlEncode( ${dataElement.categoryCombo.name} )",
+	"url": "$!encoder.xmlEncode( ${dataElement.url} )",
+	"lastUpdated": "$!format.formatDate( ${dataElement.lastUpdated} )",
+	
+	#set( $size = ${dataElement.dataSets.size()} )
+	"dataSets": [
+	#foreach( $ds in ${dataElement.dataSets} )
+	  {
+		"name": "$!encoder.xmlEncode( ${ds.name} )"
+	  }#if( $velocityCount < $size ),#end
+	#end
+	]
   } 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2011-09-26 09:31:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2011-09-26 10:48:38 +0000
@@ -49,69 +49,64 @@
 
 function showDataElementDetails( dataElementId )
 {
-    var request = new Request();
-    request.setResponseTypeXML( 'dataElement' );
-    request.setCallbackSuccess( dataElementReceived );
-    request.send( '../dhis-web-commons-ajax/getDataElement.action?id=' + dataElementId );
-}
-
-function dataElementReceived( dataElementElement )
-{
-    setInnerHTML( 'nameField', getElementValue( dataElementElement, 'name' ) );
-    setInnerHTML( 'shortNameField', getElementValue( dataElementElement, 'shortName' ) );
-
-    var alternativeName = getElementValue( dataElementElement, 'alternativeName' );
-    setInnerHTML( 'alternativeNameField', alternativeName ? alternativeName : '[' + i18n_none + ']' );
-
-    var description = getElementValue( dataElementElement, 'description' );
-    setInnerHTML( 'descriptionField', description ? description : '[' + i18n_none + ']' );
-
-    var active = getElementValue( dataElementElement, 'active' );
-    setInnerHTML( 'activeField', active == 'true' ? i18n_yes : i18n_no );
-
-    var typeMap = {
-        'int' : i18n_number,
-        'bool' : i18n_yes_no,
-        'string' : i18n_text
-    };
-    var type = getElementValue( dataElementElement, 'valueType' );
-    setInnerHTML( 'typeField', typeMap[type] );
-
-    var domainTypeMap = {
-        'aggregate' : i18n_aggregate,
-        'patient' : i18n_patient
-    };
-    var domainType = getElementValue( dataElementElement, 'domainType' );
-    setInnerHTML( 'domainTypeField', domainTypeMap[domainType] );
-
-    var aggregationOperator = getElementValue( dataElementElement, 'aggregationOperator' );
-    var aggregationOperatorText = i18n_none;
-    if ( aggregationOperator == 'sum' )
-    {
-        aggregationOperatorText = i18n_sum;
-    } else if ( aggregationOperator == 'average' )
-    {
-        aggregationOperatorText = i18n_average;
-    }
-    setInnerHTML( 'aggregationOperatorField', aggregationOperatorText );
-
-    setInnerHTML( 'categoryComboField', getElementValue( dataElementElement, 'categoryCombo' ) );
-
-    var url = getElementValue( dataElementElement, 'url' );
-    setInnerHTML( 'urlField', url ? '<a href="' + url + '">' + url + '</a>' : '[' + i18n_none + ']' );
-
-    var lastUpdated = getElementValue( dataElementElement, 'lastUpdated' );
-    setInnerHTML( 'lastUpdatedField', lastUpdated ? lastUpdated : '[' + i18n_none + ']' );
-
-	var temp = '';
-	var dataSets = dataElementElement.getElementsByTagName( 'dataSet' );
-	for ( var i = 0 ; i < dataSets.length ; i ++ )
-	{
-		temp += dataSets[i].firstChild.nodeValue + '<br/>';
-	}
-	setInnerHTML( 'dataSetsField', temp ? temp : '[' + i18n_none + ']' );
+	jQuery.get( '../dhis-web-commons-ajax-json/getDataElement.action', 
+		{ "id": dataElementId }, function( json ) {
+		setInnerHTML( 'nameField', json.dataElement.name );
+		setInnerHTML( 'shortNameField', json.dataElement.shortName );
+
+		var alternativeName = json.dataElement.alternativeName;
+		setInnerHTML( 'alternativeNameField', alternativeName ? alternativeName : '[' + i18n_none + ']' );
+
+		var description = json.dataElement.description;
+		setInnerHTML( 'descriptionField', description ? description : '[' + i18n_none + ']' );
+
+		var active = json.dataElement.active;
+		setInnerHTML( 'activeField', active == 'true' ? i18n_yes : i18n_no );
+
+		var typeMap = {
+			'int' : i18n_number,
+			'bool' : i18n_yes_no,
+			'string' : i18n_text
+		};
+		var type = json.dataElement.valueType;
+		setInnerHTML( 'typeField', typeMap[type] );
+
+		var domainTypeMap = {
+			'aggregate' : i18n_aggregate,
+			'patient' : i18n_patient
+		};
+		var domainType = json.dataElement.domainType;
+		setInnerHTML( 'domainTypeField', domainTypeMap[domainType] );
+
+		var aggregationOperator = json.dataElement.aggregationOperator;
+		var aggregationOperatorText = i18n_none;
+		if ( aggregationOperator == 'sum' )
+		{
+			aggregationOperatorText = i18n_sum;
+		} else if ( aggregationOperator == 'average' )
+		{
+			aggregationOperatorText = i18n_average;
+		}
+		setInnerHTML( 'aggregationOperatorField', aggregationOperatorText );
+
+		setInnerHTML( 'categoryComboField', json.dataElement.categoryCombo );
+
+		var url = json.dataElement.url;
+		setInnerHTML( 'urlField', url ? '<a href="' + url + '">' + url + '</a>' : '[' + i18n_none + ']' );
+
+		var lastUpdated = json.dataElement.lastUpdated;
+		setInnerHTML( 'lastUpdatedField', lastUpdated ? lastUpdated : '[' + i18n_none + ']' );
+		
+		var temp = '';
+		var dataSets = json.dataElement.dataSets;
+		for ( var i = 0 ; i < dataSets.length ; i ++ )
+		{
+			temp += dataSets[i].name + '<br/>';
+		}
+		setInnerHTML( 'dataSetsField', temp ? temp : '[' + i18n_none + ']' );
 	
-    showDetails();
+		showDetails();
+	});
 }
 
 function getDataElements( dataElementGroupId, type, filterCalculated )