← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22092: Program indicator UI. Fixed issue with expressions.

 

------------------------------------------------------------
revno: 22092
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-03-01 12:55:22 +0100
message:
  Program indicator UI. Fixed issue with expressions.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programIndicator.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-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programIndicator.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programIndicator.js	2016-01-10 22:32:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programIndicator.js	2016-03-01 11:55:22 +0000
@@ -66,29 +66,28 @@
 }
 
 function getTrackedEntityDataElements( type ) {
-    var fieldId = type + '-data-elements';
-    clearListById(fieldId);
-
-    var psSelectId = type + '-program-stage';
-    var programStageId = getFieldValue(psSelectId);
-
-    if(programStageId) {
-      jQuery.getJSON('getTrackedEntityDataElements.action',
-        {
-          programId: getFieldValue('programId'),
-          programStageUid: programStageId
-        }, function( json ) {
-          var dataElements = jQuery('#' + fieldId);
-          for( i in json.dataElements ) {
-                    var de = json.dataElements[i];
-
-                    if ( !('expression' == type && de.valueType && dhis2.pi.aggregatableValueTypes.indexOf(de.valueType) == -1)) {
-              dataElements.append("<option value='" + json.dataElements[i].id + "' title='" + json.dataElements[i].name + 
-                "' suggested='" + json.dataElements[i].optionset + "'>" + json.dataElements[i].name + "</option>");
-            }
-          }
-        });
-    }
+	var fieldId = type + '-data-elements';
+	clearListById(fieldId);
+
+	var psSelectId = type + '-program-stage';
+	var programStageId = getFieldValue(psSelectId);
+
+	if(programStageId) {
+		jQuery.getJSON('../api/programStages/' + programStageId + '.json?fields=programStageDataElements[dataElement[id,displayName|rename(name)]',
+		{
+			programId: getFieldValue('programId'),
+			programStageUid: programStageId
+		}, 
+		function( json ) {
+			var dataElements = jQuery('#' + fieldId);
+			$.each( json.programStageDataElements, function(inx, val) {
+				var de = val.dataElement;
+				if ( !('expression' == type && de.valueType && dhis2.pi.aggregatableValueTypes.indexOf(de.valueType) == -1)) {
+					dataElements.append("<option value='" + de.id + "'>" + de.name + "</option>");
+				}
+			} );
+		});
+	}
 }
 
 function insertDataElement( type ) {