← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17304: ER option code/name for individual cases.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 17304 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-28 16:23:41 +0100
message:
  ER option code/name for individual cases.
modified:
  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/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-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2014-10-28 14:44:03 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2014-10-28 15:22:45 +0000
@@ -6354,7 +6354,51 @@
 			};
 
 			web.report.createReport = function(layout, response, isUpdateGui) {
-				var map = {};
+				var map = {},
+                    getOptionSets;
+
+                getOptionSets = function(xResponse, callbackFn) {
+                    var optionSetHeaders = [];
+
+                    for (var i = 0; i < xResponse.headers.length; i++) {
+                        if (Ext.isString(xResponse.headers[i].optionSet)) {
+                            optionSetHeaders.push(xResponse.headers[i]);
+                        }
+                    }
+
+                    if (optionSetHeaders.length) {
+                        var callbacks = 0,
+                            optionMap = {},
+                            getOptions,
+                            fn;
+
+                        fn = function() {
+                            if (++callbacks === optionSetHeaders.length) {
+                                xResponse.metaData.optionNames = optionMap;
+                                callbackFn();
+                            }
+                        };
+
+                        getOptions = function(optionSetId, dataElementId) {
+                            dhis2.er.store.get('optionSets', optionSetId).done( function(obj) {
+                                Ext.apply(optionMap, support.prototype.array.getObjectMap(obj.options, 'code', 'name', dataElementId));
+                                fn();
+                            });
+                        };
+
+                        // execute
+                        for (var i = 0, header, optionSetId, dataElementId; i < optionSetHeaders.length; i++) {
+                            header = optionSetHeaders[i];
+                            optionSetId = header.optionSet;
+                            dataElementId = header.name;
+
+                            getOptions(optionSetId, dataElementId);
+                        }
+                    }
+                    else {
+                        callbackFn();
+                    }
+                };
 
 				map['aggregated_values'] = function() {
 					var xLayout,
@@ -6444,48 +6488,7 @@
                         xLayout = service.layout.getExtendedLayout(layout);
                         xResponse = service.response.aggregate.getExtendedResponse(xLayout, response);
 
-                        //get option sets
-                        var optionSetHeaders = [];
-
-                        for (var i = 0; i < xResponse.headers.length; i++) {
-                            if (Ext.isString(xResponse.headers[i].optionSet)) {
-                                optionSetHeaders.push(xResponse.headers[i]);
-                            }
-                        }
-
-                        if (optionSetHeaders.length) {
-                            var callbacks = 0,
-                                optionMap = {},
-                                getOptions,
-                                fn;
-
-                            fn = function() {
-                                if (++callbacks === optionSetHeaders.length) {
-                                    //Ext.apply(xResponse.metaData.names, optionMap);
-                                    xResponse.metaData.optionNames = optionMap;
-                                    getSXLayout();
-                                }
-                            };
-
-                            getOptions = function(optionSetId, dataElementId) {
-                                dhis2.er.store.get('optionSets', optionSetId).done( function(obj) {
-                                    Ext.apply(optionMap, support.prototype.array.getObjectMap(obj.options, 'code', 'name', dataElementId));
-                                    fn();
-                                });
-                            };
-
-                            // execute
-                            for (var i = 0, header, optionSetId, dataElementId; i < optionSetHeaders.length; i++) {
-                                header = optionSetHeaders[i];
-                                optionSetId = header.optionSet;
-                                dataElementId = header.name;
-
-                                getOptions(optionSetId, dataElementId);
-                            }
-                        }
-                        else {
-                            getSXLayout();
-                        }
+                        getOptionSets(xResponse, getSXLayout);
                     };
 
                     // execute
@@ -6495,29 +6498,38 @@
 				};
 
 				map['individual_cases'] = function() {
-					var xResponse = service.response.query.getExtendedResponse(layout, response),
+					var xResponse,
+                        getTable;
+
+                    getTable = function() {
                         table = web.report.query.getHtml(layout, xResponse);
 
-					//if (layout.sorting) {
-						//xResponse = web.report.query.sort(layout, xResponse);
-						//table = web.report.query.getHtml(layout, xResponse);
-					//}
-
-					ns.app.centerRegion.removeAll(true);
-					ns.app.centerRegion.update(table.html);
-
-					// after render
-					ns.app.layout = layout;
-					ns.app.response = response;
-					ns.app.xResponse = xResponse;
-
-					if (NS.isSessionStorage) {
-						web.events.setColumnHeaderMouseHandlers(layout, response, xResponse);
-					}
-
-					ns.app.accordion.setGui(layout, null, response, isUpdateGui, table);
-
-					web.mask.hide(ns.app.centerRegion);
+                        //if (layout.sorting) {
+                            //xResponse = web.report.query.sort(layout, xResponse);
+                            //table = web.report.query.getHtml(layout, xResponse);
+                        //}
+
+                        ns.app.centerRegion.removeAll(true);
+                        ns.app.centerRegion.update(table.html);
+
+                        // after render
+                        ns.app.layout = layout;
+                        ns.app.response = response;
+                        ns.app.xResponse = xResponse;
+
+                        if (NS.isSessionStorage) {
+                            web.events.setColumnHeaderMouseHandlers(layout, response, xResponse);
+                        }
+
+                        ns.app.accordion.setGui(layout, null, response, isUpdateGui, table);
+
+                        web.mask.hide(ns.app.centerRegion);
+                    };
+
+                    // execute
+                    xResponse = service.response.query.getExtendedResponse(layout, response);
+
+                    getOptionSets(xResponse, getTable);
 				};
 
 				map[layout.dataType]();

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js	2014-10-28 12:49:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js	2014-10-28 15:22:45 +0000
@@ -2967,6 +2967,7 @@
 				var dimensionHeaders = xResponse.dimensionHeaders,
 					rows = xResponse.rows,
                     names = xResponse.metaData.names,
+                    optionNames = xResponse.metaData.optionNames,
                     pager = xResponse.metaData.pager,
                     count = pager.page * pager.pageSize - pager.pageSize
 					tableCls = 'pivot',
@@ -3004,7 +3005,8 @@
 					for (var j = 0, str, header, name; j < dimensionHeaders.length; j++) {
 						header = dimensionHeaders[j];
 						str = row[header.index];
-                        str = names.hasOwnProperty(str) ? names[str] : str;
+                        //str = names.hasOwnProperty(str) ? names[str] : str;
+                        str = optionNames[header.name + str] || optionNames[str] || names[str] || str;
 						name = web.report.query.format(str);
 
 						//if (header.name === 'ouname' && layout.showHierarchy) {