← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19171: ER EV order of boolean items fixed.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 19171 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-05-21 17:35:59 +0200
message:
  ER EV order of boolean items fixed.
modified:
  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-visualizer/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/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js	2015-05-19 13:12:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js	2015-05-21 15:32:20 +0000
@@ -1969,6 +1969,60 @@
                             support.prototype.array.sort(objects, 'ASC', 'sortingId');
                             header.ids = Ext.Array.pluck(objects, 'id');
                         }
+                        else if (header.type === 'java.lang.Boolean') {
+							var objects = [];
+
+                            for (var k = 0, id, fullId, name, isHierarchy; k < response.rows.length; k++) {
+                                id = response.rows[k][i] || emptyId;
+
+                                // hide NA data
+                                if (xLayout.hideNaData && id === emptyId) {
+                                    continue;
+                                }
+
+                                fullId = header.name + id;
+                                isHierarchy = service.layout.isHierarchy(xLayout, response, id);
+
+                                // add dimension name prefix if not pe/ou
+                                name = isMeta ? '' : header.column + ' ';
+
+                                // add hierarchy if ou and showHierarchy
+                                name = isHierarchy ? service.layout.getHierarchyName(ouHierarchy, names, id) : (names[id] || id);
+
+                                names[fullId] = name;
+
+                                // update rows
+                                response.rows[k][i] = fullId;
+
+                                // update ou hierarchy
+                                if (isHierarchy) {
+									ouHierarchy[fullId] = ouHierarchy[id];
+								}
+
+                                // update boolean metadata
+                                response.metaData.booleanNames[id] = booleanNameMap[id];
+                                response.metaData.booleanNames[fullId] = booleanNameMap[id];
+
+								objects.push({
+									id: fullId,
+									sortingId: id
+								});
+                            }
+
+                            // sort
+                            objects.sort(function(a, b) {
+                                if (a.sortingId === emptyId) {
+                                    return 1;
+                                }
+                                else if (b.sortingId === emptyId) {
+                                    return -1;
+                                }
+
+                                return a.sortingId - b.sortingId;
+                            });
+
+                            header.ids = Ext.Array.pluck(objects, 'id');
+                        }
                         else if (header.name === 'pe') {
                             var selectedItems = xLayout.dimensionNameIdsMap['pe'],
                                 isRelative = false;
@@ -2016,15 +2070,9 @@
 									ouHierarchy[fullId] = ouHierarchy[id];
 								}
 
-                                // update boolean metadata
-                                if (header.type === 'java.lang.Boolean') {
-                                    response.metaData.booleanNames[id] = booleanNameMap[id];
-                                    response.metaData.booleanNames[fullId] = booleanNameMap[id];
-                                }
-
 								objects.push({
 									id: fullId,
-									sortingId: header.name === 'pe' ? fullId : name
+									sortingId: name
 								});
                             }
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js	2015-05-13 16:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/core.js	2015-05-21 15:34:29 +0000
@@ -2612,6 +2612,60 @@
                             support.prototype.array.sort(objects, 'ASC', 'sortingId');
                             header.ids = Ext.Array.pluck(objects, 'id');
                         }
+                        else if (header.type === 'java.lang.Boolean') {
+							var objects = [];
+
+                            for (var k = 0, id, fullId, name, isHierarchy; k < response.rows.length; k++) {
+                                id = response.rows[k][i] || emptyId;
+
+                                // hide NA data
+                                if (xLayout.hideNaData && id === emptyId) {
+                                    continue;
+                                }
+
+                                fullId = header.name + id;
+                                isHierarchy = service.layout.isHierarchy(xLayout, response, id);
+
+                                // add dimension name prefix if not pe/ou
+                                name = isMeta ? '' : header.column + ' ';
+
+                                // add hierarchy if ou and showHierarchy
+                                name = isHierarchy ? service.layout.getHierarchyName(ouHierarchy, names, id) : (names[id] || id);
+
+                                names[fullId] = name;
+
+                                // update rows
+                                response.rows[k][i] = fullId;
+
+                                // update ou hierarchy
+                                if (isHierarchy) {
+									ouHierarchy[fullId] = ouHierarchy[id];
+								}
+
+                                // update boolean metadata
+                                response.metaData.booleanNames[id] = booleanNameMap[id];
+                                response.metaData.booleanNames[fullId] = booleanNameMap[id];
+
+								objects.push({
+									id: fullId,
+									sortingId: id
+								});
+                            }
+
+                            // sort
+                            objects.sort(function(a, b) {
+                                if (a.sortingId === emptyId) {
+                                    return 1;
+                                }
+                                else if (b.sortingId === emptyId) {
+                                    return -1;
+                                }
+
+                                return a.sortingId - b.sortingId;
+                            });
+
+                            header.ids = Ext.Array.pluck(objects, 'id');
+                        }
                         else if (header.name === 'pe') {
                             var selectedItems = xLayout.dimensionNameIdsMap['pe'],
                                 isRelative = false;
@@ -2659,15 +2713,9 @@
 									ouHierarchy[fullId] = ouHierarchy[id];
 								}
 
-                                // update boolean metadata
-                                if (header.type === 'java.lang.Boolean') {
-                                    response.metaData.booleanNames[id] = booleanNameMap[id];
-                                    response.metaData.booleanNames[fullId] = booleanNameMap[id];
-                                }
-
 								objects.push({
 									id: fullId,
-									sortingId: header.name === 'pe' ? fullId : name
+									sortingId: name
 								});
                             }