← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20343: ER attribute legend sets.

 

------------------------------------------------------------
revno: 20343
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-24 14:40:52 +0300
message:
  ER attribute legend sets.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.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-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2015-09-24 10:42:19 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2015-09-24 11:40:52 +0000
@@ -412,33 +412,24 @@
                         fields: [idProperty, nameProperty]
                     }),
                     listeners: {
-                        added: function(cb) {
+                        added: function(cb) {                            
                             cb.store.add({
                                 id: defaultRangeSetId,
                                 name: 'No range set'
                             });
 
-                            if (container.dataElement.isAttribute) {
-                                cb.setPendingValue();
-                            }
-                            else {                                
-                                Ext.Ajax.request({
-                                    url: ns.core.init.contextPath + '/api/dataElements/' + container.dataElement.id + '.json?fields=legendSet[id,name]',
-                                    success: function(r) {
-                                        r = Ext.decode(r.responseText);
-
-                                        if (Ext.isObject(r) && Ext.isObject(r.legendSet)) {
-                                            cb.store.add(r.legendSet);
-
-                                            cb.setValue(r.legendSet.id);
-                                            container.onRangeSetSelect(r.legendSet.id);
-                                        }
-                                    },
-                                    callback: function() {
-                                        cb.setPendingValue();
-                                    }
-                                });
-                            }
+                            if (container.dataElement.legendSet) {
+                                var legendSet = ns.core.init.idLegendSetMap[container.dataElement.legendSet.id];
+                                
+                                if (Ext.isObject(legendSet)) {
+                                    cb.store.add(legendSet);
+
+                                    cb.setValue(legendSet.id);
+                                    container.onRangeSetSelect(legendSet.id);
+                                }
+                            }
+
+                            cb.setPendingValue();
                         },
                         select: function(cb, r) {
                             var id = Ext.Array.from(r)[0].data.id;
@@ -4359,7 +4350,7 @@
             }
             else {
                 Ext.Ajax.request({
-                    url: ns.core.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&fields=programStages[id,name],programTrackedEntityAttributes[trackedEntityAttribute[id,' + ns.core.init.namePropertyUrl + ',valueType,optionSet[id,name]]]&paging=false',
+                    url: ns.core.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&fields=programStages[id,name],programTrackedEntityAttributes[trackedEntityAttribute[id,' + ns.core.init.namePropertyUrl + ',valueType,optionSet[id,name],legendSet[id,name]]]&paging=false',
                     success: function(r) {
                         var program = Ext.decode(r.responseText).programs[0],
                             stages,
@@ -4472,7 +4463,7 @@
             }
             else {
                 Ext.Ajax.request({
-                    url: ns.core.init.contextPath + '/api/programStages.json?filter=id:eq:' + stageId + '&fields=programStageDataElements[dataElement[id,' + ns.core.init.namePropertyUrl + ',valueType,optionSet[id,name]]]',
+                    url: ns.core.init.contextPath + '/api/programStages.json?filter=id:eq:' + stageId + '&fields=programStageDataElements[dataElement[id,' + ns.core.init.namePropertyUrl + ',valueType,optionSet[id,name],legendSet[id,name]]]',
                     success: function(r) {
                         var objects = Ext.decode(r.responseText).programStages,
                             dataElements;