← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21700: GIS aggregatable value types + confidential tei.

 

------------------------------------------------------------
revno: 21700
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-01-12 12:24:22 +0100
message:
  GIS aggregatable value types + confidential tei.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.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-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2015-12-29 16:07:55 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2016-01-12 11:24:22 +0000
@@ -7181,13 +7181,11 @@
 				this.sort('name', 'ASC');
 			},
 			setTotalsProxy: function(uid, preventLoad, callbackFn) {
-				var path;
+                var types = gis.conf.valueType.aAggregateTypes.join(','),
+                    path = '/dataElements.json?fields=dimensionItem|rename(id),' + gis.init.namePropertyUrl + '&filter=valueType:in:[' + types + ']&domainType=aggregate&paging=false';
 
 				if (Ext.isString(uid)) {
-                    path = '/dataElements.json?fields=id,' + gis.init.namePropertyUrl + '&domainType=aggregate&paging=false&filter=dataElementGroups.id:eq:' + uid;
-				}
-				else if (uid === 0) {
-					path = '/dataElements.json?fields=id,' + gis.init.namePropertyUrl + '&domainType=aggregate&paging=false';
+                    path += '&filter=dataElementGroups.id:eq:' + uid;
 				}
 
 				if (!path) {
@@ -7219,9 +7217,11 @@
 			},
 			setDetailsProxy: function(uid, preventLoad, callbackFn) {
 				if (Ext.isString(uid)) {
+                    var types = gis.conf.valueType.aAggregateTypes.join(',');
+                        
 					this.setProxy({
 						type: 'ajax',
-						url: gis.init.contextPath + '/api/dataElementOperands.json?fields=id,' + gis.init.namePropertyUrl + '&paging=false&filter=dataElement.dataElementGroups.id:eq:' + uid,
+						url: gis.init.contextPath + '/api/dataElementOperands.json?fields=dimensionItem|rename(id),' + gis.init.namePropertyUrl + '&filter=valueType:in:[' + types + ']&filter=dataElement.dataElementGroups.id:eq:' + uid + '&paging=false',
 						reader: {
 							type: 'json',
 							root: 'dataElementOperands'
@@ -7756,49 +7756,31 @@
         onEventDataItemProgramSelect = function(programId) {
             eventDataItem.clearValue();
 
+            var types = gis.conf.valueType.tAggregateTypes.join(','),
+                namePropertyUrl = gis.init.namePropertyUrl;
+            
             Ext.Ajax.request({
-                url: gis.init.contextPath + '/api/programs.json?paging=false&fields=programTrackedEntityAttributes[trackedEntityAttribute[id,displayName|rename(name),valueType]],programStages[programStageDataElements[dataElement[id,' + namePropertyUrl + ',valueType]]]&filter=id:eq:' + programId,
+                url: gis.init.contextPath + '/api/programDataElements.json?program=' + programId + '&filter=valueType:in:[' + types + ']&fields=dimensionItem|rename(id),name,valueType&paging=false',
+                disableCaching: false,
                 success: function(r) {
-                    r = Ext.decode(r.responseText);
-
-                    var isA = Ext.isArray,
-                        isO = Ext.isObject,
-                        program = isA(r.programs) && r.programs.length ? r.programs[0] : null,
-                        stages = isO(program) && isA(program.programStages) && program.programStages.length ? program.programStages : [],
-                        teas = isO(program) && isA(program.programTrackedEntityAttributes) ? Ext.Array.pluck(program.programTrackedEntityAttributes, 'trackedEntityAttribute') : [],
-                        dataElements = [],
-                        attributes = [],
-                        types = gis.conf.valueType.aggregateTypes,
-                        data;
-
-                    // data elements
-                    for (var i = 0, stage, elements; i < stages.length; i++) {
-                        stage = stages[i];
-
-                        if (isA(stage.programStageDataElements) && stage.programStageDataElements.length) {
-                            elements = Ext.Array.pluck(stage.programStageDataElements, 'dataElement') || [];
-
-                            for (var j = 0; j < elements.length; j++) {
-                                if (Ext.Array.contains(types, elements[j].valueType)) {
-                                    dataElements.push(elements[j]);
-                                }
+                    var elements = Ext.decode(r.responseText).programDataElements,
+                        isA = Ext.isArray,
+                        isO = Ext.isObject;
+
+                    Ext.Ajax.request({
+                        url: gis.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&filter=programTrackedEntityAttributes.trackedEntityAttribute.confidential:eq:false&filter=programTrackedEntityAttributes.valueType:in:[' + types + ']&fields=programTrackedEntityAttributes[dimensionItem|rename(id),' + namePropertyUrl + '|rename(name),valueType]&paging=false',
+                        disableCaching: false,
+                        success: function(r) {
+                            var attributes = (Ext.decode(r.responseText).programs[0] || {}).programTrackedEntityAttributes || [],
+                                data = gis.util.array.sort(Ext.Array.clean([].concat(elements, attributes))) || [];
+
+                            if (data) {
+                                eventDataItemAvailableStore.loadData(data);
                             }
                         }
-                    }
-
-                    // attributes
-                    for (i = 0; i < teas.length; i++) {
-                        if (Ext.Array.contains(types, teas[i].valueType)) {
-                            attributes.push(teas[i]);
-                        }
-                    }
-
-                    data = gis.util.array.sort(Ext.Array.clean([].concat(dataElements, attributes))) || [];
-
-                    eventDataItemAvailableStore.loadData(data);
+                    });
                 }
             });
-
         };
 
 		eventDataItemProgram = Ext.create('Ext.form.field.ComboBox', {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2016-01-08 10:30:35 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/core.js	2016-01-12 11:24:22 +0000
@@ -3009,8 +3009,9 @@
             	textTypes: ['TEXT','LONG_TEXT','LETTER','PHONE_NUMBER','EMAIL'],
             	booleanTypes: ['BOOLEAN','TRUE_ONLY'],
             	dateTypes: ['DATE','DATETIME'],
-            	aggregateTypes: ['NUMBER','UNIT_INTERVAL','PERCENTAGE','INTEGER','INTEGER_POSITIVE','INTEGER_NEGATIVE','INTEGER_ZERO_OR_POSITIVE','BOOLEAN','TRUE_ONLY']
-            };            
+                aAggregateTypes: ['BOOLEAN', 'TRUE_ONLY', 'TEXT', 'LONG_TEXT', 'LETTER', 'INTEGER', 'INTEGER_POSITIVE', 'INTEGER_NEGATIVE', 'INTEGER_ZERO_OR_POSITIVE', 'NUMBER', 'UNIT_INTERVAL', 'PERCENTAGE', 'COORDINATE'],
+            	tAggregateTypes: ['NUMBER','UNIT_INTERVAL','PERCENTAGE','INTEGER','INTEGER_POSITIVE','INTEGER_NEGATIVE','INTEGER_ZERO_OR_POSITIVE','BOOLEAN','TRUE_ONLY']
+            };
 
             conf.url = {};